About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: 20 October 2009

URL: http://cxc.harvard.edu/sherpa4.1/convert/index.html

Command Comparison: Sherpa 3.4 vs. Sherpa 4.1


The table below provides the Sherpa 4.1 (Python) translation for a list of commonly used Sherpa 3.4 commands, to assist with your transition to the new syntax. See the Sherpa ahelp pages for detailed information on each Sherpa 4.1 function, including the corresponding S-Lang syntax.

To view complete Sherpa 3.4 and 4.1 (Python or S-Lang) scripts side-by-side for various 1-D and 2-D plotting and fitting scenarios, visit the Sherpa Gallery of Examples, which includes eighteen common Sherpa use cases.

The CXC is committed to helping Sherpa users transition to new the syntax as smoothly as possible. If you have existing Sherpa scripts or save files, submit them to us via the CXC Helpdesk and we will provide the Sherpa 4.1 syntax to you.

Sherpa 3.4 Sherpa 4.1 (Python)
ANALYSIS set_analysis([id], quantity, [type, factor])

Assuming data set with given ID contains PHA data:

quantity - "energy", "wavelength", "channel", or "bin"
type - "rate", "counts"
factor - 0, 1, 2, ..., n
BACK load_bkg([id], arg, [use_errors, bkg_id])

Assuming data set with given ID contains PHA data:

arg - filename and path | PHACrate obj | PyFITS HDUList obj
BACKERRORS | BERRORS | BSTATERRORS get_staterror([id, filter, bkg_id]) get_error([id, filter, bkg_id])
BACKGROUND | BG set_bkg_model([id], model, [bkg_id])
BDCOUNTS calc_data_sum([lo, hi, id, bkg_id])
BEFLUX calc_energy_flux([lo, hi, id, bkg_id])
BGROUP group([id, bkg_id])
BMCOUNTS calc_model_sum([lo, hi, id, bkg_id])
BSYSERRORS Assuming data set with given ID contains PHA data: get_syserror([id, filter, bkg_id])
BUNGROUP ungroup([id, bkg_id])
BYE | EXIT | QUIT Ctrl-D, exit
CLOSE TBD
COORD set_coord([id], coord)
COVARIANCE covar([id, otherids ... , pars])
CPLOT contour_data([id])
contour_model([id])
contour_fit([id])
contour_resid([id])
contour_ratio([id])
contour_psf([id])
contour_fit_resid([id])
or
contour(arg1, [id], arg2, [id], ...])

where arg* is one of "data", "model", "fit", "psf", "resid", or "ratio"
CREATE abs1 = xsphabs.abs1 or abs1 = create_model_component("xsphabs", "abs1")
DATA arg - filename and path | PHACrate obj | PyFITS HDUList obj

load_arf([id], arg, [resp_id, bkg_id])
load_ascii([id], arg, [ncols, colkeys, dstype, sep, comment])
load_data([id], filename, [...])
load_image([id], arg, [coord])
load_pha([id], arg, [use_errors])
load_rmf([id], arf, [resp_id, bkg_id])
load_table([id], arg, [ncols, colkeys, dstype])
DATASPACE dataspace1d(start, stop, [step, id, bkg_id, dstype])
dataspace2d(dims, [id, dstype])

dstype - Data1DInt, Data2D, Data2DInt, DataARF, DataIMG, DataPHA, or DataRMF
DCOUNTS calc_data_sum([lo, hi, id, bkg_id])
ECHO For Python users, IPython's logging mechanism is an option. %logstart ... %logstop
EFLUX calc_energy_flux([lo, hi, id, bkg_id])
EQWIDTH eqwidth(cont, cont+eline, [id, bkg_id])
ERASE clean()
ERRORS get_error([id, filter, bkg_id])
FAKEIT fake_pha(id, arf, rmf, exposure, [backscal, areascal, grouping, grouped, quality, bkg])
FEFFILE deprecated
FEFPLOT deprecated
FIT | RUN fit([id, otherids ..., outfile, clobber])
FLUX calc_photon_flux([lo, hi, id, bkg_id])
FREEZE freeze(list params or models)
FTEST ftest(dof_1, stat_1, dof_2, stat_2)
GETX TBD
GETY TBD
GOODNESS get_fit_results()

