spatial_calibrate

sofia_redux.instruments.fifi_ls.spatial_calibrate.spatial_calibrate(filename, obsdate=None, flipsign=None, rotate=False, outdir=None, write=False)[source]

Apply spatial calibration (x and y offsets).

Each data extension will be updated with xs and ys fields, containing spatial coordinates for each pixel in the data array. The input file should have been created by fifi_ls.lambda_calibrate. This procedure handles only ERF coordinates; SIRF mapping is neither detected nor handled properly.

The FIFI-LS optics are not perfectly aligned so the pixels do not fall on an even grid. This routine calculates the x, y locations for each pixel and shifts them according to dither positions. The procedure is, for each grating scan extension:

  1. Calculate spatial positions in mm (from fifi_ls.offset_xy)

  2. Convert positions to arcseconds, using PLATSCAL, dither offsets (DLAM_MAP and DBET_MAP, possibly with a sign-flip on each), and offsets of the secondary array from the primary (from data/secondary_offset.txt).

  3. Convert arcsecond offsets to RA and Dec coordinates.

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

For OTF mode data, each input ramp sample has a separate DLAM_MAP and DBET_MAP value, as recorded in the SCANPOS table in the input FITS file. These values are used to calculate the X and Y offsets for each sample. The output XS and YS image extensions have dimension 25 x 1 x n_ramp. The SCANPOS table is not propagated to the output.

For all other data, the X and Y offsets are calculated from the DLAM_MAP and DBET_MAP keywords in the header, and are attached to the output as a 25-element array in the XS and YS image extensions.

For all data, RA and DEC image extensions are additionally attached, containing the sky coordinates for each spaxel in hours and degrees, respectively. Array dimensions for these extensions match the XS and YS arrays.

Parameters:
filenamestr

File to be spatial-calibrated

obsdatearray_like of int, optional

Date of observation. Intended for files that do not have the DATE-OBS keyword (and value) in the FITS primary header (early files do not). Format is [YYYY,MM,DD].

flipsignbool, optional

If True, DLAM_MAP and DBET_MAP will be multiplied by -1. If False, DLAM_MAP and DBET_MAP will be used as is. If None (default), the observation date will be used to determine what the sign convention should be.

rotatebool, optional

If True, rotate by the detector angle to set N up.

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 HDUList. The output filename is created from the input filename, with the suffix ‘WAV’ replaced with ‘XYC’.

Returns:
fits.HDUList or str

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