Reducing the Science Target and Standard Star Data (Step=4)¶
Relevant code¶
XDpiped.csh ReducingXD.py AltReducingXD.py
Relevant options¶
1despike_tgt: yes/no (yes) [attempt to remove spikes from science target data?]
2despike_std: yes/no (no) [attempt to remove spikes from standard star data?]
3tgt_thresh: (20) [threshold for removing spikes from science target data]
4tgt_thresh: (50) [threshold for removing spikes from standard star data]
What it does¶
At this stage, the following things take place:
The science target data (and, optionally, the standard star) are “cleaned” of spikes
The science target and standard star data are cut, flatfielded and sky-subtracted
These steps are performed by the ReducingXD.py or AltReducingXD.py
modules. The algorithm used to identify and remove the radiation events
is described on the GNIRS XD DR page. Briefly, a “minimum” image is
created from all the individual input files at each offset position, and
pixels deviating by some multiple of the noise above the minimum image
are identified as radiation events. The events are “grown” to include
their haloes and the central pixels and then interpolated
using IRAF’s fixpix task. The output files have the prefix “l” (e.g.
lncN20120305S0067.fits). This “despiking” is much more critical for data
taken before June 2012, when one of the lenses with radioactive
coatings in the SB camera was replaced. Still, later data do tend to
contain spikes that can also benefit from this procedure.
Unlike in previous versions of XDGNIRS, the standard star data are by
default not cleaned of spikes. This is because we judged the risk of
false positives to outweigh the need to clean short-exposure images,
especially for non-interactive reductions. The despike_std option allows
the standard star to be treated if necessary. We also briefly
experimented with using the gemcrspec task, based on the LACOSMIC
routine, to clean the data. We didn’t obtain satisfactory results, but
the interested user is welcome to uncomment lines \(\sim\)517-518
in XDpiped.csh and edit the gemcrspec options in AltReductingXD.py if
they would like to try.
The nsreduce task is then used to cut the science target and
standard star data, apply the flat, and do the sky subtraction. The
resulting files have the prefix “r” (e.g., rlncN20120305S0067.fits). Sky
frames are not explicitly supplied to nsreduce, so the task attempts to
identify a sky frame for each input file based on the nod position and
separation in time between the spectra.
What to look for¶
We highly recommend that the user inspect the mask files at this stage to
check that the real signal hasn’t been identified as a series of radiation
events. Problems are more likely to be encountered with bright objects and
when varying weather conditions caused the signal to vary significantly among
the individual files. The masks have the prefix “bgmsk” and can be found in the
INTERMEDIATE directory. If bad masks are found, rerun the code from
step=4 and set the tgt_thresh parameter to a value higher than the
default. The default threshold is simply a value that works reasonably well on
several test data sets, and users may wish to experiment with this parameter to
find the best “despiking” of their data. If unacceptable radiation events
remain after this process, the bgmsk*pl files (or final, combined files) could
be edited using the imedit task. Sky subtraction does remove many lower-level
spikes; see Example: NGC 3031.
Things to most likely go wrong¶
The sky-object pairing algorithm in nsreduce works well except in cases
where the files are irregularly spaced, which can happen if the observer
paused for clouds to pass, for example. If nsreduce can’t identify sky
files, XDGNIRS will exit with an error. If the offending files happen to
be at the start or end of the sequence, they could simply be omitted
from the input list. Otherwise, the workaround would be to run nsreduce
outside the pipeline, supplying a list of sky files via the “skyimages”
parameter (see the nsreduce help). As long as the output files follow
the naming convention used by nsreduce/XDGNIRS, the code could then be
restarted at the next step. The name of the file used for sky
subtraction is written into the header of each resulting data file, so
this can be checked if problems are suspected.
Example: NGC 3031¶
As these data were taken before the 2012 lens replacement, they contain
many radiation events and are reduced using the despike_std=yes option
(as well as the default despike_tgt=yes).
Fig. 4 shows one of the on-source galaxy spectra before and after the radiation event removal. Most of the prominent spikes are removed by this process. As Fig. 5 shows, no real signal was flagged when the default value of the tgt_thresh parameter was used. Setting the value of that parameter to lower values causes background emission at the long-wavelength end of the K band to be identified as a series of radiation events. More commonly, spurious detections will extend along the target spectrum or horizontally along sky emission lines.
Fig. 4 On-source galaxy spectrum, before (left, ncN20120305S0067) and after (right, lncN20120305S0067) radiation event “cleaning”.¶
Fig. 5 The radiation event mask, “bgmskN20120305S0067.pl” created for file 67 using the default value of tgt_thresh (left), and tgt_thresh=5 (right). With the lower value of tgt_thresh, signal from the galaxy has been erroneously flagged as radiation events.¶
In any case, interpolating over a genuine signal will make a mess of the final spectrum and should be avoided.
As well as the bright, obvious radiation events, several less prominent artifacts are also visible in the data. These can be seen in Fig. 6, which shows a close-up of the cleaned data in Fig. 4, before and after sky subtraction. Many artifacts disappear when the data are sky-subtracted, and others will decrease in magnitude when the files are combined – see S-distortion Correction and Wavelength Calibration (Step=5). Nonetheless, if users find ways of improving the process, feedback would be very welcome.
Fig. 6 Left: close-up of the data shown in Figure 4, after removal of radiation events (lncN20120305S0067; z1=-5, z2=75). Right: extension 6/order 8 of the same file after sky subtraction (rlncN20120305S0067; z1=-5, z2=75). The green circle identifies the same pixels of extension 6/order 8 in each case, for orientation.¶