The pupil slicer distributes the flux of the octagonal science fiber into three rectangular fibers (fibers #2, 3, 4) which are reduced separately. For data with lower SNR (exact values tbd), RV algorithms give better results when the signal from the three fibers is first combined into a single spectrum.
Since the wavelength solutions for the three fibers are not identical, proper re-sampling is required. The algorithm is using a cubic spline interpolation to resample fibers #2 and #4 onto the wavelength grid of fiber 3, applying outlier correction and proper weighting to deliver a combined flux and uncertainties which are saved as a 'virtual' fiber #6.
Unlike the individual spectra from fibers 2, 3, and 4 which have NaN values in the flux and uncertainty vectors for bad columns, the combined flux never has NaNs but the flux is set to 0 and the uncertainty us set to 1e6, to denote these pixels as outliers. This is done to ease handling in SERVAL.
The procedure is written as a multi-threaded/multi-file batch processing routine.
Reduced (science) spectra (hdf)
Combined flux and uncertainties as new 'fiber 6' in input file.
PDF plot with spectrum, uncertainties, and SNR as _fiber6.pdf
From the base directory (maroonx_reduce) call: PYTHONPATH=${PWD} python analyze/recipes/combine_science_fibers.py
with the following parameters:
-dd DATA_DIRECTORY, --data_directory DATA_DIRECTORY Directory for hdf input files. Default ='/data2/MaroonX_spectra_reduced/'.
-d DATE, --date DATE UTC date of file, e.g. '20200901' or '202009*'.
-c CAMERA_ARM, --camera_arm CAMERA_ARM Camera arm, e.g. 'b' or 'r'. Default: '?' for both
-o OBS_TYPE, - -obs_type OBS_TYPE Obs type. Default: 'SOOOE'
-t EXPTIME, --exptime EXPTIME Exposure time in sec to downselect files, e.g. '300'. Default = '*'
--file FILE Specify specific file. Ignores date and obstype.
--kappa_sigma KAPPA_SIGMA Kappa-sigma clipping value. Default = 5.0
--max_clip MAX_CLIP Maximum pixels per order to be kappa-sigma clipped. Default = 5000 (no limit)
Example 1: PYTHONPATH=${PWD} python analyze/recipes/combine_science_fibers.py -d '20201201'
Example call collects all blue and red science (SOOOE) frames from /data2/MaroonX_spectra who's date is matching 20201201 and computes combined flux from all three science fibers.
Fluxes and uncertainties from fibers 2 and 4 are interpolated to the wavelength grid of fiber 3 using cubic spline interpolation. The combination then uses a weighted mean with an additional sigma-kappa clipped outlier rejection. The kappa value is an input parameter. The weights for the clipped data is simply set to 0 for the mean. The pdf shows the clipped pixels. Note that kappa should actually be a function that takes the blaze into account, instead of a fixed value. A fixed value might lead to too many data being clipped at the edges of the orders, particularly for high SNR data. The max_clip option iteratively increases the kappa_sigma value until less than the specified number of pixels are clipped in any fiber in a given order. The kappa_sigma value is re-accessed for each order.
Error handling in the multi-threaded environment is poor, i.e. if something goes wrong for a file, it's hard to figure out which file caused the problem. Logging added in 2021/03 but may still need a callback function for error handling.
The kappa sigma clipping should take the blaze into account.
The kappa sigma value is re-accessed for each order if option --max_clip is used. This should maybe be done separately for each fiber in each order instead of determining the value based on the worst fiber of each order.
QC: Procedure should raise a flag if it fails (too many NANs).