| apflatten | noao.twodspec.apextract | apflatten |
apflatten -- Create flat fields for fiber or narrow aperture spectra
apflatten input output
The following parameters control the profile and spectrum fitting.
The following parameters are used to fit the normalization spectrum using the ICFIT routine.
I/O parameters and the default dispersion axis are taken from the package parameters, the default aperture parameters from apdefault , automatic aperture finding parameters from apfind , recentering parameters from aprecenter , resizing parameters from apresize , parameters used for centering and editing the apertures from apedit , and tracing parameters from aptrace .
It is sometimes the case that it is undesirable to simply divide two dimensional format spectra taken through fibers, aperture masks with small apertures such as holes and slitlets, or small slits in echelle formats by a flat field observation of a lamp. This is due to the sharp dropoff of the flat field and object profiles and absence of signal outside of the profile. Slight shifts or changes in profile shape introduce bad edge effects, unsightly "grass" is produced where there is no signal (which may also confuse extraction programs), and the division will also remove the characteristic profile of the object which might be needed for tracking the statistical significance, variance weighted extraction, and more. A straight flat field division also has the problem of changing the shape of the spectrum in wavelength, again compromising the poisson statistics and artificially boosting low signal regions.
There are three approaches to consider. First, the flat field correction can be done after extraction to one dimension. This is valid provided the flat field and object profiles don't shift much. However, for extractions that depend on a smooth profile, such as the variance weighting algorithms of this package, the sensitivity corrections must remain small; i.e. no large fringes or other small scale variations that greatly perturb the true photon profile. The second approach is to divide out the overall spectral shape of the flat field spectrum, fill regions outside of the signal with one and leave the profile shape intact. This will still cause profile division problems described earlier but is mentioned here since it implemented in a related task called apnormalize . The last approach is to model both the profile and overall spectrum shape and remove it from the flat field leaving only the sensitivity variations. This is what the task apflatten does.
The two dimensional flat field spectra within the defined apertures of the input images are fit by a model having the profile of the data and a smooth spectral shape. This model is then divided into the flat field image within the aperture, replacing points of low signal, set with the threshold parameter, within the aperture and all points outside the aperture by one to produce an output sensitivity variation only flat field image.
A two dimensional normalized profile is computed by dividing the data within the aperture by the one dimensional spectrum and smoothing with low order function fits parallel to the dispersion axis if the aperture is well aligned with the axis or parallel to the traced aperture center if the trace is tilted relative to the dispersion axis. The smooth profile is then used to improve the spectrum estimate using variance weighting and to eliminate deviant or cosmic ray pixels by sigma tests. The profile algorithm is described in detail in approfiles and the variance weighted spectrum is described in apvariance .
The process of determining the profile and variance weighted spectrum, and hence the two dimensional spectrum model, is identical to that used for variance weighted extraction of the one dimensional spectra in the tasks apall or apsum and in making a two dimensional spectrum model in the task apfit . Most of the parameters in this task are the same in those tasks and so further information about them may be found in their descriptions. In fact, up to this point the task is the same as apfit and, if the flat field were normalized by this model it would produce the "ratio" output of that task.
This task deviates from apfit in that the final variance weighted one dimensional spectrum of the flat field is subjected to a smoothing operation. This is done by fitting a function to the spectrum using the icfit routine. This may be done interactively or noninteractively depending on the interactive parameter. The default fitting parameters are part of this task. The goal of the fitting is to follow the general spectral shape of the flat field light (usually a lamp) but not the small bumps and wiggles which are the one dimensional projection of sensitivity variations. When the fitted function is multiplied into the normalize profile and then the two dimensional model divided into the data the sensitivity variations not part of the fitted spectrum are what is left in the final output flat field.
The remainder of this description covers the basic steps defining the apertures to be used. These steps and parameter are much the same as in any of the other apextract tasks.
Aperture definitions may be inherited from those of other images by specifying a reference image with the references parameter. Images in the reference list are matched with those in the input list in order. If the reference image list is shorter than the number of input images, the last reference image is used for all remaining input images. Thus, a single reference image may be given for all the input images or different reference images may be given for each input image. The special reference name "last" may be used to select the last set apertures used in any of the apextract tasks.
If an aperture reference image is not specified or no apertures are found for the specified reference image, previously defined apertures for the input image are sought in the aperture database. Note that reference apertures supersede apertures for the input image. If no apertures are defined they may be created automatically, the find option, or interactively in the aperture editor, if the interactive and edit options are set.
The functions performed by the task are selected by a set of flag parameters. The functions are an automatic spectrum finding and aperture defining algorithm (see apfind ) which is ignored if apertures are already defined, automatic recentering and resizing algorithms (see aprecenter and apresize ), an interactive aperture editing function (see apedit ), a spectrum position tracing and trace function fit (see aptrace ), and the main function of this task, the flat field profile and spectral shape modeling and removal.
Each function selection will produce a query for each input spectrum if the interactive parameter is set. The queries are answered by "yes", "no", "YES", or "NO", where the upper case responses suppress the query for following images. There are other queries associated with tracing which first ask whether the operation is to be done interactively and, if yes, lead to queries for each aperture. If the interactive parameter is not set then aperture editing interactive trace fitting, and interactive spectrum shape fitting are ignored.
1. To make a two dimensional flat field from a lamp observation:
cl> apflatten fiber1 flat read=3 gain=1 back=fit Yes find No resize No edit Yes trace Yes trace interactively NO Yes flatten Yes fit interactively
apbackground, approfile, apvariance, apfit, icfit, apdefault, apfind, aprecenter, apresize, apedit, aptrace, apsum