Chandra X-Ray Observatory
Skip to the navigation links
Last modified: 13 March 2017

How do I change the AtomDB version used by XSPEC Apec models?

The XSPEC Apec models - such as xsapec, xsbapec, xsbvapec and xsvapec - default to using version 2.0.2 of the AtomDB atomic database. To use a different version you need to change the value of the APECROOT variable used by the XSPEC model, using the set_xsxset command, as described elsewhere.

Using the versions distributed with Sherpa

The model distributed as part of Sherpa provides data for the following AtomDB versions: 1.10, 1.2.0, 1.3.1, and 2.0.2. So, to change to use 1.3.1 you would say:

sherpa> set_xsxset("APECROOT", "1.3.1")

and all XSPEC Apec model components will use this version of the database whenever they are evaluated (e.g. in fitting, error analysis, calculating statistics or plotting).

Example: Comparison of 2.0.2 with 1.3.1

In the following script, we show how you can compare the values from the xsapec model for versions 1.3.1 and 2.0.2 of the AtomDB. The choice of energy range and model parameters made here was for didactic reasons rather than to highlight any specific feature in the new database.

# Create an instance of the XS apec model
mdl = xsapec.mdl
mdl.kt = 1.5
mdl.abundanc = 1

# Energy range over which to evaluate the model
#   x1 uses a bin width of 1 eV and
#   x2 uses                0.1 eV
# The lo/hi arrays give the left and right values
# of each bin for the model evaluation.
x1 = np.arange(1.05, 1.061, 0.001)
lo1 = x1[:-1]
hi1 = x1[1:]

x2 = np.arange(1.05, 1.061, 0.0001)
lo2 = x2[:-1]
hi2 = x2[1:]

# Evaluate using version 1.3.1
set_xsxset("APECROOT", "1.3.1")
y131_1 = mdl(lo1, hi1)
y131_2 = mdl(lo2, hi2)

# Use version 2.0.2
set_xsxset("APECROOT", "2.0.2")
y202_1 = mdl(lo1, hi1)
y202_2 = mdl(lo2, hi2)

# Plot the results
add_window(8, 6, "inches")
add_histogram(lo1, hi1, y131_1, ["line.thickness", 2])
add_histogram(lo1, hi1, y202_1, ["line.color", "orange"])

set_plot_title(r"AtomDB: 1.3.1  vs  \color{orange}2.0.2")
set_plot(["title.size", 24])

add_histogram(lo2, hi2, y131_2, ["line.thickness", 2])
add_histogram(lo2, hi2, y202_2, ["line.color", "orange"])


set_plot_xlabel("Energy (keV)")

set_yaxis(["offset.perpendicular", 60])
set_axis(["label.size", 18, "ticklabel.size", 16])

add_label(0.95,0.85,"kT_x = 1.5 keV", ["coordsys", PLOT_NORM,
   "halign", 1, "size", 18])
add_label(0.95,0.75,r"A = 1_\sun", ["coordsys", PLOT_NORM,
   "halign", 1, "size", 18])

print_window("compare.131-202.png", ["clobber", True])
print("Created: compare.131-202.png")

If these files are stored in the file then they can be run by saying:

unix% sherpa
Welcome to Sherpa: CXC's Modeling and Fitting Package
CIAO 4.8 Sherpa version 1 Thursday, December 3, 2015

Created: compare.131-202.png

which creates the following plot:

[There are small differecnces in the two models]

Using the default version

To get back to the default version of the AtomDB, clear the APECROOT setting by saying:

sherpa> set_xsxset("APECROOT", "")


The set_xsxset call to change the APECROOT value needs to be made each time Sherpa is used (analagous to how changes to the XSPEC abundance setting, using set_xsabund, must be made each session).

Last modified: 13 March 2017
Smithsonian Institute Smithsonian Institute

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