STIS Instrument Science Report 97-08 The Spectrum Splicer Task Steve Hulbert June 1997 ABSTRACT This report discusses the requirements for modification to existing tasks and creation of new tasks in STSDAS to facilitate the splicing of multiple spectra into a single spectrum. 1. Introduction The splicing or joining of spectra to produce a single spectrum can be operationally defined by a small number of discrete reduction steps. The process begins with an implicit requirement–we have a collection of spectra with calibrated wavelengths that overlap in wavelength space that we wish to splice. The assignment of wavelengths is not within the responsibilities of the splicer task. This does not mean that existing wavelengths cannot be improved. The improvement, however, is restricted to identifying and removing zero-point shifts between spectra overlapping in wavelength space. Removing small zero-point wavelength shifts from adjacent spectra represents the first step in the splicer task. This processing is simply a matter of doing a cross-correlation in pixel space to identify the relative offsets. This step requires that the dispersions for the two spectra are close enough as to be identical–otherwise the resolution will be degraded in the overlap regions as we mix pixels of differing wavelengths. Care must be taken to account for variation in the flux levels of overlapping spectra. While we would expect that properly calibrated spectra would not should significant discrepancies in flux levels, experience has shown that this is not always the case. These scaling effects can be removed prior to combining by simple image arithmetic. Alternately, the scaling can be handled during the splicing process with the input of the desired additive and multiplicative constants. 1 To begin the splicing process we must select the reference wavelength scale onto which the final spectrum will be placed. Ideally the type of scale would be unrestricted but in practice is usually limited to an input spectrum (in the case of nonlinear scales) or to a linearized scale as specified by a starting wavelength and dispersion. The splicing begins by interpolating the individual spectra onto the output wavelength grid. In the case of more than one input pixel contributing to an output pixel the splice task must perform some combining process. Control over this process is critical to the splicing. Once combined, the final spectrum is saved to disk. It is necessary to be able to produce a plot of the spliced spectrum. The plot should allow the overplotting of the input and output spectra. The resultant plots should be suitable for publication. Figure 1 on page 6 summarizes the process of splicing spectra in the form of a flow chart. 2. Wish List Below we list (highly) desirable features of the spectrum splicing task(s). These items are driven in large part by the nature of spectra taken with the spectrographs on HST. 1. Support for various input spectrum formats: input spectra as GEIS, FITS, IRAF, and IRAF multispec images; and, input spectra as ASCII, FITS ASCII, FITS binary (2-D and 3-D), and SDAS binary (2-D and 3-D) tables. 2. Support for various output spectrum formats: output spectra resampled to a polynomial wavelength fit (which may be the same as one of the input spectra) with the necessary WCS keywords populated in the case of GEIS or IRAF multispec formats; output spectra in GEIS format, i.e. wavelengths contained in a separate image from the flux info; output spectra with wavelength values identical to the input values except in the overlapping region where the wavelengths have been put on an arbitrary (but selectable) scale; and, output spectra written to tables (2-D ASCII, 2-D Binary, 3-D binary). 3. Ability to produce “pretty pictures” of spliced spectra, including “histogram” style plots. 4. Ability to boxcar smooth input spectra. 5. Ability to interactively determine wavelength offsets (zero-point shifts). 6. Ability to perform interactively spectrum arithmetic to normalize individual spectra to common scale. 7. Ability to restrict the rebinning (resampling) of flux values to overlap regions only. 8. No restriction on flux units. 2 9. Ability to process a large number of input spectra (~50). 10. Resampling options, including linear, polynomial, and sinc function interpolation. 11. Ability to produce output with the necessary header information to properly displayed by the splot task. 12. Ability to update header WCS keywords or to carry out the necessary arithmetic on the wavelengths to correct zero-point shifts. 3. Analysis of Current Capabilities A review of the current set of IRAF/STSDAS tasks that can be used in the process of splicing spectra is summarized in Table 1 on page 7. The important point to note is that the basic features of the splicing process are covered by the existing tasks. Unfortunately, each task has been written to support some but not all of the spectrum data formats. Table 2 on page 8 lists the data formats that must be supported by the splicing process. In order for all types of spectrum formats to be processed, there must be translation tasks to convert among the various formats. Table 3 on page 9 lists the current set of translation tasks. To demonstrate the current capabilities, consider how you would perform the following three tasks. How to splice FOS spectra with existing tasks (wavelength space) • Use poffsets to determine zero point shifts between overlapping spectra. • Update the WCS keywords using hedit to correct for the zero-point shifts. • Use mkmultispec to create multispec format data—this task interpolates the wavelengths onto a polynomial scale but does not modify the flux values. • Use splot to compare spectra and to determine if scaling of the flux is needed. • Use scombine to splice the spectra. If scaling is required use the scaling parameters in scombine. Configure scombine to use the wavelength scale of the first input spectrum as the output wavelength scale. Use the appropriate parameters to control how the overlapping parts of the spectra are combined. • Use igi to make a pretty picture. The output of scombine is a multispec format spectrum. The igi task is able to read the WCS information from the header. If desired, write the igi script to overplot the input spectra. How to combine GHRS spectra of same object taken at different epochs (pixel space) • Use poffsets to determine zero point shifts between overlapping spectra. • Use specalign to combine the spectra. A polynomial fit to the wavelengths will used to describe the output dispersion solution. This is no control over how overlapping regions are combined–a simple average is taken. 3 • Use igi to make a pretty picture. The output of specalign is a multispec format spectrum. The igi task will be able to read the WCS information from the header. If desired, write the igi script to overplot the input spectra. How to combine all echelle orders from a STIS MAMA observation (pixel space) • Use taextract to convert 3-D table data to 2-D table data. • Use tabim to convert 2-D table data to image data. • Use poffsets to determine zero point shifts between overlapping spectra. • Use imcalc to apply zero-point offsets to the wavelength images. • Use specalign to combine the spectra. A polynomial fit to the wavelengths will used to describe the output dispersion solution. This is no control over how overlapping regions are combined–a simple average is taken. • Use igi to make a pretty picture. The output of specalign is a multispec format spectrum. The igi task will be able to read the WCS information from the header. If desired, write the igi script to overplot the input spectra. Deficiencies of existing tasks The current tasks have, in addition to being limited to a subset of the desired spectrum formats, a number of deficiencies. • scombine does not let you specify a nonlinear wavelength scale as output. You can use the nonlinear scale of the first input spectrum, but if you are using tabulated wavelengths (as opposed to a polynomial fit to the wavelengths) then the wavelength range is limited and the output will be truncated to fit the input wavelengths regions. (I supposed you could created a zero-filled dummy spectrum with a collection of wavelengths that was whatever you wanted. I imagine you could even determine the overlap region up front and then cut and past to build up a complete wavelength grid–as nonlinear as you might want. I think this sounds doable, although it also sounds like a bit of work. • There is no simple, interactive task to determine the scaling parameters needed in the splicing process. Since the splot task does not preserve the various spectra in memory, you are forced to keep reading the same pair of spectra in the course of the comparison. For example: you read in a spectrum; you divide by a second; if you are unhappy with the comparison your read in a spectrum; you divide by a second; if you are unhappy... • The current translation tasks are not packaged in a way to make their use straightforward. For example, I just can’t convert a 3-D FITS table spectrum to a GEIS spectrum. Instead, I have to reconstruct the spectrum in the new format which requires that I know the details of each of these formats. I think we should be able to hide many of the details from the average user. In other words, I can’t just say “Convert this to GEIS format”, I have to say “Create a .c1h image, create a .c0h image, create ...”. 4 4. Recommendations Below are my recommendations for improvements and additions to the existing tasks that can be used to splice spectra. Notice that I don’t recommend adopting the approach of creating the ultimate “black-box” for spectrum splicing. Instead I urge use of the approach that has been extensively discussed among the STIS/NICMOS/STSDAS groups–namely, to provide translation tasks that permit access to existing tasks. Phase I 1. Create easy-to-use translation tools to permit use of existing tasks on data of any format. The tasks should convert formats and not bother the user with the details of how the formats are stored on disk. We need the ability to convert among all of the data formats listed in the wish list: GEIS, FITS, IRAF, and IRAF multispec images; and, ASCII, FITS ASCII, FITS binary (2-D and 3-D), and SDAS binary (2-D and 3-D) tables. 2. Create easy-to-use cl scripts to group routine processing steps. For example, link poffsets and hedit to permit the updating of header WCS information with wavelength zero-point shifts. 3. Create igi scripts for pretty pictures. This script (or scripts) should support overplotting of spectra, plotting of multiple spectra in multiple boxes on one page, and the style of the plot (i.e., provisions for histogram style plots). Written as a cl script, this task could be easily customized by users. Think of this as paper products for spliced spectra. Phase II 1. Add functionality to scombine to permit a wider variety of output wavelength scales, specifically for nonlinear scales. Permit the output scale to be a merged scale generated from all input scales. Permit the output to be specified as a separate input parameter instead of as one of the spectra to be spliced. I realize this task is an IRAF/NOAO task–we would have to submit this request to IRAF. 2. Modify poffsets to display, in interactive mode, the two spectra being cross-correlated as well as the cross-correlation values. Specifically, I would like see the two spectra shifted by the calculated amount and then overplotted. 3. Modify specalign to permit more control over how overlapping pixels are combined. Phase III 1. Modify splot to maintain more than one spectrum in the buffer and to permit spectrum arithmetic on individual spectra. Again, I realize this task is an IRAF/ NOAO task and that we would have to submit this request to IRAF. 5 Figure 1: Flow chart of the spectrum splicing process Spectra Update Wavelength Scales? YES Determine Zero-Point Shifts NO Combine into a Single Spectrum? YES YES NO Resample? Resample NO YES Scale? Scale NO Combine Spectrum Plot Plot YES Plot? NO 6 7 Plot Combine spectra Scale flux values imstat Pixel igi scombine Wavelength Wavelength specalign Pixel splot tcalc Pixel Pixel imcalc trebin Wavelength Pixel resample Wavelength crosscorr Pixel Resample to a linear wavelength scale poffsets Pixel Zero-point wavelength shift Existing Task Parameter Space Processing Step Table 1. Existing capabilities in IRAF/STSDAS for splicing spectra GEIS/ OIF/ 2-D tables/ 3-D tables multispec GEIS OIF/ multispec OIF/ multispec 2-D tables GEIS/ OIF/ multispec 2-D tables GEIS OIF GEIS Required Format for Existing Task yes no yes yes yes no yes yes no no yes yes Interactive Mode Desirable? no no yes no no no no no no yes Existing Task Interactive? 8 table column table column table cell FITS ASCII 2-D tables FITS binary 2-D tables FITS binary 3-D tables table column ASCII 2-D tables table cell image GEIS SDAS binary 3-D tables image multispec table column image OIF SDAS binary 2-D tables Flux stored as Format name Table 2. Spectrum formats to support table cell table column table column table cell table column table column image WCS keywords WCS keywords Wavelengths stored as yes yes yes yes yes yes yes yes no Supports nonlinear wavelength scales Since each pixel has an assigned wavelength nonlinear wavelength scales are supported. Since each pixel has an assigned wavelength nonlinear wavelength scales are supported. Since each pixel has an assigned wavelength nonlinear wavelength scales are supported. Since each pixel has an assigned wavelength nonlinear wavelength scales are supported. Since each pixel has an assigned wavelength nonlinear wavelength scales are supported. Since each pixel has an assigned wavelength nonlinear wavelength scales are supported. Multigroup format. Flux, wavelength information is stored in separated files. Since each pixels has an assigned wavelength, nonlinear wavelength scales are supported. Special case in OIF. Supports nonlinear wavelength scales as either coefficients to polynomial fit to wavelengths or as table of wavelengths–one per pixel. Designed to store multiple spectra in a single image. IRAF image format. Supports linear wavelength scales using WCS keywords. Description Table 3. Existing data format translation capabilities in IRAF/STSDAS Existing Translator Task From To mkmultispec GEIS multispec image taextract 3-D table cell 2-D binary able column tainsert 2-D ASCII/binary table column 3-D table cell tabim 2-D ASCII/binary table column OIF image imtab OIF image 2-D table column listpix all images ASCII table 9