Quick Start

The Data Reduction Pipeline (DRP) of WIRC+Pol is a modular, object-oriented software designed to reduce data taken by the WIRC+Pol infrared (IR) spectropolarimeter on the 200-inch Hale Telescope at Palomar Observatory. It is also designed to be adaptable to reduce data from other multi-channel spectropolarimeter.

There are two classes of objects the DRP uses: wirc_data and wircpol_source. Each wirc_data object encapsulate one image recorded by WIRC+Pol including the full image, all header informations, and its calibration and reduction history. For each wirc_data object, there may be a list of wircpol_source objects, each of which describes a source in the wirc_data object. This object contains the position of the source along with cutouts of the source’s four spectral traces. It may also include spectra and polarization extracted for the source. To reduce WIRC+Pol data, the DRP loads the raw image in as a wirc_data object, then operate on it through the following steps to produce polarization spectra.

Steps of Operation

  1. Basic Calibration: a science image is dark subtracted and flattened using dark and flat frames taken on the same night, or on a night close to the science observation. This step is performed by the method wirc_data.calibrate.

  2. background-subtraction: a calibrated science image is then background subtracted. This is a crucial step to remove polarimetric biases from the bright IR sky emission. There are several methods, but generally they rely on a library of background frames taken with some offsets from the science observations. If the slit is used, the source is typically observed at two dither positions inside the slit (AB) so images from one position can be used as background for another position. The method for generating background file for subtraction is wirc_data.generate_bkg.

  3. Source Finding: after background subtraction, one can either run automatic source finding using the method of wirc_data.find_sources_v2, or manually specify the location of the source to be extracted using the add_source method. Either way, this will create wircpol_source objects associated with that wirc_data object. The get_source_cutouts method is run to retrieve small thumbnails of the four spectral traces for extraction.

  4. Spectral Extraction: once the background image and the location of the source(s) are defined, the extract_spectra method can be run on each wircpol_source object to retrieve four flux spectra from the upper left, lower right, upper right, and lower left spectral traces of a source. The output spectral cube, which is the trace_spectra attribute of the wircpol_source object, is an array of shape [4, 3, spectral_length] where the first index is the four spectra, the second index is (wavelength, flux, flux_uncertainty), and the last index is the spectrum. For example, the upper left flux is wircpol_source.trace_spectra[0,1,:]. Wavelength calibration can be obtained by the rough_lambda_calibration method. Note that this step is sometimes unreliable, and the resulting wavelength solution should be verified.

  5. polarization-calculation: and Calibration: this calculation is performed after all science images in the dataset have been reduced and extracted. The calculation is performed on the datacube of all extracted spectra (dimensions [n_images, 4, 3, spectral_length], where n_images is the number of images in the observation sequence. In addition, we also need an array of the half-wave plate angle (with length equals to n_images). The calculation can be performed by using the function compute_qu_for_obs_sequence in source_utils.py on the spectra cube and the HWP angle array. Finally, the normalized Stokes parameters from compute_qu_for_obs_sequence can be calibrated using the calibrate_qu function in calibration.py.

For the example of these steps, see the Tutorial notebooks. Functions to perform steps 2-5 automatically are in dataset.py.