Most of the software tools for operating on COS FITS files are contained in three Python
packages that come with the AstroConda
python distribution, which is available for download from STScI:
The three Python
packages used with COS are:
In Chapter 3
, we gave detailed discussions of the use of the data reduction pipeline calcos
. This task is contained in the AstroConda
. Other modules useful for reducing and analyzing COS data are contained in a separate package called costools
. A complete listing and brief description of these modules is given in Table 5.1
. All of these tasks are run in Python
. Consult the online help
for each module for more information. Some of these modules will be discussed in greater detail in the remainder of this chapter.
COS 1-D spectra and most COS reference files are stored in FITS tables (see Section 2.4.1
for a description of the structure of the table extension files for 1-D spectra and TIME-TAG
data). Tasks designed to handle this format can be used to examine and extract information from the tables. Here we give specific examples of the use of routines in astropy.table.Table
to help you get started. A sample output is given after each command.
Use the Table
module in the astropy.table
package to find out what information is given in the columns of a FITS table.
to look at the contents of the table:
The user may wish to look at values in a COS reference file FITS
table, which generally have many rows. Each row typically characterizes a specific operating mode, location on the detector, a value of a parameter to be used in the reduction, etc.
In Python, there are often many methods to accomplish the same goal. For instance, in the above example, one could have used fits.getdata()
instead of fits.open()
(as shown in examples below). When using fits.open
(), it is important to close the fits file afterwards as shown in the last line of this example.
lists several useful Python
packages for displaying and analyzing COS spectral data.
is a powerful spectral plotting and fitting package that provides the user with many options for modeling emission and absorption features, continuum, and much more. It is controlled via a graphical user interface, and has documentation and examples available: https://specviz.readthedocs.io/
Please note that this is a new package which has not been fully tested and verified as of May 2018.
The COS FUV data consist of separate files for each of the two FUV detector segments, segment A and segment B. In general, each segment contains one target spectrum and one wavecal. On the other hand, for the NUV data there are three disjointed portions of the spectrum present on the image for both the target and the wavecal. The following examples illustrate the use of the imshow()
function in matplotlib.pyplot
module to plot COS FUV and NUV spectra from the 2-D flt
files. The parameters in plt.ylim()
refer to the Y location of the spectrum for each particular grating/segment combination. One may need to adjust the scaling factors, vmin and vmax, to suit the data range of any particular dataset. A range of different colormaps may be used, and can be found here:
The following example illustrates the use of the Python
to plot COS tabular data. See Section 5.3.1
for more details and examples.
We note that instead of using concatenate()
, one could also use the flatten()
module as shown in the example in Section 5.3.1