Loading repository data…
Loading repository data…
DavidT3 / repository
X-ray: Generate and Analyse (XGA) provides a Python interface to high-energy astrophysics data product generation and analysis, enabling large scale interactive/scripted exploration of X-ray sources. XMM, eROSITA, and Chandra (partial) are supported. Product classes provide powerful Python interfaces with high-energy data products.
XGA is a Python module designed to make it easy to analyse X-ray sources that have been observed by the XMM-Newton Space telescope. It is based around declaring different types of source and sample objects which correspond to real X-ray sources, finding all available data, and then insulating the user from the tedious generation and basic analysis of X-ray data products.
XGA will generate photometric products and spectra for individual sources, or whole samples, with just a few lines of code. It is not a pipeline itself, but pipelines for complex analysis can easily be built on top of it. XGA provides an easy to use (and parallelised) Python interface with XMM's Science Analysis System (SAS), as well as with XSPEC. A major goal of this module is that you shouldn't need to leave a Python environment at any point during your analysis, as all XMM products and fit results are read into an XGA source storage structure.
This module also supports more complex analyses for specific object types; the easy generation of scaling relations, the measurement of gas masses for galaxy clusters, and the PSF correction of images for instance.
This is a slightly more complex installation than many Python modules, but shouldn't be too difficult. If you're having issues feel free to contact me.
This is very important - Currently, to make use of this module, you must have access to cleaned XMM-Newton event lists, as XGA is not yet capable of producing them itself.
It will be beneficial if you have region files available, as it will allow XGA to remove interloper sources. If you wish to use existing region files, then they must be in a DS9 compatible format, point sources must be red and extended sources must be green.
We strongly recommend that you make use of Python virtual environments, or (even better) Conda/Mamba virtual environments when installing XGA.
XGA is available on the popular Python Package Index (PyPI), and can be installed like this:
pip install xga
You can also fetch the current working version from the git repository, and install it:
git clone https://github.com/DavidT3/XGA
cd XGA
python -m pip install .
Alternatively you could use the 'editable' option so that any changes you pull from the remote repository are reflected without having to reinstall XGA.
git clone https://github.com/DavidT3/XGA
cd XGA
python -m pip install --editable .
We also provide a Conda lock file in the conda_envs directory (see conda-lock GitHub README on how to install conda-lock), which can be used to create an Anaconda environment with the required dependencies (excepting PyAbel, which has to be installed through pip at this time):
conda-lock install -n <YOUR ENVIRONMENT NAME GOES HERE>
conda activate <YOUR ENVIRONMENT NAME GOES HERE>
pip install pyabel==0.9
[!IMPORTANT] For Python 3.10 and earlier, the optional dependency contextlib-chdir must be installed.
XGA depends on two non-Python pieces of software:
All required Python modules can be found in requirements.txt, and should be added to your system during the installation of XGA.
Excellent installation guides for SAS and HEASoft already exist, so I won't go into that in this readme. XGA will not run without detecting these pieces of software installed on your system.
XGA can also make use of external software for some limited tasks, but they are not required to use the module as a whole:
The R interpreter, Rpy2, and LIRA are all necessary only if you wish to use the LIRA scaling relation fitting function.
Before XGA can be used you must fill out a configuration file (a completed example can be found here).
Follow these steps to fill out the configuration file:
XGA_CONFIG_DIR environment variable. If set, XGA will look for its configuration and store its census files in exactly that directory.I have tried to make this part as general as possible, but I am biased by how XCS generates and stores their data products. If you are an X-ray astronomer who wishes to use this module, but it seems to be incompatible with your setup, please get in touch or raise an issue.
Remote Data Access: If your data lives on a remote server, and you want to use XGA on a local machine, I recommend setting up an SFTP connection and mounting the server as an external volume. Then you can fill out the configuration file with paths going through the mount folder - its how I use it a lot of the time.
The first time you import any part of XGA, it will create an 'observation census', where it will search through all the observations it can find (based on your entries in the configuration file), check that there are events lists present, and record the pointing RA and DEC. This can take a while, but will only take that long on the first run. The module will check the census against your observation directory and see if it needs to be updated on every run.
Please refer to the tutorials in the documentation, which can be found here
If you encounter a bug, or would like to make a feature request, please use the GitHub issues page, it really helps to keep track of everything.
However, if you have further questions, or just want to make doubly sure I notice the issue, feel free to send me an email at djturner@umbc.edu