Wavelength Solution¶
Welcome to the documentation for the ‘wifes_wsol.py’ module, which contains the core functions for determining the wavelength solution of WiFeS data.
- pywifes.wifes_wsol.derive_wifes_optical_wave_solution(inimg, outfn, arc_name=None, ref_arclines=None, ref_arcline_file=None, dlam_cut_start=5.0, flux_threshold_nsig=3.0, find_method='mpfit', shift_method='xcorr_all', exclude_from=None, exclude=None, epsilon=0.005, doalphapfit=False, automatic=False, verbose=False, decimate=False, sigma=1.0, alphapfile=None, plot=False, plot_dir='.', multithread=False, plot_slices=False, debug=False)¶
This function reads the input image, finds the lines, and fits the optical model to the lines. The derived wave solution is saved to the specified output file.
- Parameters:
inimg (str) – Path to the input image.
outfn (str) – Path to save the output file.
arc_name (str, optional) – Name of the arc.
ref_arclines (array-like, optional) – Reference arcline wavelengths.
ref_arcline_file (str, optional) – Path to the file containing reference arcline wavelengths.
dlam_cut_start (float, optional) – Starting wavelength cut-off for line finding.
flux_threshold_nsig (float, optional) – Flux threshold in terms of number of standard deviations.
find_method (str, optional) – Method for finding lines.
shift_method (str, optional) – Method for shifting lines.
exclude_from (str, optional) – Path to the file containing lines to exclude.
exclude (array-like, optional) – Lines to exclude.
epsilon (float, optional) – Tolerance for excluding lines.
doalphapfit (bool, optional) – Whether to perform alphap fitting.
automatic (bool, optional) – Whether to perform automatic fitting.
verbose (bool, optional) – Whether to print verbose output.
decimate (bool, optional) – Whether to decimate the data.
sigma (float, optional) – Sigma value for fitting.
alphapfile (str, optional) – Path to the file containing alphap values.
plot (bool, optional) – Whether to plot the results.
plot_dir (str, optional) – Directory to save the plots.
multithread (bool, optional) – Whether to use multithreading.
plot_slices (bool, optional) – Whether to plot per-slice wavelength fits Default: False.
debug (bool, optional) – Whether to report the parameters used in this function call. Default: False.
- Return type:
None
- pywifes.wifes_wsol.derive_wifes_polynomial_wave_solution(inimg, out_file, dlam_cut_start=7.0, dlam_cut=3.0, ref_arclines=None, ref_arcline_file=None, arc_name=None, grating=None, bin_x=None, bin_y=None, x_polydeg=4, y_polydeg=2, flux_threshold_nsig=3.0, deriv_threshold_nsig=1.0, verbose=False)¶
Derives the polynomial wave solution for WiFeS data. The wave solution is derived by fitting the arc lines in each slitlet and then fitting a polynomial to the derived wavelengths. The derived wave solution is saved to the specified output file.
- Parameters:
inimg (str) – Input MEF file name.
out_file (str) – Output file name for the derived wave solution.
dlam_cut_start (float, optional) – Starting wavelength cut in Angstroms for the derivative calculation (default is 7.0).
dlam_cut (float, optional) – Wavelength cut in Angstroms for the derivative calculation (default is 3.0).
ref_arclines (array-like, optional) – Reference arc lines for wavelength calibration (default is None).
ref_arcline_file (str, optional) – File name containing reference arc lines for wavelength calibration (default is None).
arc_name (str, optional) – Name of the arc lamp used for calibration (default is None).
grating (str, optional) – Grating used for calibration (default is None).
bin_x (int, optional) – Binning factor in the x-direction (default is None).
bin_y (int, optional) – Binning factor in the y-direction (default is None).
x_polydeg (int, optional) – Degree of the polynomial fit in the x-direction (default is 4).
y_polydeg (int, optional) – Degree of the polynomial fit in the y-direction (default is 2).
flux_threshold_nsig (float, optional) – Flux threshold in number of standard deviations for peak detection (default is 3.0).
deriv_threshold_nsig (float, optional) – Derivative threshold in number of standard deviations for peak detection (default is 1.0).
verbose (bool, optional) – Whether to print verbose output (default is False).
- Returns:
The derived wave solution is saved to the specified output file.
- Return type:
None
- pywifes.wifes_wsol.derive_wifes_wave_solution(inimg, out_file, method='optical', **args)¶
Derives the wavelength solution for WiFeS data. The derived wave solution is saved to the specified output file. The method to use for deriving the wavelength solution can be specified using the ‘method’ parameter. The following methods are available:
‘poly’ for polynomial fitting: The wave solution is derived by fitting the arc lines in each slitlet and then fitting a polynomial to the derived wavelengths.
‘optical’ for optical fitting. The wave solution is derived by finding the lines, and fitting the WiFeS optical model to the lines (model provided in the sub-module ‘optical_model.py’).
- Parameters:
inimg (str) – The input image file path.
out_file (str) – The output file path to save the wavelength solution.
method (str) – The method to use for deriving the wavelength solution: polynomial fitting or optical model. Options: ‘poly’, ‘optical’. Default is ‘optical’.
Arguments (Optional Function)
---------------------------
method –
Method for fitting wavelength solution: optical model of spectrograph or polynomial method. Options: ‘optical’, ‘poly’ Default: ‘optical’.
- Options for ‘method’=’optical’:
- shift_methodstr
Method to shift model to match reference line list: shifting each row, just the central row of each slitlet, sampling a grid of rows in the y-axis, or guessing from the optical model. Options: ‘xcorr_all’, ‘xcorr_single’, ‘xcorr_grid’, None. Default: ‘xcorr_all’.
- find_methodstr
Method for fitting the arc lines, using MPFIT, numpy fitter (using logFlux), or scipy fitter. Options: ‘mpfit’, ‘loggauss’, ‘least_squares’. Default: ‘mpfit’.
- doalphapfitbool
Whether to fit each slitlet angle of incidence. Default: True.
- dlam_cut_startfloat
Initial threshold in Angstroms for the derivative calculation portion of the list matching. Default: 5.0.
- flux_threshold_nsigfloat
Number of sigma above the background for line detection. Default: 3.0.
- epsilonfloat
Threshold for excluding lines when matching to exclusion list. Default: 0.005.
- automaticbool
Whether to exclude lines with large residuals. Default: False.
- sigmafloat
RMS threshold offset from mean for excluding lines if ‘automatic’=True. Default: 1.0.
- decimatebool
Whether to perform initial fit with 10% of data. Default: False.
- multithreadbool
Whether to run step using “multiprocessing” module. Default: true.
- Options for ‘method’=’poly’:
- dlam_cut_startfloat
Initial threshold in Angstroms for the derivative calculation portion of the list matching. Default: 7.0.
- dlam_cutfloat
Subsequent threshold for matching to line lists. Default: 3.0.
- x_polydegint
Order of x-axis polynomial. Default: 4.
- y_polydegint
Order of y-axis polynomial. Default: 2.
- flux_threshold_nsigfloat
Number of sigma above the background for line detection. Default: 3.0.
- deriv_threshold_nsigfloat
Threshold for number of sigma different from median flux derivative per x pixel. Default: 1.0.
- Raises:
ValueError – If the wavelength solution method is not recognized.