subtract_chops¶
- sofia_redux.instruments.fifi_ls.subtract_chops.subtract_chops(chop0_file, outdir=None, add_only=False, write=False)[source]¶
Subtract chops of ramp-fitted data.
One HDUL/file is created for a chop pair, containing n_scan binary table extensions, each containing DATA and STDDEV data cubes of shape (18, 5, 5). The output filename is created from the input filename with the suffix ‘RP0’ replaced with ‘CSB’.
The procedure is:
Check chop amplitude: if zero, assume observation was taken in no-chop mode and return without subtracting chops
Identify chop 1 file corresponding to input chop 0 file and read both from disk.
For each extension, subtract OFF data from ON data.
symmetric mode: For A nods, chop 1 is subtracted from chop 0. For B nods, chop 0 is subtracted from chop 1. This should result in positive source flux in the resulting output, whether nod A or B, so that files can be simply added in the nod-combination algorithm.
asymmetric mode: chop 0 is subtracted from chop 1, regardless of nod position. Sky files are subtracted from sources files in the nod-combination algorithm.
Propagate the error as the square root of the sum of the input variances.
(optional) Create FITS file and write to disk.
- Parameters:
- chop0_filestr
File path to the chop 0 file (RP0.fits). The chop 1 file is assumed to have the same root and directory location, with the designator RP1 in place of RP0.
- outdirstr, optional
Directory path to write output. If None, output files will be written to the same directory as the input files.
- add_onlybool, optional
If True, chop files will be added rather than subtracted. This is intended to be used for flat files only.
- writebool, optional
If True, write to disk and return the path to the output file. If False, return the HDUL.
- Returns:
- fits.HDUList or str
Either the HDU (if write is False) or the filename of the output file (if write is True)