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/

As of early 2019, the transition from older IRAF/PyRAF routines to Python-based routines is still in progress, and there remains a few tools from the IRAF/PyRAF version of the package that are still in development in the Python package. In this transitional period, users are encouraged to use IRAF/PyRAF for the tools/tasks currently unavailable in Python., e.g., tasks for removing IR fringes (see Section 3.5.5). In the meantime, we plan to keep the stistools web documentation up to date, so users are aware of any update to its components.

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 tables (see Section 2.3.2 for a description of the structure of the table extension files for spectral extractions and TIME-TAG data). The Table module in astropy.tableis designed to read in data contained in FITS tables. Below, we provide several examples of using the Table module with STIS data files. A sample output is given after each command.
Find out 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, you can simply adjust the width of the window and rerun the command above. If you want 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 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://specviz.readthedocs.io. Note that these packages are currently in active development and may lack some functions for detailed analyses. For these cases, users can utilize the older PyRAF/IRAF/STSDAS applications for displaying and analyzing STIS spectral data. such as those listed in Table 5.1.

Table 5.1: Spectral Analysis Tasks

Task

Input Formats

Purpose

stsdas.hst_calib.stis.echplot

3-D tables

Plots multiple STIS echelle spectral orders.

stsdas.analysis.fitting.nfit1d

2-D & 3-D tables, images

General 1-D feature fitting; part of the STSDAS fitting package.

stsdas.graphics.stplot.igi

2-D & 3-D tables, images

General presentation graphics; supports world coordinates.

stsdas.graphics.stplot.sgraph

2-D & 3-D tables, images

General 1-D plotting; supports world coordinates.

stsdas.contrib.spfit.specfit

1-D images,
ASCII tables

General 1-D spectrum modelling package.

noao.onedspec.splot

multispec images

General 1-D spectral analysis.


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 http://www.stsci.edu/scientific-community/software/drizzlepac.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.