5.1 Data Reduction and Analysis Applications
Most of the software tools for operating on STIS FITS files are contained in the stistools package. Stistools is a package that provides Python-based data processing tools for working with STIS data. It contains calstis, the full STIS calibration pipeline, as well as its individual components (e.g., basic2d, ocrreject, wavecal, x1d, x2d). Many of these tasks are described in Chapter 3. In addition, stistools features a selection of analysis tools independent from the pipeline. The following website provides documentation including example usages for individual tasks in the stistools package: https://stistools.readthedocs.io/
Currently, all of the previously supported IRAF/PyRAF tasks have been ported to Python-based routines except for the odelaytime task to compute barycentric corrections, which is still in development. Please consult the stistools web documentation for up-to-date information concerning changes and additions to this suite of software tools. In addition, STIS now supports a repository of Jupyter notebooks (https://github.com/spacetelescope/hst_notebooks/tree/main/notebooks/STIS) to complement the Data Handbook with worked examples related to STIS data analysis. New notebooks are in active development.
5.1.1 STIS-Specific Python Tasks
In Chapter 3, we gave detailed discussions of the use of the data reduction pipeline calstis, the calstis component tasks, and auxiliary tasks that were developed to create customized reference files and to facilitate the combination of unassociated images. Most of these tasks are contained in the stistools package. Other tasks useful for reducing and analyzing STIS data are contained in this package as well. A complete listing and brief description of these tasks can be found at https://stistools.readthedocs.io/.
The function stistools.stisnoise was implemented to deal with the increase in pattern noise with the shift of STIS operations to Side-2 electronics in July 2001. The function stistools.mktrace was created to correct the orientation of spectral traces for application to a given image when it was discovered that the traces have gradually rotated over time. (The average rotation rates have been incorporated into the trace reference files for the L gratings and for the most commonly used M modes: G750M (CENWAVEs
6581, 6768, 8561). See Section 3.5.7.) The function stistools.wx2d is being offered as an alternative to the bilinear interpolation performed by stistools.x2d. It produces an image that is iteratively subsampled in the cross-dispersion direction, then rectified in that dimension and summed back into pixels. The final image can then be processed by stistools.x2d for photometric calibration.
5.1.2 Handling FITS Tables
STIS spectral extractions, TIME-TAG data, and most STIS reference files are stored in FITS files with the structure described in Section 2.3.2. The Table module in astropy.table is designed to read in data contained in FITS tables. Below, we provide several examples of using the Table module on STIS data files with table extensions. A sample output is given after each command.
To find what information is given in the columns of a FITS table (the parameters listed here are discussed in depth in Section 5.4):
>>> from astropy.table import Table >>> ex_table = Table.read('obc410010_x1d.fits') >>> print(ex_table.info) <Table masked=True length=1> name dtype shape unit format ---------- ------- ------- ---------------------- --------- SPORDER int16 {:11d} NELEM int16 {:11d} WAVELENGTH float64 (1024,) Angstroms {:25.16g} GROSS float32 (1024,) Counts/s {:15.7g} BACKGROUND float32 (1024,) Counts/s {:15.7g} NET float32 (1024,) Counts/s {:15.7g} FLUX float32 (1024,) erg / (Angstrom cm2 s) {:15.7g} ERROR float32 (1024,) erg / (Angstrom cm2 s) {:15.7g} NET_ERROR float32 (1024,) Counts/s {:15.7g} DQ int16 (1024,) {:11d} A2CENTER float32 pix {:15.7g} EXTRSIZE float32 pix {:15.7g} MAXSRCH int16 pix {:11d} BK1SIZE float32 pix {:15.7g} BK2SIZE float32 pix {:15.7g} BK1OFFST float32 pix {:15.7g} BK2OFFST float32 pix {:15.7g} EXTRLOCY float32 (1024,) pix {:15.7g} OFFSET float32 pix {:15.7g}
To look at the contents of the table:
>>> print(ex_table) SPORDER NELEM ... EXTRLOCY [1024] OFFSET ... pix pix ----------- ----------- ... ---------------------------------- --------------- 1 1024 ... 378.1119 .. 381.7816 332.1185
Note that the number of columns displayed is limited by the width of the window that you are working in when using print(). To see more columns, simply adjust the width of the window and rerun the command above. To view specific columns:
>>> print(ex_table['BK1SIZE','BK2SIZE','BK1OFFST']) BK1SIZE BK2SIZE BK1OFFST pix pix pix --------------- --------------- --------------- 5 5 -300
Reference file FITS tables generally have many rows, with each row characterizing a specific operating mode, location on the detector, value of a parameter to be used in the reduction, etc. To display specific rows in the table:
>>> from astropy.table import Table >>> ref_table = Table.read(‘q541740qo_pct.fits’) >>> columns = ['CENWAVE','APERTURE','EXTRHEIGHT','NELEM','WAVELENGTH'] >>> print(ref_table[columns] CENWAVE APERTURE EXTRHEIGHT NELEM WAVELENGTH [8] Angstrom pix Angstrom -------- ---------------- ---------- ----- ------------------------ -1 52X0.05 3 8 5812 .. 9696 -1 52X0.05 5 8 5812 .. 9696 -1 52X0.05 7 8 5812 .. 9696 -1 52X0.05 9 8 5812 .. 9696 -1 52X0.05 11 8 5812 .. 9696 -1 52X0.05 15 8 5812 .. 9696 -1 52X0.05 21 8 5812 .. 9696 -1 52X0.05 200 8 5812 .. 9696 -1 52X0.05 600 8 5812 .. 9696 -1 52X0.1 3 8 5813 .. 9697 -1 52X0.1 5 8 5813 .. 9697 -1 52X0.1 7 8 5813 .. 9697 -1 52X0.1 9 8 5813 .. 9697 -1 52X0.1 11 8 5813 .. 9697 -1 52X0.1 15 8 5813 .. 9697 -1 52X0.1 21 8 5813 .. 9697 -1 52X0.1 200 8 5813 .. 9697 -1 52X0.1 600 8 5813 .. 9697 -1 52X0.2 3 8 5807 .. 9692 -1 52X0.2 5 8 5807 .. 9692 -1 52X0.2 7 8 5807 .. 9692 -1 52X0.2 9 8 5807 .. 9692 -1 52X0.2 11 8 5807 .. 9692 -1 52X0.2 15 8 5807 .. 9692 ... ... ... ... ... -1 52X0.1F1 7 8 5813 .. 9697 -1 52X0.1F1 9 8 5813 .. 9697 -1 52X0.1F1 11 8 5813 .. 9697 -1 52X0.1F1 15 8 5813 .. 9697 -1 52X0.1F1 21 8 5813 .. 9697 -1 52X0.1F1 200 8 5813 .. 9697 -1 52X0.1F1 600 8 5813 .. 9697 -1 52X0.1F2 3 8 5813 .. 9697 -1 52X0.1F2 5 8 5813 .. 9697 -1 52X0.1F2 7 8 5813 .. 9697 -1 52X0.1F2 9 8 5813 .. 9697 -1 52X0.1F2 11 8 5813 .. 9697 -1 52X0.1F2 15 8 5813 .. 9697 -1 52X0.1F2 21 8 5813 .. 9697 -1 52X0.1F2 200 8 5813 .. 9697 -1 52X0.1F2 600 8 5813 .. 9697 -1 52X0.2F2 3 8 5807 .. 9692 -1 52X0.2F2 5 8 5807 .. 9692 -1 52X0.2F2 7 8 5807 .. 9692 -1 52X0.2F2 9 8 5807 .. 9692 -1 52X0.2F2 11 8 5807 .. 9692 -1 52X0.2F2 15 8 5807 .. 9692 -1 52X0.2F2 21 8 5807 .. 9692 -1 52X0.2F2 200 8 5807 .. 9692 -1 52X0.2F2 600 8 5807 .. 9692 Length = 198 rows
5.1.3 General Spectral Display and Analysis Tasks
The astropy package specutils provides a basic interface for loading, manipulating, and performing common forms of analysis of spectroscopic data. Documentation for specutils can be found at https://specutils.readthedocs.io. SpecViz is an interactive tool for visualization and quick-look analysis of 1-D astronomical spectra written in the Python language. Documentation for SpecViz can be found at https://jdaviz.readthedocs.io/en/latest/specviz/index.html. Note that these packages are currently in active development and may lack some functions for detailed analyses. Other older applications in PyRAF/IRAF/STSDAS can provide applications for displaying and analyzing STIS spectral data in these cases, but are no longer supported. Jupyter notebook tutorials for current and future tools can be found at https://github.com/spacetelescope/hst_notebooks/tree/main/notebooks/STIS.
5.1.4 AstroDrizzle for Image Combination
AstroDrizzle is a Python script that automates the detection of cosmic rays and the combination of dithered images. A user guide for DrizzlePac, which includes AstroDrizzle, can be found at https://spacetelescope.github.io/hst_notebooks/notebooks/STIS/drizpac_notebook/STIS_DrizzlePac_Tutorial.html. AstroDrizzle has been adapted to STIS imaging as well as ACS, WFC3, and COS imaging. It can be used to combine STIS CRSPLIT or REPEATOBS image sets as well as dithered images and images made with the same aperture and optical elements but with different target centering or orientation. It uses cosmic ray rejection algorithms which often gives superior results to calstis for CRSPLIT and REPEATOBS exposures, especially for images of unresolved targets with high signal-to-noise.