| do3fiber | noao.imred.kpnocoude | do3fiber |
do3fiber -- Three fiber data reduction task
do3fiber objects
The do3fiber reduction task is specialized for scattered light subtraction, extraction, flat fielding, and wavelength calibration of multifiber data in which some fibers are used to take object spectra and other fibers are used to take simultaneous arc spectra. A three fiber instrument of this type (one object and two arc fibers) is available at the KPNO coude feed. The default parameters are set for this configuration. If there are a large number of fibers and fiber throughput and sky fiber subtraction is needed the dofiber task should be used.
The do3fiber task is a command language script which collects and combines the functions and parameters of many general purpose tasks to provide a single complete data reduction path. The task provides a degree of guidance, automation, and record keeping necessary when dealing with this type of multifiber data.
-- PACKAGE PARAMETERS
Package parameters are those which generally apply to all task in the package. This is also true of do3fiber .
nearest - nearest neighbor linear - linear poly3 - 3rd order polynomial poly5 - 5th order polynomial spline3 - cubic spline sinc - sinc function
PARAMS PARAMETERS
The following parameters are part of the params parameter set and define various algorithm parameters for do3fiber .
-- GENERAL PARAMETERS --
-- DEFAULT APERTURE LIMITS --
-- AUTOMATIC APERTURE RESIZING PARAMETERS --
-- TRACE PARAMETERS --
-- SCATTERED LIGHT PARAMETERS --
-- APERTURE EXTRACTION PARAMETERS --
-- FLAT FIELD FUNCTION FITTING PARAMETERS --
-- ARC DISPERSION FUNCTION PARAMETERS --
-- AUTOMATIC ARC ASSIGNMENT PARAMETERS --
-- DISPERSION CORRECTION PARAMETERS --
The environment parameter imtype is used to determine the extension of the images to be processed and created. This allows use with any supported image extension. For STF images the extension has to be exact; for example "d1h".
The do3fiber reduction task is specialized for scattered light subtraction, extraction, flat fielding, and wavelength calibration of multifiber data in which some fibers are used to take object spectra and other fibers are used to take simultaneous arc spectra. A three fiber instrument of this type (one object and two arc fibers) is available at the KPNO coude feed. The default parameters are set for this configuration. If there are a large number of fibers and fiber throughput and sky fiber subtraction is needed the dofiber task should be used.
The do3fiber task is a command language script which collects and combines the functions and parameters of many general purpose tasks to provide a single complete data reduction path. The task provides a degree of guidance, automation, and record keeping necessary when dealing with this type of multifiber data.
The general organization of the task is to do the interactive setup steps first using representative calibration data and then perform the majority of the reductions automatically, and possibly as a background process, with reference to the setup data. In addition, the task determines which setup and processing operations have been completed in previous executions of the task and, contingent on the redo and update options, skip or repeat some or all the steps.
The description is divided into a quick usage outline followed by details of the parameters and algorithms. The usage outline is provided as a checklist and a refresher for those familiar with this task and the component tasks. It presents only the default or recommended usage. Since do3fiber combines many separate, general purpose tasks the description given here refers to these tasks and leaves some of the details to their help documentation.
Usage Outline
There are two queries for the interactive fitting. A graph of the data between the defined reference apertures separated by a specified buffer distance is first shown. The function order and type may be adjusted. After quiting with q the user has the option of changing the buffer value and returning to the fitting, changing the image line or column to check if the fit parameters are satisfactory at other points, or to quit and accept the fit parameters. After fitting all points across the dispersion another graph showing the scattered light from the individual fits is shown and the smoothing parameters along the dispersion may be adjusted. Upon quiting with q you have the option of checking other cuts parallel to the dispersion or quiting and finishing the scattered light function smoothing and subtraction.
If there is a throughput image then this is corrected for scattered light noninteractively using the previous fitting parameters.
The final spectra will have the same name as the original 2D images with a ".ms" extension added.
Spectra and Data Files
The basic input consists of multifiber object and calibration spectra stored as IRAF images. The type of image format is defined by the environment parameter imtype . Only images with that extension will be processed and created. There are two types of calibration images. These are flat fields and comparison lamp arc spectra. The raw CCD images must be processed to remove overscan, bias, and dark count effects. This is generally done using the ccdred package. The do3fiber task will abort if the image header keyword CCDPROC, which is added by ccdproc , is missing. If the data processed outside of the IRAF ccdred package then a dummy CCDPROC keyword should be added to the image headers; say with hedit . Flat fielding is generally not done at this stage but as part of do3fiber . If for some reason the flat field or calibration arc spectra have separate exposures through different fibers they may be simply added.
The assignment of arc calibration exposures to object exposures is generally done by selecting the nearest in time and interpolating. However, the optional arc assignment table may be used to explicitly assign arc images to specific objects. The format of this file is described in the task refspectra .
The final reduced spectra are recorded in one, two or three dimensional IRAF images. The images have the same name as the original images with an added ".ms" extension. Each line in the reduced image is a one dimensional spectrum with associated aperture, wavelength, and identification information. With a single object spectrum the image will be one dimensional and with multiple object spectra the image will be two dimensional. When the extras parameter is set the images will be three dimensional (regardless of the number of apertures) and the lines in the third dimension contain additional information (see apsum for further details). These spectral formats are accepted by the one dimensional spectroscopy tasks such as the plotting tasks splot and specplot .
Package Parameters
The kpnocoude package parameters set parameters affecting all the tasks in the package. Some of the parameters are not applicable to the do3fiber task. The observatory parameter is only required for data without an OBSERVAT header parameter (currently included in NOAO data). The spectrum interpolation type might be changed to "sinc" but with the cautions given in onedspec.package . The dispersion axis parameter is only needed if a DISPAXIS image header parameter is not defined. The other parameters define the standard I/O functions. The verbose parameter selects whether to print everything which goes into the log file on the terminal. It is useful for monitoring what the do3fiber task does. The log and plot files are useful for keeping a record of the processing. A log file is highly recommended. A plot file provides a record of apertures, traces, and extracted spectra but can become quite large. The plotfile is most conveniently viewed and printed with gkimosaic .
Processing Parameters
The input images are specified by image lists. The lists may be a list of explicit, comma separate image names, @ files, or image templates using pattern matching against file names in the directory. The aperture reference spectrum is used to find the spectrum profiles and trace them. Thus, this requires an image with good signal in all fibers which usually means a flat field spectrum. It is recommended that flat field correction be done using one dimensional extracted spectra rather than as two dimensional images. This is done if a flat field spectrum is specified. The arc assignment table is used to specifically assign arc spectra to particular object spectra and the format of the file is described in refspectra .
The detector read out noise and gain are used for cleaning and variance (optimal) extraction. The dispersion axis defines the wavelength direction of spectra in the image if not defined in the image header by the keyword DISPAXIS. The width parameter (in pixels) is used for the profile finding and centering algorithm (center1d ).
The number of fibers is fairly obvious. It is the number of fibers, including the arc fibers, to be automatically found and assigned apertures. The apertures are assigned aperture numbers sequentially. The object and arc fibers are identified by these aperture numbers as specified by the objaps and arcaps parameters. The defaults are for the case of three fibers in the sequence arc fiber, object fiber, and arc fiber.
The approximate central wavelength and dispersion are used for the automatic identification of the arc reference. They may be specified as image header keywords or values. The INDEF values search the entire range of the coordinate reference file but the automatic line identification algorithm works much better and faster if approximate values are given.
The next set of parameters select the processing steps and options. The scattered light option allows fitting and subtracting a scattered light surface from the input object and flat field. If there is significant scattered light which is not subtracted the fiber throughput correction will not be accurate. The flat fitting option allows fitting and removing the overall shape of the flat field spectra while preserving the pixel-to-pixel response corrections. This is useful for maintaining the approximate object count levels and not introducing the reciprocal of the flat field spectrum into the object spectra.
The apertures defined for the aperture reference image are assigned to each image. For the object images the apertures may be shifted across the dispersion by recentering the strongest profiles and averaging the individual shifts to form a single shift for all apertures. This corrects for shifts in the detector during the observations. The recenter parameter selects whether to apply this shift or not.
The edit option allows you to be queried to review the apertures assigned to each object image. If selected and the query answered affirmatively the apertures may be interactively shifted and resized. The query may also be answered with "NO" to turn off this option during processing. Note that the initial aperture definitions for the aperture reference image always allows editing.
The clean option invokes a profile fitting and deviant point rejection algorithm as well as a variance weighting of points in the aperture. These options require knowing the effective (i.e. accounting for any image combining) read out noise and gain. For a discussion of cleaning and variance weighted extraction see apvariance and approfiles .
The dispersion correction option selects whether to extract arc spectra, determine dispersion functions, assign them to the object spectra, and, possibly, resample the spectra to a linear (or log-linear) wavelength scale.
The splot option allows a query (which may be answered with "YES" or "NO" to eliminate the query) and then plotting of the final object spectra if answered affirmatively. The plotting is done with the task splot .
Generally once a spectrum has been processed it will not be reprocessed if specified as an input spectrum. However, changes to the underlying calibration data can cause such spectra to be reprocessed if the update flag is set. The changes which will cause an update are a new reference image, new flat field, and a new arc reference image. If all input spectra are to be processed regardless of previous processing the redo flag may be used. Note that reprocessing clobbers the previously processed output spectra.
The batch processing option allows object spectra to be processed as a background or batch job. This will only occur if the aperture editing and final spectrum plotting have been turned off, either with the task option parameter or by answering "NO" to the queries. The listonly option prints a summary of the processing steps which will be performed on the input spectra without actually doing anything. This is useful for verifying which spectra will be affected if the input list contains previously processed spectra. The listing does not include any arc spectra which may be extracted to dispersion calibrate an object spectrum.
The last parameter (excluding the task mode parameter) points to another parameter set for the algorithm parameters. The way do3fiber works this may not have any value and the parameter set params is always used. The algorithm parameters are discussed further in the next section.
Algorithms and Algorithm Parameters
This section summarizes the various algorithms used by the do3fiber task and the parameters which control and modify the algorithms. The algorithm parameters available to the user are collected in the parameter set params . These parameters are taken from the various general purpose tasks used by the do3fiber processing task. Additional information about these parameters and algorithms may be found in the help for the actual task executed. These tasks are identified in the parameter section listing in parenthesis. The aim of this parameter set organization is to collect all the algorithm parameters in one place separate from the processing parameters and include only those which are relevant for this type of data. The parameter values can be changed from the defaults by using the parameter editor,
cl> epar paramsor simple typing params . The parameter editor can also be entered when editing the do3fiber parameters by typing :e params or simply :e if positioned at the params parameter.
Aperture Definitions
The first operation is to define the extraction apertures, which include the aperture width and position dependence with wavelength, for the object and arc fibers. This is done on a reference spectrum which is usually a flat field taken through both fibers. Other spectra will inherit the reference apertures and may apply a correction for any shift of the orders across the dispersion. The reference apertures are defined only once unless the redo option is set.
The selected number of fibers are found automatically by selecting the highest peaks in a cut across the dispersion. Apertures are assigned with a limits set by the lower and upper parameter and numbered sequentially. A query is then given allowing the apertures to be reviewed interactively. If answered affirmatively a cut across the orders is shown with the apertures marked and an interactive aperture editing mode is entered (see apedit ). The main thing to be concerned about is that the aperture numbers agree with the objaps and arcaps definitions. The aperture numbers may be changed with the i or o keys. The apertures may also be resized from the default limits. To exit the background and aperture editing steps type q.
Next the positions of the fiber profiles at various points along the dispersion are measured and a "trace function" is fit. The user is asked whether to fit the trace function interactively. This is selected to adjust the fitting parameters such as function type and order. When interactively fitting a query is given for each aperture. After the first aperture one may skip reviewing the other traces by responding with "NO". Queries made by do3fiber generally may be answered with either lower case "yes" or "no" or with upper case "YES" or "NO". The upper case responses apply to all further queries and so are used to eliminate further queries of that kind.
The above steps are all performed using tasks from the apextract package and parameters from the params parameters. As a quick summary, the dispersion direction of the spectra are determined from the package dispaxis parameter if not defined in the image header. The default line or column for finding the orders and the number of image lines or columns to sum are set by the line and nsum parameters. A line of INDEF (the default) selects the middle of the image. The automatic finding algorithm is described for the task apfind and basically finds the strongest peaks. The tracing is done as described in aptrace and consists of stepping along the image using the specified t_step parameter. The function fitting uses the icfit commands with the other parameters from the tracing section.
Extraction
The actual extraction of the spectra is done by summing across the fixed width apertures at each point along the dispersion. The default is to simply sum the pixels using partial pixels at the ends. There is an option to weight the sum based on a Poisson noise model using the readnoise and gain detector parameters. Note that if the clean option is selected the variance weighted extraction is used regardless of the weights parameter. The sigma thresholds for cleaning are also set in the params parameters.
The cleaning and variance weighting options require knowing the effective (i.e. accounting for any image combining) read out noise and gain. These numbers need to be adjusted if the image has been processed such that the intensity scale has a different origin (such as a background light subtraction) or scaling (such as caused by unnormalized flat fielding). For optimal extraction and cleaning to work it is recommended that a datamax value be determined for the data and the fitflat option be used. For further discussion of cleaning and variance weighted extraction see apvariance and approfiles as well as apsum .
Scattered Light Subtraction
Scattered light may be subtracted from the input two dimensional image as the first step. This is done using the algorithm described in apscatter . This can be important if there is significant scattered light since the flat field/throughput correction will otherwise be incorrect. The algorithm consists of fitting a function to the data outside the defined apertures by a specified buffer at each line or column across the dispersion. The function fitting parameters are the same at each line. Because the fitted functions are independent at each line or column a second set of one dimensional functions are fit parallel to the dispersion using the evaluated fit values from the cross-dispersion step. This produces a smooth scattered light surface which is finally subtracted from the input image. Again the function fitting parameters are the same at each line or column though they may be different than the parameters used to fit across the dispersion.
The first time the task is run with a particular flat field (or aperture reference image if no flat field is used) the scattered light fitting parameters are set interactively using that image. The interactive step selects a particular line or column upon which the fitting is done interactively with the icfit commands. A query is first issued which allows skipping this interactive stage. Note that the interactive fitting is only for defining the fitting functions and orders. When the graphical icfit fitting is exited (with q) there is a second prompt allowing you to change the buffer distance (in the first cross-dispersion stage) from the apertures, change the line/column, or finally quit.
The initial fitting parameters and the final set parameters are recorded in the apscat1 and apscat2 hidden parameter sets. These parameters are then used automatically for every subsequent image which is scattered light corrected.
The scattered light subtraction modifies the input 2D images. To preserve the original data a copy of the original image is made with the same root name and the word "noscat" appended. The scattered light subtracted images will have the header keyword "APSCATTE" which is how the task avoids repeating the scattered light subtraction during any reprocessing. However if the redo option is selected the scattered light subtraction will also be redone by first restoring the "noscat" images to the original input names.
Flat Field Correction
Flat field corrections may be made during the basic CCD processing; i.e. direct division by the two dimensional flat field observation. In that case do not specify a flat field spectrum; use the null string "". The do3fiber task provides an alternative flat field response correction based on division of the extracted object spectra by the extracted flat field spectra. A discussion of the theory and merits of flat fielding directly verses using the extracted spectra will not be made here. The do3fiber flat fielding algorithm is the recommended method for flat fielding since it works well and is not subject to the many problems involved in two dimensional flat fielding.
The first step is extraction of the flat field spectrum, if specified, using the reference apertures. Only one flat field is allowed so if multiple flat fields are required the data must be reduced in groups. If the fitflat option is selected (the default) the extracted flat field spectra are averaged together and a smooth function is fit. The default fitting function and order are given by the parameters f_function and f_order . If the parameter f_interactive is "yes" then the fitting is done interactively using the fit1d task which uses the icfit interactive fitting commands.
The fitted function is divided into the individual flat field spectra to remove the basic shape of the spectrum while maintaining the relative individual pixel responses and any fiber to fiber differences. This step avoids introducing the flat field spectrum shape into the object spectra and closely preserves the object counts.
The final step is to normalize the flat field spectra by the mean counts over all the fibers. This normalization step is simply to preserve the average counts of the extracted object and arc spectra after division by the response spectra.
Dispersion Correction
If dispersion correction is not selected, dispcor =no, then the object spectra are simply extracted. If it is selected the arc spectra are used to dispersion calibrate the object spectra. There are four steps involved; determining the dispersion functions relating pixel position to wavelength, assigning the appropriate dispersion functions to a particular observation, determining a zero point wavelength shift from the arc fibers to be applied to the object fiber dispersion functions, and either storing the nonlinear dispersion function in the image headers or resampling the spectra to evenly spaced pixels in wavelength.
The first arc spectrum in the arc list is used to define the reference dispersion solution. It is extracted using the reference aperture definitions. The interactive task autoidentify is used to automatically define the dispersion function in one fiber. Whether or not it is successful the user is presented with the interactive identification graph. The automatic identifications can be reviewed and a new solution or corrections to the automatic solution may be performed. The dispersion functions for the other fibers are then determined automatically by reference to the first fiber using the task reidentify . Except in batch mode a query is given allowing the reidentified arc spectra to be examined interactively with identify . This would normally be done only if the information about the reidentification printed on the terminal indicates a problem such as a large increase in the RMS. This query may be eliminated in the usual way.
The set of arc dispersion function parameters are from autoidentify and reidentify . The parameters define a line list for use in automatically assigning wavelengths to arc lines, a parameter controlling the width of the centering window (which should match the base line widths), the dispersion function type and order, parameters to exclude bad lines from function fits, and parameters defining whether to refit the dispersion function, as opposed to simply determining a zero point shift, and the addition of new lines from the line list when reidentifying additional arc spectra. The defaults should generally be adequate and the dispersion function fitting parameters may be altered interactively. One should consult the help for the two tasks for additional details of these parameters and the operation of autoidentify .
If resampling of the spectra is selected by the parameter linearize all the arc dispersion functions are combined to provide a default starting and ending wavelength and dispersion with the same number of pixels is determined and the user is queried for any changes. This linear dispersion system will be applied to all spectra so that all the final processed object spectra will have the same dispersion sampling.
Once the reference dispersion functions are defined other arc spectra are extracted as they are assign to the object spectra. The assignment of arcs is done either explicitly with an arc assignment table (parameter arctable ) or based on a header parameter such as a time. The assignments are made by the task refspectra . When two arcs are assigned to an object spectrum an interpolation is done between the two dispersion functions. This makes an approximate correction for steady drifts in the dispersion. Because the arc fibers monitor any zero point shifts in the dispersion functions, due to translation and rotation of the detector, it is probably only necessary to have one or two arc spectra, one at the beginning and/or one at the end of the night.
The tasks setjd and setairmass are automatically run on all spectra. This computes and adds the header parameters for the Julian date (JD), the local Julian day number (LJD), the universal time (UTMIDDLE), and the air mass at the middle of the exposure. The default arc assignment is to use the Julian date grouped by the local Julian day number. The grouping allows multiple nights of data to be correctly assigned at the same time.
When the object spectra are extracted so are the simultaneous arc spectra. A zero point shift of the arc spectra relative to the dispersion solutions of an assigned full arc observation is computed using reidentify . The zero point shifts from the arc fibers are then interpolated across the detector based on the positions of the arc apertures to the positions of the object apertures. A linear interpolation is used which accounts for a rotation of the detector as well as a translation along the dispersion. The interpolated zero point wavelength shifts are then added to the dispersion functions from the full arc observation for the object fibers. Note that this does not assume that the object and arc fiber dispersion functions are the same or have the same wavelength origin, but only that the interpolated shifts in wavelength zero point apply to all fibers. When there are two assigned full arc spectra the above steps are done independently and the final pair of zero point corrected dispersion functions for each object fiber are combined using the assigned weights. Once the dispersion function correction is determined from the extracted arc fiber spectra they are deleted leaving only the object spectra.
The last step of dispersion correction is setting the dispersion of the object spectra. There are two choices here. If the linearize parameter is not set the nonlinear dispersion functions are stored in the image header. Other IRAF tasks interpret this information when dispersion coordinates are needed for plotting or analysis. This has the advantage of not requiring the spectra to be interpolated and the disadvantage that the dispersion information is only understood by IRAF tasks and cannot be readily exported to other analysis software.
If the linearize parameter is set then the spectra are resampled to a linear dispersion relation either in wavelength or the log of the wavelength. The linear dispersion parameters are those defined previously for the arc reference image.
The linearization algorithm parameters allow selecting the interpolation function type, whether to conserve flux per pixel by integrating across the extent of the final pixel, and whether to linearize to equal linear or logarithmic intervals. The latter may be appropriate for radial velocity studies. The default is to use a fifth order polynomial for interpolation, to conserve flux, and to not use logarithmic wavelength bins. These parameters are described fully in the help for the task dispcor which performs the correction.
1. The following example uses artificial data and may be executed at the terminal (with IRAF V2.10). This is also the sequence performed by the test procedure "demos do3fiber".
kp> demos mkdo3fiber
Creating image demoobj ...
Creating image demoflat ...
Creating image demoarc ...
kp> do3fiber demoobj apref=demoflat flat=demoflat arcs=demoarc \
>>> width=4 edit=yes
Set reference apertures for demoflat
Resize apertures for demoflat? (yes):
Edit apertures for demoflat? (yes):
<Exit with 'q'>
Fit traced positions for demoflat interactively? (yes):
Fit curve to aperture 1 of demoflat interactively (yes):
<Exit with 'q'>
Fit curve to aperture 2 of demoflat interactively (yes): N
Create response function demoflatnorm.ms
Extract flat field demoflat
Fit and ratio flat field demoflat
Create the normalized response demoflatnorm.ms
demoflatnorm.ms -> demoflatnorm.ms using bzero: 0. and bscale: 1.
mean: 1. median: 1.034214 mode: 0.8378798
upper: INDEF lower: INDEF
Average aperture response:
1. 0.8394014
2. 1.034403
3. 1.126194
Extract arc reference image demoarc
Determine dispersion solution for demoarc
<Reset default line list with ":coord linelists$idhenear.dat">
<A dispersion solution is found automatically.>
<Examine the fit with 'f'>
<Exit fit with 'q' and exit task with 'q'>
REIDENTIFY: NOAO/IRAF V2.10BETA valdes@puppis Fri 11:04:32 06-Mar-92
Reference image = demoarc.ms, New image = demoarc.ms, Refit = yes
Image Data Found Fit Pix Shift User Shift Z Shift RMS
d...ms - Ap 1 30/30 29/30 -0.00675 -0.04 -6.9E-6 0.252
Fit dispersion function interactively? (no|yes|NO|YES) (yes): n
d...ms - Ap 3 30/30 29/30 -0.0154 -0.0928 -1.4E-5 0.303
Fit dispersion function interactively? (no|yes|NO|YES) (no): y
<Exit with 'q'>
d...ms - Ap 3 30/30 29/30 -0.0154 -0.0928 -1.4E-5 0.303
Dispersion correct demoarc
d...ms: w1 = 5785.86, w2 = 7351.59, dw = 6.14, nw = 256
Change wavelength coordinate assignments? (yes|no|NO): N
Extract object spectrum demoobj
Edit apertures for demoobj? (yes): n
Assign arc spectra for demoobj
[demoobj] refspec1='demoarc'
Reidentify arc fibers in demoobj with respect to demoarc
REIDENTIFY: NOAO/IRAF V2.10BETA valdes@puppis Fri 11:04:52 06-Mar-92
Reference image = demoarc.ms, New image = demoobjarc.ms, Refit = no
Image Data Found Fit Pix Shift User Shift Z Shift RMS
d...ms - Ap 1 27/30 27/27 0.00502 0.0263 3.99E-6 0.175
d...ms - Ap 3 27/30 27/27 8.62E-4 0.006 5.07E-7 0.248
Dispersion correct demoobj
demoobj.ms.imh: REFSHFT1 = 'demoobjarc.ms interp', shift = -0.0050,
rms = 0.00282813 intercept = -0.0118401, slope = 2.70764E-4
d...ms: ap = 2, w1 = 5785.86, w2 = 7351.59, dw = 6.14, nw = 256
demoobj.ms.imh:
Splot spectrum? (no|yes|NO|YES) (yes):
<Exit with 'q'>
apedit, apfind, approfiles, aprecenter, apresize, apsum, aptrace, apvariance, ccdred, center1d, dispcor, fit1d, icfit, identify, observatory, onedspec.package, refspectra, reidentify, setairmass, setjd