get_fit_results().statval
get_fit_results().numpoints
get_fit_results().dof
get_fit_results().qval
get_fit_results().rstat
get_fit_results().nfev
get_fit_results().modelvals
get_fit_results().parnames
get_fit_results().parvals
GROUP group([id, bkg_id])
IGNORE Apply to all data sets:

ignore(3, 5) # IGNORE FILTER 3:5
ignore(3) # IGNORE FILTER 3:
ignore(None | NULL, 5) # IGNORE FILTER :5
ignore("4,8:,1:3") # IGNORE FILTER 4, 8:, 1:3
ignore() # IGNORE ALL

Apply to data set by id:

ignore_id(id, 3, 5) # IGNORE id FILTER 3:5
ignore_id(id, 3) # IGNORE id FILTER 3:
ignore_id(id, None | NULL, 5) # IGNORE id FILTER :5
ignore_id(id, "4,8:,1:3") # IGNORE id FILTER 4, 8:, 1:3
ignore_id(id) # IGNORE id ALL
IMAGE image_data()
image_model()
image_fit()
image_psf()
image_ratio()
image_resid()
image_source()
INSTRUMENT | RESPONSE load_rmf()
load_arf()
load_psf()
INTEGRATE abs1 = atten.abs1

abs1.integrate = True | 1
abs1.integrate = False | 0
INTERVAL-PROJECTION | INT-PROJ int_proj(param, [id, otherids, replot, min, max, nloop, delv, fac, log, overplot])

Print reg_proj parameters

print(get_int_proj())
INTERVAL-UNCERTAINTY | INT-UNC int_unc(param, [id, otherids, replot, min, max, nloop, delv, fac, log, overplot])

Print reg_unc parameters

print(get_int_unc())

JOURNAL For Python users, IPython's history mechanism is an option.
!cat ~/.ipython-ciao/history-sherpa
LINK link()
LPLOT plot_arf([id, resp_id, replot, overplot])
plot_bkg([id, bkg_id, replot, overplot])
plot_bkg_chisqr([id, bkg_id, replot, overplot])
plot_bkg_delchi([id, bkg_id, replot, overplot])
plot_bkg_fit([id, bkg_id, replot, overplot])
plot_bkg_fit_delchi([id, bkg_id, replot, overplot])
plot_bkg_fit_resid([id, bkg_id, replot, overplot])
plot_bkg_model([id, bkg_id, replot, overplot])
plot_bkg_ratio([id, bkg_id, replot, overplot])
plot_bkg_resid([id, bkg_id, replot, overplot])
plot_bkg_source([id, lo, hi, bkg_id, replot, overplot])
plot_chisqr([id, replot, overplot])
plot_data([id, replot, overplot])
plot_delchi([id, replot, overplot])
plot_fit([id, replot, overplot])
plot_fit_delchi([id, replot, overplot])
plot_fit_resid([id, replot, overplot])
plot_model([id, replot, overplot])
plot_ratio([id, replot, overplot])
plot_resid([id, replot, overplot])
plot_source([id, lo, hi, replot, overplot])

or

plot(arg1, [id], arg2, [id], ...)

where arg* is one of "arf","bkg","bkgchisqr", "bkgdelchi","bkgfit","bkgmodel","bkgratio", "bkgresid","bkgsource","chisqr","data","delchi", "fit","model","psf","ratio","resid","source"
MCOUNTS calc_model_sum([lo, hi, id, bkg_id])
METHOD | SEARCHMETHOD set_method(method_name)
MLR mlr(delta_dof, delta_stat)
NOTICE Apply to all data sets:

notice(3, 5) # NOTICE FILTER 3:5
notice(3) # NOTICE FILTER 3:
notice(None | NULL, 5) # NOTICE FILTER :5
notice("4,8:,1:3") # NOTICE FILTER 4, 8:, 1:3
notice() # NOTICE ALL

Apply to one data set:

notice_id(id, 3, 5) # NOTICE id FILTER 3:5
notice_id(id, 3) # NOTICE id FILTER 3:
notice_id(id, None | NULL, 5) # NOTICE id FILTER :5
notice_id(id, "4,8:,1:3") # NOTICE id FILTER 4, 8:, 1:3
notice_id(id) # NOTICE id ALL
OPEN image_open()
OPLOT plot_data(overplot=True)
PARAMPROMPT N/A
PLOTX Removed as of CIAO 3.0.2
PLOTY TBD
PROJECTION proj([id, otherids ..., param])
PROMPT N/A
READ arg - filename and path | PHACrate obj | PyFITS HDUList obj

