A new 'dynamical' wavelength solution can be computed for each new etalon spectrum in combination with the etalon parameters determined previously (see Step 1 in Wavelength Calibration). This step involves exposures with etalon light injected into the science fibers at the frontend and into the simultaneous calibration fiber, resulting in a DEEEE type frame. The lines in these spectra are then refitted (see Etalon Line Fitting) and a new spline-based wavelength solution is computed using the analyze/recipes/etalon_spline_wls.py script.
The main function fit_and_apply_etalon_wls() works on individual 1D reduced and fitted etalon spectra. A batch version provides functionality to process more than one file at a time in multi-threaded fashion, see discussion below.
Etalon parameter file (hdf).
1D (hdf) extracted etalon spectra.
Wavelength solution added to the input hdf file.
Log file with ending _spline.log
Plots with ending _spline.pdf
API:
Function fit_and_apply_etalon_wls(etalon_file,param_file,fibers,ref_file=None,ref_fiber=None,thar=False,p=None) in analyze/recipes/etalon_spline_wls.py
Parameters (mandatory):
etalon_file Absolute path and filename containing reduced and fitted etalon spectra
param_file Absolute path and filename containing etalon parameters
fibers List of fibers containing etalon spectra (e.g., [2,3,4,5] in a DEEEE file)
Parameters (optional):
ref_file Absolute path and filename containing reduced and fitted etalon spectra. This input is only used for the drift correction step.
ref_fiber Which fiber to use as the reference fiber if a reference spectrum was provided. This input is only used for the drift correction step.
thar True/False for applying only initial ThAr wavelength solution. This input is not used here. Default: False
p Etalon parameters. If param_file is set to None, p must be used to provide the etalon parameters. This input is not used here.
Example: fit_and_apply_etalon_wls(
"/data2/MaroonX_spectra_reduced/20201119/20201119T083653Z_DEEEE_b_0055.hdf",
"/data/MaroonX_spectra_reduced/Maroonx_wls/202005xx/wl_combined_final_etalon_peakmodel_2020.hdf",
fibers=[2,3,4,5])
API example call to fit a spline-based wavelength solution to fibers 2,3,4,5 of the input spectrum. Results are saved in the input spectrum. Plots are written to
/data2/MaroonX_spectra_reduced/20201119/20201119T083653Z_DEEEE_b_0055_spline.pdf
From the base directory (maroonx_reduce) call: PYTHONPATH=${PWD} python analyze/recipes/batch_etalon_spline_wls.py
with the following parameters:
-p PARAM_FILE, --param_file PARAM_FILE Full name and path of etalon parameter file.
Default = '/data /MaroonX_spectra_reduced/Maroonx_wls/
202005xx/wl_combined_final_etalon_peakmodel_2020.hdf'.
-dd DATA_DIRECTORY, --data_directory DATA_DIRECTORY Directory for hdf input files. Input files need to have extracted etalon positions.
Default = '/data2/MaroonX_spectra_reduced/'.
-d DATE, --date DATE UTC date of file, e.g. '20200901' or '202009*'.
-o OBS_TYPE, --obs_type OBS_TYPE Obs type, e.g. 'DEEEE' or 'DEEED'. Default: 'DEEEE'
-c CAMERA_ARM, --camera_arm CAMERA_ARM Camera arm, e.g. 'b' or 'r'. Default: '?' for both
-t EXPTIME, --exptime EXPTIME Exposure time in sec to downselect files, e.g. '80'. Default = '*'
-m MULTITHREAD, --multithread MULTITHREAD Multithread or only loop over files. Default = False (just loop)
Example: PYTHONPATH=${PWD} python analyze/recipes/batch_etalon_spline_wls.py -d '20201201' -c 'b' -m True
Example call for the multi-file / multi-threaded routine to re-determine a wavelength solution for all fibers with source designation 'E' in its filename for all orders in the blue arm. All files matching 'DEEEE' type and 20201201 as a date are processed.
Fits a cubic smoothing spline with 30 equidistant knots to the etalon peak parameters in each fiber/order using the global etalon parameters.
The function name fit_and_apply_etalon_wls() is used in different python scripts with different parameters and slight variations of its functionality. This might be confusing. If separate functions are indeed desirable for the different use cases (initial wavelength solution, dynamical wavelength solution, drift solution) than the routine should be renamed and stripped of unused parts, particularly the ThAr option and the reference file option.
A few things are hard coded that can (should?) be made a parameter call:
Number of knots per order (see n_knots)
Sigma clipping value for outlier removal (currently set to 3.5 and 4 - see bad = np.where() and good = np.where() lines)
QC: Procedure should raise a flag if it fails (e.g., no etalon peak data found). Currently only >>ERROR - Exception: 'NoneType' object has no attribute 'loc' is written into the log file.