Package: deproject
Deprojectis aSherpaextension package
to facilitate deprojection of two-dimensional annular X-ray spectra to recover
the three-dimensional source properties.  For typical thermal models this would
include the radial temperature and density profiles. This basic method has been
used extensively for X-ray cluster analysis and is the basis for the XSPEC
modelprojct.  Thedeprojectmodule brings this functionality toSherpaas a Python module that is straightforward to use and understand.The basic physical assumption ofdeprojectis that the extended source
emissivity is constant and optically thin within spherical shells whose radii
correspond to the annuli used to extract the specta.  Given this assumption one
constructs a model for each annular spectrum that is a linear volume-weighted
combination of shell models.Version 0.2 ofdeprojectis limited to circular annuli.Further documentation is available athttps://deproject.readthedocs.io/LicenseThedeprojectmodule is released under theBSD 2-Clause license,
available as the fileLICENSEin the source distribution.RequirementsThe installation assumes that you are installingdeprojectinto
theCIAO environment(CIAO 4.14 or
later), since this is the easiest way to get the XSPEC models along
with Sherpa. Thestandalone Sherpaversion can be used, but in this case you will need tobuild Sherpa
with XSPEC support.The following Python packages are required:sherpa >= 4.14.0AstropySciPy.InstallationFor Standalone Sherpa or CIAO versions newer than CIAO 4.14,
you should be able to installdeprojectwith the command:pip3 install deprojectThe installation requires pip version 19 or higher, but as that
was released in early 2019 it should be available.Theinstallation documentationdescribes how
to build a development version from theGitHub repository.ExampleIf you have a set of X-ray PHA spectra called src<n>.pi, where <n> is
an integer representing the annulus number, and the files contain theXFLT0001toXFLT0005header keywords used by theXSPEC projct model,
then aDeproject objectcan be created using thedeproject_from_xflthelper routine with the commands:>>> from deproject import deproject_from_xflt
>>> from astropy import units as u
>>> dep = deproject_from_xflt('src*.pi', 0.492 * u.arcsec)where, in this example, theXFLT0001andXFLT0002keywords,
which specify the inner and outer radii of the annulus, are in
ACIS pixels, and so need to be multiplied by 0.492 arcseconds to
convert to an angle (the second parameter).This will automatically load the spectra into separate Sherpa datasets,
whichcanbe fitted individually, but it is generally easier to use
the object returned bydeproject_from_xflt. For instance, the
following will set the data range to be fit foreachspectra and ensure
that the background is subtracted before fitting:>>> dep.ignore(None, 0.5)
>>> dep.ignore(7.0, None)
>>> dep.subtract()Sherpa functions are used to change the statistic and optimiser:>>> from sherpa.astro import ui
>>> ui.set_stat('chi2xspecvar')
>>> ui.set_method('levmar')The data can be fit, and errors estimated for all the parameter, using
the onion-skin deprojection approach, with the following commands:>>> onion = dep.fit()
>>> errs = dep.conf()The return value includes the density (and errors, if appropriate), as
anAstropy Quantity.>>> print(onion['density'])
print(onion['density'])
      density
      1 / cm3
--------------------
  0.1100953546292787
 0.07736622021374819
 0.04164827967805805
 0.03630168106524076
0.025221797991301052
0.021845331641349316
                 ...
0.012396857131392835
 0.01336640115325031
0.012303975980575187
0.013631563529090736
0.013996131292837352
0.010843683594144967
0.023067220584935984
Length = 20 rowsTheon-line documentationcontains more information, including creating theDeprojectobject
directly (without the need for theXFLTxxxxkeywords).