load_arf([id], arg, [resp_id, bkg_id])
load_ascii([id], arg, [ncols, colkeys, dstype, sep, comment])
load_data([id], filename, [...])
load_image([id], arg, [coord])
load_pha([id], arg, [use_errors])
load_rmf([id], arf, [resp_id, bkg_id])
load_table([id], arg, [ncols, colkeys, dstype])
RECORD For Python users

fit(outfile=<filename>, clobber=True)

For S-lang users

fit(;outfile=<filename>, clobber=1)
REGION-PROJECTION | REG-PROJ reg_proj(param_1, param_2, [id, otherids, replot, min, max, nloop, delv, fac, log, sigma, levels, overplot])

Print reg_proj parameters

print(get_reg_proj())

REGION-UNCERTAINTY | REG-UNC reg_unc(param_1, param_2, [id, otherids, replot, min, max, nloop, delv, fac, log, sigma, levels, overplot])

Print reg_unc parameters

print(get_reg_unc())
RENAME modelb = gauss1d.modelb

modelB = modelb
RESET reset(get_model())

reset(p1)
RESPONSE | INSTRUMENT load_rmf() load_arf() load_psf()
SAVE save([filename]) --> produces binary file

then later ...
restore([filename])
SEARCHMETHOD | METHOD set_method(method_name)
SETBACK Assuming data set with given ID contains PHA data:

set_counts([id], val, [bkg_id])
set_exposure([id], exptime, [bkg_id])
set_backscal([id], backscale, [bkg_id])
set_areascal([id], area, [bkg_id])
SETDATA Assuming data set with given ID contains PHA data:

set_counts([id], val, [bkg_id])
set_exposure([id], exptime, [bkg_id])
set_backscal([id], backscale, [bkg_id])
set_areascal([id], area, [bkg_id])
SHOW Show session objects

show_all([id, outfile, clobber])
show_data([id, outfile, clobber])
show_covar([outfile, clobber])
show_filter([id, outfile, clobber])
show_method([outfile, clobber])
show_model([id, outfile, clobber])
show_proj([outfile, clobber])
show_source([id, outfile, clobber])
show_stat([outfile, clobber])

List session state info

list_bkg_ids()
list_data_ids()
list_methods()
list_model_components()
list_model_ids()
list_models()
list_response_ids()
list_stats()
SOURCE | SRC set_model()
set_source()
SPLOT N/A
STATISTIC set_stat(stat_name)

calc_stat([id, otherids ...])
calc_chisqr([id, otherids ...])
SUBTRACT subtract([id])
STATERRORS get_staterror([id, filter, bkg_id])
set_staterror([id], val, [fractional,] [bkg_id])
SYSERRORS get_syserror([id, filter, bkg_id])
set_syserror([id], val, [fractional,] [bkg_id])
THAW thaw(list params or model)
TRUNCATE TBD
UNCERTAINTY deprecated
UNGROUP ungroup([id, bkg_id])
UNLINK unlink(param)
UNSUBTRACT unsubtract([id])
USE Execute script in Python:

execfile(filename)

Execute script in S-Lang:

() = evalfile(filename)

Restore a previous Sherpa session

restore([filename])
VERSION In Python:

import sherpa
sherpa.__version__

In S-Lang:

_sherpa_version
_sherpa_version_string
WRITE TBD

Workaround for writing ASCII or FITS table files:

Step 1:
load_arrays("my_model", get_model_plot().x, get_model_plot().y) #non-PHA 1D data set
load_arrays("my_model", get_model_plot().xlo, get_model_plot().y) # PHA 1D data set

Step 2:
save_data("my_model", "filename") # ASCII table
save_table("my_model", "filename") # FITS table

For writing FITS image files:

cr_image = pack_image()
set_imagevals(cr_image, get_resid_image().y)
write_file(cr_image, "resid_image.fits")

set_imagevals(cr_image,get_model_image().y)
write_file(cr_image,"model_image.fits")
XSPEC ABUNDAN set_xsabund(name)
get_xsabund()
XSPEC XSECT set_xsxsect(name)
get_xsxsect()
Last modified: 20 October 2009


The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory.
60 Garden Street, Cambridge, MA 02138 USA.    Email: cxcweb@head.cfa.harvard.edu
Smithsonian Institution, Copyright © 1998-2004. All rights reserved.