4.3 Notable Python Packages for HST
Many of the software tools that are useful for analyzing HST data may be found in the Astropy library of Python modules. Additionally, some other Python modules are in Astropy-affiliated packages or are released directly by STScI. All of these packages are located within the AstroConda channel. For more information on AstroConda, see Section 4.2.
The following subsections list some Python tools that may be of interest to users. This is not an exhaustive list, but one that provides some of the most commonly used and recommended tools in topics of interest to HST users.
4.3.1 Data Retrieval
As discussed in Chapter 1, HST data may be obtained via the MAST portal. Data may also be obtained using the astroquery Python package for instances when one wishes to combine the data access with the analysis code. Furthermore, astroquery can be used to retrieve catalog information. The astroquery documentation (https://astroquery.readthedocs.io/en/latest/) contains information on supported archives and catalogs along with instructions for access and numerous examples.
4.3.2 Data Visualization
SAOImage DS9 (http://ds9.si.edu/site/Home.html) is a common tool for opening FITS data files and visualizing astronomical data. DS9 is included by default when creating an AstroConda environment.
As an alternative to DS9, some advanced Python users may be interested in using ginga (https://ginga.readthedocs.io/en/latest/). Ginga is a generic, customizable tool for visualizing numpy data arrays. Ginga functionality may be extended using plug-ins, and a set of plug-ins for functions common to HST data analysis are contained within stginga (https://stginga.readthedocs.io/en/stable/).
Users familiar with the IRAF task imexam will find useful the Python version of the tool with the same name. Documentation for Python imexam may be found at https://imexam.readthedocs.io/en/latest/.
The Python version of imexam contains all of the familiar functions from the IRAF task of the same name, however users may find that this implementation is more complex than its predecessor. Helpful examples are presented within the documentation linked above. Some basic functionality is demonstrated in Section 4.5, however users should always reference the code documentation for the most accurate and up-to-date syntax.
Glue is a tool for exploring your data. The previously discussed tools described how to visualize specifically imaging data, but glue is primarily made for exploring multi-dimensional datasets. More information about glue may be found on the website https://glueviz.org/.
AstroDrizzle is used to combine dithered imaging data from ACS, NICMOS, STIS, WFC3, and WFPC2. Drizzling data corrects for geometric distortion effects and removes cosmic rays and other undesirable artifacts to create a clean mosaic. Note that STIS and NICMOS data are only sometimes combined via drizzling, and users should consult the data handbooks for each of the aforementioned instruments to verify appropriate data combination techniques. For more information on AstroDrizzle, which is part of the DrizzlePac package, please see http://drizzlepac.stsci.edu/.
Examples for drizzling data are provided as Jupyter notebooks in the STScI Notebooks GitHub repository (https://github.com/spacetelescope/notebooks). Jupyter notebooks are files that combine formatted text and blocks of Python code together making them useful tools for instruction. The linked GitHub repository contains both the Jupyter notebook files, which can be run on a computer with a properly configured environment, as well as pre-compiled versions rendered in HTML.
All AstroDrizzle users are encouraged to review the Initialization notebook before proceeding to other example notebooks.
4.3.4 Synthetic Photometry
Synthetic photometry uses throughput information from the HST optical telescope assembly as well as the instrument optics, filters, and detectors to estimate count rates and fluxes associated with the observation of an astrophysical source. For proposing HST observations, users should use the Exposure Time Calculator (ETC; http://etc.stsci.edu/), which uses software called PySynphot. A new, generalized version of the synthetic photometry software called synphot (with an additional plug-in for STScI missions called stsynphot) is also available. Synphot is built upon Astropy tools and uses the astropy.units package along with Astropy model templates. For more information, please see the synphot documentation at https://synphot.readthedocs.io/en/latest/.
Tarballs containing all of the throughput tables, extinction curves, and spectral atlases required for synthetic photometry and simulated HST observations are available via https://archive.stsci.edu/hlsp/reference-atlases.
Alternatively, the throughput tables for HST are also contained within CRDS. See the "synphot" expandable section on the HST CRDS website (https://hst-crds.stsci.edu/) for access to these files. To download only the throughput tables via the command line, one can use the crds.get_synphot tool. Please see the help text for this tool for the most up-to-date information regarding its use.
4.3.5 Other Useful Resources
Here, we simply list other Python tools that may be helpful to astronomers. This list is by no means comprehensive.
- astropy.stats - Contains many basic and advanced statistical functions. See http://docs.astropy.org/en/stable/stats/.
- astropy.units - Allows for turning scalar values into a quantity object, which contains both the scalar value and an attached unit. Unit conversions are handled by Astropy. See https://docs.astropy.org/en/stable/units/.
- matplotlib - Flexible plotting tool for Python. There are other plotting packages, but this one is widely-used and well-documented. See https://matplotlib.org/.
- numpy - Numerical tools for Python. This package forms the basis of many scientific computing codes in Python. See https://numpy.org/.
- pandas - Another tool for displaying and working with tabular data that has advanced, SQL-like capabilities. See https://pandas.pydata.org/.
- scipy - SciPy is a container of many tools including, e.g., numpy, pandas, and matplotlib. See https://www.scipy.org/.
Introduction to the Hubble Space Telescope Data Handbooks
- 1. Obtaining HST Data
- 2. HST File Names
- 3. HST File Formats
- 4. HST Data Analysis
- 5. Observation Logs