combine_nods¶
- sofia_redux.instruments.fifi_ls.combine_nods.combine_nods(filenames, offbeam=False, b_nod_method='nearest', outdir=None, write=False)[source]¶
Combine nods of ramp-fitted, chop-subtracted data.
Writes a single FITS file to disk for each A nod found. Each HDU list contains n_san binary table extensions, each containing DATA and STDDEV data cubes, each 5x5x18. The output filename is created from the input filename, with the suffix ‘CSB’, ‘RP0’ or ‘RP1’ replaced with ‘NCM’, and with input file numbers numbers concatenated. Unless specified, the output directory is the same as the input files.
Input files should have been generated by
subtract_chops
, orfit_ramps
(for total power mode, which has no chops).The procedure is:
Read header information from each extension in each of the input files, making lists of A data and B data, with relevant metadata (dither) position, date/time observed (DATE-OBS), inductosyn position, channel, nod style).
Loop though all A data to find matching B data
a. asymmetric nod style: find closest B nod in time with the same channel and inductosyn position. Dither position does not have to match, B data can be used more than once, and data must be subtracted rather than added.
b. symmetric nod style: find closest B nod in time with the same channel, inductosyn position, and dither position. Each B nod can only be used once, since it contains a source observation, and data must be added rather than subtracted.
3. After addition or subtraction, create a FITS file and write results to disk.
- Parameters:
- filenamesarray_like of str
File paths to the data to be combined
- offbeambool, optional
If True, swap ‘A’ nods with ‘B’ nods and the following associated keywords: DLAM_MAP <-> DLAM_OFF, DBET_MAP <-> DBET_OFF. This option cannot be used with OTF-mode A nods.
- b_nod_method{‘nearest’, ‘average’, ‘interpolate’}, optional
For asymmetric, data this option controls how the nearest B nods are combined. The ‘nearest’ option takes only the nearest B nod in time. The ‘average’ option averages the nearest before and after B nods. The ‘interpolate’ option linearly interpolates the nearest before and after B nods to the time of the A data.
- 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.
- Returns:
- pandas.DataFrame
The output pandas dataframe contains a huge variety of information indexed by original filename. The combined A-B FITS data are located in the ‘chdul’ column. Note that only A nod files contain combined data in this ‘chdul’ column. For example, in order to extract combined FITS data, one could issue the command:
df = combine_nods(filenames) combined_hduls = df[df['nodbeam'] == 'A']['chdul']
In order to extract rows from the dataframe that were not combined issue the command:
not_combined = df[(df['nodbeam'] == 'A') & (df['chdul'] == None)]
files are considered ‘combined’ if at least one A extension was combined for an A-nod file. A true signifier of whether an extension was combined (both A and B nod files) can be found in the ‘combined’ column as a list of bools, one for each extension.