# Pipeline overview

\label{sec:pipeline} The FLOYDS pipeline runs in two different modes: automatic reduction and interactive reduction. The automatic reduction is run by an executable script floydsauto on a linux machine at LCOGT headquarters as soon as new observations are automatically downloaded and archived from FTN and FTS. This script produces the tar file with the observations and data products for users, FLOYDS data product 1 (FDP1). This is what the vast majority of FLOYDS users should use. Intermediate data products are also provided so that the user can, for example, reextract the spectrum from the red and blue wavelength and flux calibrated, rectified 2d images.

It is also possible to do a more complete interactive reduction with the executable script floydsspec. It is explained here for completeness, but is not supported for general users. It requires installation of the FLOYDS pipeline.

## Steps common to both modes

The initial steps taken by the automatic and interactive reductions are:

• Splitting arms: The first and second order are divided into blue and red arms as a first step. From here on, all the data are analyzed separately and only combined at the end.

• X-axis rectification: The spectra are initially curved, so they are straightened (rectified) along the x-axes using a Legendre polynomial. Different functions are used for FLOYDS at FTN and FTS. Commissioning tests indicated the instruments are stable enough to use a fixed transformation function for all the data. We do this, rather than computing the transformation from each data set. This ensures that the rectification will be successful even for data with a low signal-to-noise ratio.

• Trimming: The frame is then trimmed in order to exclude the part with no signal.

• Cosmic ray cleaning : The 2D images are cleaned of cosmic rays using the lacosmic Laplacian cosmic ray rejection algorithm1 of van Dokkum (2001). We use a modified python2 implementation that avoids the use of the scipy package.

• Y-axis rectification: The blue and red parts of the frame are rectified along the y-axes using a Legendre polynomial. This produces a rough wavelength calibration. Typical rectified blue and red frames are shown in Figure \ref{fig:rect}.

• Fringing correction: The fringing correction is performed by dividing the science frame by the normalized flat field. Flat fields are normalized using the pyraf task apflatten, which normalizes the flat frames by dividing the flat field by a surface obtained with low order polynomial fit of the flat frame. This task gives a better result that the iraf task response in cases where the flat is not homogeneous along the spatial axes. However, apflatten needs to have as input a trace to follow for the 2D polynomial fit. Since the frames are already rectified, we use as a trace a linear function at the center of the frame parallel to the x-axes.

Calibration arc and flat field frames are usually taken as part of the same observation block as the science frame and are rectified in the same way as the science frame. Observations of a flat taken soon before or after the science frame are strongly suggested since the FLOYDS CCDs suffer intense fringing in the red. Flats taken both before and after the science exposure may improve the fringing correction. If a flat field has not been observed in the same observation block of the science exposure, another from the same night is used. In the case of interactive reductions, a flat from the reduction directory may be used instead.

When a flat field frame was not observed soon after the science frame, distortion may cause a misalignment between the two. This can result in a poor fringing correction. FLOYDS pipeline .0 tries to apply a shift and to scale the fringing flat to get a better fringing correction. Further investigations are underway to find a better solution, but for now we include in the FDP1 both frames corrected and not corrected for fringing, and the normalized flat frame, to give the user the option to apply the flat field correction independently.

From here on the interactive reduction and automatic reduction proceed differently.

## Automatic reduction

The automatic reduction applies the following steps to the rectified, cosmic corrected, fringing corrected 2D frame:

1. Check wavelength calibration with sky lines or telluric lines.

2. Flux calibration of the 2D frame using a sensitivity function from the archive.

3. Fast extraction of the blue and red frames.

4. Merge blue and red 1D spectra.

While the 1D spectrum may be useful for a fast check of the data quality, we consider the 2D wavelength and flux calibrated image the best starting point for user who wants to use the automatic reduction. We encourage users to manually perform the last 3 steps of the reduction:

1. Extraction: Depending on the science topic, different users may need different extraction parameters, for example, the aperture extracted, background extraction window, or multiple extractions.

2. Wavelength calibration: The 2D frames produced by the automatic calibration have been calibrated during the rectification (which uses a fixed solution) and a shift (computed with telluric or sky lines) has been applied. The arc frame observed soon after the science frame is not used by the automatic reduction, but it is provided and can be used to improve the wavelength calibration up to few tenths of an Å. The wavelength calibration performed by the automatic reduction should be accurate to 1-2 Å.

3. A check on the absolute flux calibration should be done using a standard frame observed during the same night.

## Interactive reduction

The interactive reduction uses the rectified, cosmic corrected, fringing corrected 2D frame, and applies the following steps:

1. Extraction of the spectra: This is performed using the IRAF task apall.

2. Wavelength calibration: The wavelength calibration is done using the arc frame observed closest in time to the observation, using the IRAF task identify.

3. Check wavelength calibration with sky or telluric lines: This is computed in a similar way to the automatic reduction, but using the third dimension of the extracted spectrum.

4. Flux calibration: If a standard has been observed the same night, the pipeline should recognize the standard frames and extract and calibrate the standard frame in the same way as it is done for the science observations. Then a sensitivity function is computed using the IRAF task standard and sensfunction. These files are then used to flux calibrate the science frame. If there are no standards observed the same night, a sensitivity function from the archive is used.

5. Telluric correction: A telluric correction is applied using a a model of the atmospheric absorption to correct for the H$$_{2}$$O and O$$_{2}$$ absorption. The model was computed by F. Patat using the Line By Line Radiation Transfer Model (LBLRTM; Clough et al., 2005). Details on the model and the parameters used can be found in Patat et al. (2011). The pipeline scales the model spectrum so that the intensities of H$$_{2}$$O and O$$_{2}$$ absorptions match those observed in the spectrophotometric standards, hence creating multiple model telluric spectra per night. Each science spectrum is than corrected for telluric absorption by dividing it by the scaled absorption model which is most closely matched in time i.e. the closest match between the standard star observation time and the science observation time. If no standards were observed the same night the telluric correction is performed with a file obtained from a different night stored in the archive or selected by the user.