heasoftpy: A Python Interface To HEASoftWhat is heasoftpy?heasoftpy is a Python 3 package that allows users to more easily integrate HEASoft tools into their Python workflow. heasoftpy provides Python wrappers to the HEASoft tools (and thus requires a HEASoft installation of course). Note that heasoftpy does NOT provide Python native versions of HEASoft tools.Please note that this is a BETA release, so some functionality may be missing, and improvements may be forthcoming. InstallationAs of the HEASoft 6.29 release (July 2021), all downloads include and install HEASoftPy by default, but if you are using an older version of HEASoft, please refer to the following instructions: Installation of heasoftpy is simple. Assuming you have HEASoft initialized and the environment variable $HEADAS is defined, you should:
Python functions corresponding to tasks in the HEASoft suite will be written into the $HEADAS/lib/python/heasoftpy/defs directory. Please note that if you add new tasks to your installation and want heasoftpy to be able to access them, you will need to repeat the process above. Lastly, to make sure that $HEADAS/lib/python is included in your PYTHONPATH environment variable, you may need to re- initialize HEASoft by sourcing the standard HEASoft setup script: $ source $HEADAS/headas-init.sh (Bourne shell variants) Or $ source $HEADAS/headas-init.csh (C-shell variants) Using heasoftpyThe heasoftpy functions in $HEADAS/lib/python/heasoftpy/defs are wrappers to whatever HEASoft tools you currently have installed (this could be all HEASoft tasks or some subset of the full distribution, depending on which package choices you made when downloading).The heasoftpy functions run HEASoft tools and return a Result object. The Result object is a container for data returned from a heasoftpy call to a HEAsoft tool, and has the following attributes:
Some Usage ExamplesImporting and using heasoftpy in a Python 3 session is simple:% ipython In [1]: import heasoftpy as hsp In [2]: hsp? # get help on the heasoftpy package In [3]: myfitsfile = 'Test.fits' In [4]: hsp_result = hsp.ftverify(myfitsfile) In [5]: print(hsp_result.stdout) In [6]: output = hsp_result.stdout.split('\n') in [7]: verification = [x for x in output if 'Verification found' in x] # list of the verification strings in the outputTo find the effective area for NICER, you could do this: In [1]: import heasoftpy as hsp In [2]: hsp_result = hsp.quzcif() # heasoftpy will prompt you for unspecified required parameters Name of Mission> nicer Name of Instrument> xti Name of Detector (- if not required)> - Name of Filter (- if not required)> - Calibration Dataset Codename> SPECRESP Requested Date in yyyy-mm-dd format> now Requested Time in hh:mm:ss format> now Boolean selection expression for Boundary params(- if not required)> - In [3]: hsp_result.stdout Out[3]: 'https://heasarc.gsfc.nasa.gov/FTP/caldb/data/nicer/xti/cpf/arf/nixtiaveonaxis20170601v004.arf 1\n' In [4]: arf = hsp_result.stdout.split()[0] In [5]: print('The current NICER ARF is {0}'.format(arf)) The current NICER ARF is https://heasarc.gsfc.nasa.gov/FTP/caldb/data/nicer/xti/cpf/arf/nixtiaveonaxis20170601v004.arf HelpPlease send any comments or questions to the ftools help deskLast modified Wednesday, 04-Aug-2021 13:09:28 EDT FTOOLS HELP DESK If FTOOLS has been useful in your research, please reference this site (http://heasarc.gsfc.nasa.gov/ftools) and use the ASCL reference for HEASoft [ascl:1408.004] or the ASCL reference for the original FTOOLs paper [ascl:9912.002]: Blackburn, J. K. 1995, in ASP Conf. Ser., Vol. 77, Astronomical Data Analysis Software and Systems IV, ed. R. A. Shaw, H. E. Payne, and J. J. E. Hayes (San Francisco: ASP), 367. Web page maintained by: Bryan K. Irby HEASARC Home | Observatories | Archive | Calibration | Software | Tools | Students/Teachers/Public Last modified: Wednesday, 04-Aug-2021 13:09:28 EDT |