| bswitch | noao.imred.iids/noao.imred.irs | bswitch |
bswitch - generate sky-subtracted accumulated spectra
bswitch input records
Data from multiaperture spectrographs are summed according to aperture number and sky subtracted if sky observations are available. Data for up to 50 apertures may be simultaneously accumulated. The accumulated spectra are written to new images.
The exposure times for each observation may be different. All internal computations are performed in terms of count rates, and converted back to counts (for statistical analysis) prior to writing the new image. Therefore, the time on the sky and object may be different as well. When these extensions to the normal mode are required, the flag ids_mode must be set to no. Then object and sky accumulations are performed totally independently and a difference is derived at the conclusion of the operation.
If ids_mode is set to yes, then the usual IIDS/IRS "beam-switch" observing mode is assumed. This implies that an equal number of sky and object spectra are obtained through each aperture after 2N spectra have been accumulated, where N is the number of instrument apertures (2 for the IIDS/IRS). It is also assumed that the object and sky exposure times are equal for each aperture. Note that the "nebular" mode (where all instrument apertures point at an extended object simultaneously, and then all apertures point at sky simultaneously) is an acceptable form for beam-switched data in ids_mode.
The accumulations are optionally weighted by the countrate over a region of the spectrum to improve the statistics during variable conditions. The user may specify the region of spectrum by wavelength. In ids_mode, the statistics are obtained from object-sky differences; otherwise, the statistics are performed on object+sky and sky spectra separately.
The spectra may be extinction corrected if this has not already been performed. In order to perform either the extinction correction or the weighting process, the spectra must have been placed on a linear wavelength scale (or linear in the base 10 logarithm).
Strings of spectra are accumulated to produce a single summed spectrum for each observing aperture. But in some cases it is desirable to produce summed spectra from subsets of the entire string to evaluate the presence of variations either due to observing conditions or due to the physical nature of the object. A subset parameter may be set to the frequency at which spectra are to be summed.
In order that the processing occur with minimal user interaction, elements from the extended image header are used to direct the flow of operation and to obtain key observing parameters. The required parameters are: object/sky flag (OFLAG=1/0), exposure time in seconds (ITM), beam (that is, aperture) number (BEAM-NUM), airmass (AIRMASS) or alternatively hour angle (HA) and declination (DEC), or right ascension (RA), sidereal time (ST), declination (DEC), and the observatory (OBSERVAT), starting wavelength (W0), and wavelength increment per channel (WPC), where the names in parenthesis are the expected keywords in the header. If the observatory is not specified in the image the observatory parameter is used. See observatory for further details on the observatory database.
The following header flags are used as well: DC_FLAG for dispersion corrected data (must=0), BS_FLAG for beam-switching (must not be 1 which indicates the operation was already done), EX_FLAG for extinction correction (if = 0 extinction is assumed already done).
The headers may be listed with the IMHEADER task, setting the parameter "long" = yes. The values for the parameters follow the rules used for IIDS and IRS data.
After the beam-switch operation, the newly created spectra will have header elements taken from the last object spectrum. A few parameters will be updated to reflect the operation (e.g. integration time, processing flags).
The following example will accumulate a series of 16 spectra obtained in the normal beam-switched mode and create two new extincton corrected spectra having names nite1bs.1 and nite1bs.2:
cl> bswitch nite1 1011-1026 nite1bs 1
The following example performs the same functions but accumulates the data to produce 8 new spectra representing the individual object-sky pairs:
cl> bswitch nite1 1011-1026 nite1bs 1 subset=4
The following example produces an extinction corrected spectrum for every input spectrum. Note that ids_mode is set to off to generate separate object and sky sums, and subset is set to 2 so that every pair of spectra (one object and one sky) are written out as two new spectra:
cl> bswitch nite1 1011-1026 nite1bs 1 subset=2 ids_mode-
The next example produces a pair of spectra for each of 3 independent objects observed, provided that each was observed for the same number of observations (16 in this case).
cl> bswitch nite1 1011-1026,1051-1066,1081-1096 nite1bs 1 \ >>> subset=16
The next example shows how to use the weighting parameters where the indicative flux is derived from the region around the emission-line of 5007A.
cl> bswitch nite1 1011-1026 nite1bs 1 weighting- \ >>> wave1=4990, wave2=5020
The principle time expenditure goes toward extinction correcting the data. For IIDS type spectra (length=1024 pixels), approximately 30 cpu seconds are required to beam-switch a series of 16 spectra.
The number of apertures is restricted to 50 and must be labeled between 0 and 49 in the image header (the IIDS uses 0 and 1).
Until an image header editor is available, BSWITCH can be applied only to data with properly prepared headers such as IIDS/IRS data read by RIDSMTN, RIDSFILE and some data via RFITS.
When used to perform the function of extinction correction only (the third example above), the statistics file fails to note the output image name for the sky spectrum.
The data must be on a linear wavelength scale. The starting wavelength, W0, and a wavelength per channel, WPC, are required header information, and the DC_FLAG must be set to 0.
observatory, sensfunc, imheader, lcalib, ridsmtn, ridsfile, rfits