combine_grating_scans

sofia_redux.instruments.fifi_ls.combine_grating_scans.combine_grating_scans(filename, correct_bias=False, write=False, outdir=None)[source]

Combine separate grating positions in FIFI-LS data.

Combines separate grating positions in FIFI-LS data into a single extension. Will produce an unevenly spaced wavelength grid if multiple grating (inductosyn) extensions exist in the input file.

The procedure is:

  1. Read the wavelength values for all grating scans to determine overlapping wavelength regions.

  2. Loop over the grating scan extensions, reading the flux from each. Calculate the mean value of any overlapping wavelength regions. Store all data in an unsorted cube.

  3. Loop over the spaxels in the cube, correcting the flux to the mean value of all overlap regions, then sorting the data by its associated wavelength value.

  4. Create FITS file and (optionally) write results to disk.

The output FITS file contains FLUX, STDDEV, LAMBDA, XS, YS, RA, and DEC data arrays. For most data, all arrays have dimension 25 x nw, where nw is the combined number of wavelength samples across all input grating scans.

For OTF data, only one grating scan is expected or allowed, so nw is always 16. Output cubes for FLUX, STDDEV, XS, YS, RA, and DEC are 25 x 16 x n_ramp. The LAMBDA array is 25 x 16.

Parameters:
filenamestr

Path to the file to be combined

correct_biasbool, optional

If True, additive offset between separate grating scans will be removed, using overlapping wavelength regions to determine the value of the bias.

outdirstr, optional

Directory path to write output. If None, output files will be written to the same directory as the input files.

writebool, optional

If True, write to disk and return the path to the output file. If False, return the HDUL. The output filename is created from the input filename, with the suffix ‘XYC’ or ‘FLF’ replaced with ‘SCM’.

Returns:
fits.HDUList or str

Either the HDU (if write is False) or the filename of the output file (if write is True)