flux_calibrate

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

Convert spectra to physical flux units.

The procedure is:

  1. Identify response file to use. Smooth it to the spectral resolution of the input file.

  2. Read the spectral data from the input file.

  3. Loop over the spaxels.

  4. For each spaxel, interpolate the response data onto the wavelengths of the spexels and multiply the data at each point by the response value and its associated wavelength.

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

The output FITS file matches the extensions and dimensions of the input FITS file, with an additional RESPONSE extension attached, containing the interpolated response correction. The dimensions of the RESPONSE array match the dimensions of the LAMBDA array.

Parameters:
filenamestr

FITS file to be flux calibrated. Should have been created by fifi_ls.combine_grating_scans or fifi_ls.telluric_correct.

response_filestr, optional

Response file to be used. If not provided, a default file will be used. If provided, should be a FITS image file containing wavelength, response data, and response error in an array of three rows in the primary extension.

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 ‘SCM’ or ‘TEL’ replaced with ‘CAL’.

outdirstr, optional

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

Returns:
fits.HDUList or str

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