OneDSpec API

class aspired.spectral_reduction.OneDSpec(verbose: bool = True, logger_name: str = 'OneDSpec', log_level: str = 'INFO', log_file_folder: str = 'default', log_file_name: str = None)[source]

This class applies the wavelength calibrations and compute & apply the flux calibration to the extracted 1D spectra. The standard TwoDSpec object is not required for data reduction, but the flux calibrated standard observation will not be available for diagnostic.

Parameters:
  • verbose (bool (Default: True)) – Set to False to suppress all verbose warnings, except for critical failure.

  • logger_name (str (Default: 'OneDSpec')) – This will set the name of the logger, if the name is used already, it will reference to the existing logger. This will be the first part of the default log file name unless log_file_name is provided.

  • log_level (str (Default: 'INFO')) – Four levels of logging are available, in decreasing order of information and increasing order of severity: (1) DEBUG, (2) INFO, (3) WARNING, (4) ERROR and (5) CRITICAL. WARNING means that there is suboptimal operations in some parts of that step. ERROR means that the requested operation cannot be performed, but the software can handle it by either using the default setting or skipping the operation. CRITICAL means that the requested operation cannot be resolved without human interaction, this is most usually coming from missing data.

  • log_file_folder (None or str (Default: 'default')) – Folder in which the file is save, set to default to save to the current path.

  • log_file_name (None or str (Default: None)) – File name of the log, set to None to print to screen only.

add_airmass(airmass: float, stype: str, spec_id: int = None)[source]

Add airmass manually.

Parameters:
  • airmass (float) – The airmass.

  • stype (str) – ‘science’ or ‘standard’ to indicate type.

  • spec_id (int or None (default: 0)) – The ID corresponding to the spectrum_oned object.

add_arc_lines(peaks: numpy.ndarray | list, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]
Parameters:
  • peaks (list of list or list of arrays) – The pixel locations of the arc lines. Multiple traces of the arc can be provided as list of list or list of arrays.

  • spec_id (int (Default: 0)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

add_arc_spec(arc_spec: numpy.ndarray | list, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]
Parameters:
  • arc_spec (1-d array) – The count of the summed 1D arc spec

  • spec_id (int (Default: 0)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

add_atlas(elements: list | numpy.ndarray, min_atlas_wavelength: float = 3000.0, max_atlas_wavelength: float = 10000.0, min_intensity: float = 10.0, min_distance=10.0, candidate_tolerance=10.0, constrain_poly=False, vacuum=False, pressure=101325.0, temperature=273.15, relative_humidity=0, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]
Parameters:
  • elements (str or list of strings) – Chemical symbol, case insensitive

  • min_atlas_wavelength (float (Default: 3000.)) – Minimum wavelength of the arc lines.

  • max_atlas_wavelength (float (Default: 10000.)) – Maximum wavelength of the arc lines.

  • min_intensity (float (Default: 10.)) – Minimum intensity of the arc lines. Refer to NIST for the intensity.

  • min_distance (float (Default: 10.)) – Minimum separation between neighbouring arc lines.

  • candidate_tolerance (float (Default: 10.)) – toleranceold (Angstroms) for considering a point to be an inlier during candidate peak/line selection. This should be reasonable small as we want to search for candidate points which are locally linear.

  • constrain_poly (bool (Default: False)) – Apply a polygonal constraint on possible peak/atlas pairs

  • vacuum (bool (Default: False)) – Set to true to convert the input wavelength to air-wavelengths based on the given pressure, temperature and humidity.

  • pressure (float (Default: 101325.)) – Pressure when the observation took place, in Pascal. If it is not known, assume 10% decrement per 1000 meter altitude

  • temperature (float (Default: 273.15)) – Temperature when the observation took place, in Kelvin.

  • relative_humidity (float (Default: 0)) – In percentage.

  • spec_id (int (Default: 0)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

add_exptime(exptime: float, stype: str, spec_id: int = None)[source]

Add exptime manually.

Parameters:
  • exptime (float) – The exptime.

  • stype (str) – ‘science’ or ‘standard’ to indicate type.

  • spec_id (int or None (default: 0)) – The ID corresponding to the spectrum_oned object.

add_fit_coeff(fit_coeff: numpy.ndarray | list, fit_type: str = 'poly', spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]
Parameters:
  • fit_coeff (list or numpy array, or a list of them) – Polynomial fit coefficients.

  • fit_type (str or list of str) – Strings starting with ‘poly’, ‘leg’ or ‘cheb’ for polynomial, legendre and chebyshev fits. Case insensitive.

  • spec_id (int or None (Default: 0)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

add_fluxcalibration(fluxcal: FluxCalibration)[source]

Provide the pre-calibrated FluxCalibration object.

Parameters:

fluxcal (FluxCalibration object) – The true mag/flux values.

add_gain(gain: float, stype: str, spec_id: int = None)[source]

Add arc_spec manually.

Parameters:
  • gain (float) – The gain.

  • stype (str) – ‘science’ or ‘standard’ to indicate type.

  • spec_id (int or None (default: 0)) – The ID corresponding to the spectrum_oned object.

add_pix_wave_pair(pix: float, wave: float, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Adding extra pixel-wavelength pair to the Calibrator for refitting. This DOES NOT work before the Calibrator having fit for a solution yet: use set_known_pairs() for that purpose.

Parameters:
  • pix (float) – pixel position

  • wave (float) – wavelength

  • spec_id (int or None (Default: 0)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

add_readnoise(readnoise: float, stype: str, spec_id: int = None)[source]

Add arc_spec manually.

Parameters:
  • readnoise (float) – The readnoise.

  • stype (str) – ‘science’ or ‘standard’ to indicate type.

  • spec_id (int or None (default: 0)) – The ID corresponding to the spectrum_oned object.

add_science_spectrum_oned(spec_id: int)[source]

Add a new SpectrumOneD with the ID spec_id. This overwrite the existing SpectrumOneD object if it already exists.

Parameters:

spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

add_seeing(seeing: float, stype: str, spec_id: int = None)[source]

Add seeing manually.

Parameters:
  • seeing (float) – The seeing.

  • stype (str) – ‘science’ or ‘standard’ to indicate type.

  • spec_id (int or None (default: 0)) – The ID corresponding to the spectrum_oned object.

add_sensitivity_func(sensitivity_func: Callable)[source]

Provide a callable function of the detector sensitivity response.

Parameters:
  • sensitivity_func (Callable) – Interpolated sensivity curve object.

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

add_spec(count: numpy.ndarray | list, count_err: numpy.ndarray | list = None, count_sky: numpy.ndarray | list = None, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]
Parameters:
  • count (1-d array) – The summed count at each column about the trace.

  • count_err (1-d array (Default: None)) – the uncertainties of the count values

  • count_sky (1-d array (Default: None)) – The integrated sky values along each column, suitable for subtracting from the output of ap_extract

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

add_telluric_function(telluric: Callable, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Provide a callable function that gives the Telluric profile.

Parameters:
  • telluric (callable function) – A function that gives the absorption profile as a function of wavelength.

  • spec_id (int or None (Default: 0)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

add_trace(trace: numpy.ndarray | list, trace_sigma: numpy.ndarray | list, effective_pixel: numpy.ndarray | list = None, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]
Parameters:
  • trace (list or numpy.ndarray (N)) – The spatial pixel value (can be sub-pixel) of the trace at each spectral position.

  • trace_sigma (list or numpy.ndarray (N)) – Standard deviation of the Gaussian profile of a trace

  • effective_pixel (list or numpy.narray (Default: None)) – The pixel position of the trace in the dispersion direction. This should be provided if you wish to override the default range(len(spec.trace[0])), for example, in the case of accounting for chip gaps (10 pixels) in a 3-CCD setting, you should provide [0,1,2,…90, 100,101,…190, 200,201,…290]

  • spec_id (int or None (Default: 0)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

add_user_atlas(elements: list | numpy.ndarray, wavelengths: list | numpy.ndarray, intensities: list | numpy.ndarray = None, candidate_tolerance: float = 10.0, constrain_poly: bool = False, vacuum: bool = False, pressure: float = 101325.0, temperature: float = 273.15, relative_humidity: float = 0.0, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Append the user supplied arc lines to the calibrator.

The vacuum to air wavelength conversion is deafult to False because observatories usually provide the line lists in the respective air wavelength, as the corrections from temperature and humidity are small. See https://emtoolbox.nist.gov/Wavelength/Documentation.asp

Parameters:
  • elements (list) – Element (required). Preferably a standard (i.e. periodic table) name for convenience with built-in atlases

  • wavelengths (list) – Wavelength to add (Angstrom)

  • intensities (list or None (Default: None)) – Relative line intensities

  • candidate_tolerance (float (Default: 10.)) – toleranceold (Angstroms) for considering a point to be an inlier during candidate peak/line selection. This should be reasonable small as we want to search for candidate points which are locally linear.

  • constrain_poly (bool (Default: False)) – Apply a polygonal constraint on possible peak/atlas pairs

  • vacuum (bool (Default: False)) – Set to true to convert the input wavelength to air-wavelengths based on the given pressure, temperature and humidity.

  • pressure (float (Default: 101325.)) – Pressure when the observation took place, in Pascal. If it is not known, assume 10% decrement per 1000 meter altitude

  • temperature (float (Default: 273.15)) – Temperature when the observation took place, in Kelvin.

  • relative_humidity (float (Default: 0.)) – In percentage.

  • spec_id (int (Default: 0)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

add_variance(variance: list | numpy.ndarray, stype: str, spec_id: int = None)[source]

Add variance manually.

Parameters:
  • variance (1-d array) – The variance.

  • stype (str) – ‘science’ or ‘standard’ to indicate type.

  • spec_id (int or None (Default: 0)) – The ID corresponding to the spectrum_oned object.

add_wavelength(wave: numpy.ndarray | list, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Three combinations of wave and spec_id shapes are accepted.

Parameter

Size

wave

1

1

N

spec_id

1

N

N

Parameters:
  • wave (numeric value, list or numpy 1D array (N)) – The wavelength of each pixels of the spectrum.

  • spec_id (int (Default: 0)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

add_wavelength_resampled(wave_resampled: numpy.ndarray | list, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Three combinations of wave and spec_id shapes are accepted.

Parameter

Size

wave

1

1

N

spec_id

1

N

N

Parameters:
  • wave_resampled – The wavelength of the resampled spectrum.

  • spec_id (int (Default: 0)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

add_wavelengthcalibration(wavecal: WavelengthCalibration | list, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Provide the pre-calibrated WavelengthCalibration object.

Parameters:
  • wavecal (list of WavelengthCalibration object) – The WavelengthPolyFit object for the science target, flux will not be calibrated if this is not provided.

  • spec_id (int or None (Default: 0)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

apply_atmospheric_extinction_correction(science_airmass: float = None, standard_airmass: float = None, spec_id: numpy.ndarray | list | int = None)[source]

This is the first step in allowing atmospheric extinction correction of the spectra. Currently it only works if both the science and standard spectra are present and both airmass values are provided. Towards completion, this function should allow atmospheric extinction correction on any meaningful combination of (1) science and/or standard spectrum/a, and (2) airmass of either or both science and standard observations.

Parameters:
  • science_airmass (float, str or None (Default: None)) –

    • If None, it will look for the airmass in the header, if the keyword AIRMASS is not found, correction will not be performed.

    • A string input will be used as the header keyword of the airmass, if the keyword or header is not found, correction will not be performed.

    • A floatpoint value will override the other two and directly be use as the airmass

  • standard_airmass (float, str or None (Default: None)) – The same as science_airmass.

  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

apply_flux_calibration(inspect: bool = True, wave_min: float = 3500.0, wave_max: float = 8500.0, display: bool = False, width: int = 1280, height: int = 720, return_jsonstring: bool = False, renderer: str = 'default', save_fig: bool = False, fig_type: str = 'iframe+png', filename: str = None, open_iframe: bool = False, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Apply the computed sensitivity curve. And resample the spectra to match the highest resolution (the smallest wavelength bin) part of the spectrum.

Note: This function directly modify the target_spectrum_oned.

Parameters:
  • inspect (bool (Default: False)) – Set to True to create/display/save figure

  • wave_min (float (Default: 3500)) – Minimum wavelength to display

  • wave_max (float (Default: 8500)) – Maximum wavelength to display

  • display (bool (Default: False)) – Set to True to display disgnostic plot.

  • renderer (string (Default: 'default')) – plotly renderer options.

  • width (int/float (Default: 1280)) – Number of pixels in the horizontal direction of the outputs

  • height (int/float (Default: 720)) – Number of pixels in the vertical direction of the outputs

  • return_jsonstring (bool (Default: False)) – set to True to return json string that can be rendered by Plotly in any support language.

  • save_fig (bool (default: False)) – Save an image if set to True. Plotly uses the pio.write_html() or pio.write_image(). The support format types should be provided in fig_type.

  • fig_type (string (default: 'iframe+png')) – Image type to be saved, choose from: jpg, png, svg, pdf and iframe. Delimiter is ‘+’.

  • filename (str (Default: None)) – Filename for the output, all of them will share the same name but will have different extension.

  • open_iframe (bool (Default: False)) – Open the iframe in the default browser if set to True.

  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

apply_telluric_correction(factor: float = None, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Apply the telluric correction with the extra multiplier ‘factor’. The ‘factor’ provided in the profile() is propagated to this function, it has to be explicitly provided to this function.

The telluric absorption profile is normalised to 1 at the most absorpted wavelegnth, the factor manually provided can be negative in case of over/under-subtraction.

Parameters:
  • factor (float (Default: None)) – The extra fudge factor multiplied to the telluric profile to manally adjust the strength.

  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

apply_wavelength_calibration(spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Apply the wavelength calibration.

Parameters:
  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str or None (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

clear_atlas(spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Remove all the atlas lines from the calibrator.

Parameters:
  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

create_fits(output: str = '*', recreate: bool = True, empty_primary_hdu: bool = True, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Create a HDU list, with a choice of any combination of the data, see below the ‘output’ parameters for details.

Parameters:

output (String) –

(Default: ‘*’) Type of data to be saved, the order is fixed (in the order of the following description), but the options are flexible. The input strings are delimited by “+”,

trace: 2 HDUs

Trace, and trace width (pixel)

count: 3 HDUs

Count, uncertainty, and sky (pixel)

weight_map: 1 HDU

Weight (pixel)

arc_spec: 1 HDU

1D arc spectrum

arc_lines: 2 HDUs

arc line position (pixel), and arc line effective position (pixel)

wavecal_coefficients: 1 HDU

Polynomial coefficients for wavelength calibration

wavelength: 1 HDU

Wavelength of each pixel

wavelength_resampled: 1 HDU

Wavelength of each resampled position

count_resampled: 3 HDUs

Resampled Count, uncertainty, and sky (wavelength)

sensitivity: 1 HDU

Sensitivity (pixel)

flux: 3 HDUs

Flux, uncertainty, and sky (pixel)

atm_ext: 1 HDU

Atmospheric extinction correction factor

flux_atm_ext_corrected: 3 HDUs

Atmospheric extinction corrected flux, uncertainty, and sky (pixel)

telluric_profile: 1 HDU

Telluric absorption profile

flux_telluric_corrected: 3 HDUs

Telluric corrected flux, uncertainty, and sky (pixel)

flux_atm_ext_telluric_corrected: 3 HDUs

Atmospheric extinction and telluric corrected flux, uncertainty, and sky (pixel)

sensitivity_resampled: 1 HDU

Sensitivity (wavelength)

flux_resampled: 4 HDUs

Flux, uncertainty, and sky (wavelength)

atm_ext_resampled: 1 HDU

Atmospheric extinction correction factor

flux_resampled_atm_ext_corrected: 3 HDUs

Atmospheric extinction corrected flux, uncertainty, and sky (wavelength)

telluric_profile_resampled: 1 HDU

Telluric absorption profile

flux_resampled_telluic_corrected: 3 HDUs

Telluric corrected flux, uncertainty, and sky (wavelength)

flux_resampled_atm_ext_telluric_corrected: 3 HDUs

Atmospheric extinction and telluric corrected flux, uncertainty, and sky (wavelength)

recreate: bool (Default: True)

Set to True to overwrite the FITS data and header.

empty_primary_hdu: bool (Default: True)

Set to True to leave the Primary HDU blank

spec_id: int or None (Default: None)

The ID corresponding to the spectrum_oned object

stype: str (Default: ‘science+standard’)

‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

do_hough_transform(brute_force: bool = False, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

** brute_force is EXPERIMENTAL as of 1 Oct 2021 ** The brute force method is supposed to provide all the possible solution, hence given a sufficiently large max_tries, the solution should always be the best possible outcome. However, it does not seem to work in a small fraction of our tests. Use with caution, and it is not the recommended way for now.

Parameters:
  • brute_force (bool (Default: False)) – Set to true to compute the gradient and intercept between every two data points

  • spec_id (int (Default: 0)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

find_arc_lines(prominence: float = 5.0, top_n_peaks: int = None, distance: float = 5.0, refine: bool = False, refine_window_width: int = 5, display: bool = False, width: int = 1280, height: int = 720, return_jsonstring: bool = False, renderer: str = 'default', save_fig: bool = False, fig_type: str = 'iframe+png', filename: str = None, open_iframe: bool = False, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]
Parameters:
  • background (int or None (Default: None)) – User-supplied estimated background level

  • percentile (float (Default: 2.)) – The percentile of the flux to be used as the estimate of the background sky level to the first order. Only used if background is None. [Count]

  • prominence (float (Default: 5.)) – The minimum prominence to be considered as a peak (normalised)

  • distance (float (Default: 5.)) – Minimum separation between peaks

  • refine (bool (Default: True)) – Set to true to fit a gaussian to get the peak at sub-pixel precision

  • refine_window_width (int or float (Default: 5)) – The number of pixels (on each side of the existing peaks) to be fitted with gaussian profiles over.

  • display (bool (Default: False)) – Set to True to display disgnostic plot.

  • renderer (str (Default: 'default')) – plotly renderer options.

  • width (int/float (Default: 1280)) – Number of pixels in the horizontal direction of the outputs

  • height (int/float (Default: 720)) – Number of pixels in the vertical direction of the outputs

  • return_jsonstring (bool (Default: False)) – set to True to return JSON-string that can be rendered by Plotly in any support language.

  • renderer – plotly renderer options.

  • save_fig (bool (default: False)) – Save an image if set to True. Plotly uses the pio.write_html() or pio.write_image(). The support format types should be provided in fig_type.

  • fig_type (string (default: 'iframe+png')) – Image type to be saved, choose from: jpg, png, svg, pdf and iframe. Delimiter is ‘+’.

  • filename (str or None (Default: None)) – Filename for the output, all of them will share the same name but will have different extension.

  • open_iframe (bool (Default: False)) – Open the iframe in the default browser if set to True.

  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

Return type:

JSON strings if return_jsonstring is set to True

fit(max_tries: int = 5000, fit_deg: int = 4, fit_coeff: list | numpy.ndarray = None, fit_tolerance: float = 10.0, fit_type: str = 'poly', candidate_tolerance: float = 2.0, brute_force: bool = False, progress: bool = True, return_solution: bool = False, display: bool = False, renderer: str = 'default', save_fig: bool = False, fig_type: str = 'iframe+png', filename: str = None, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

A wrapper function to perform wavelength calibration with RASCAL. As of 14 January 2020, it supports He, Ne, Ar, Cu, Kr, Cd, Xe, Hg and Th from NIST.

Parameters:
  • max_tries (int) – Number of trials of polynomial fitting.

  • fit_deg (int (Default: 4)) – The degree of the polynomial to be fitted.

  • fit_coeff (list (Default: None)) – NOT CURRENTLY USED, as of 17 Jan 2021 Set the baseline of the least square fit. If no fits outform this set of polynomial coefficients, this will be used as the best fit.

  • fit_tolerance (float (Default: 10)) – Sets a tolerance on whether a fit found by RANSAC is considered acceptable.

  • fit_type (string (Default: 'poly')) – One of ‘poly’, ‘legendre’ or ‘chebyshev’.

  • candidate_tolerance (float (default: 2.0)) – toleranceold (Angstroms) for considering a point to be an inlier

  • brute_force (bool (Default: False)) – Set to True to try all possible combination in the given parameter space.

  • progress (bool (Default: True)) – Set to show the progress using tdqm (if imported).

  • return_jsonstring ((default: False)) – Set to True to save the plotly figure as json string.

  • display (bool (Default: False)) – Set to show diagnostic plot.

  • renderer (str (Default: 'default')) – plotly renderer options.

  • save_fig (string (Default: False)) – Set to save figure.

  • fig_type (string (default: 'iframe+png')) – Image type to be saved, choose from: jpg, png, svg, pdf and iframe. Delimiter is ‘+’.

  • filename (str or None (Default: None)) – Filename for the output, all of them will share the same name but will have different extension.

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

from_fits(fits_file: str | astropy.io.fits.hdu.hdulist.HDUList, spec_id: int = 0, stype: str = 'science')[source]

To add a FITS files/object saved from a TwoDSpec object to provide the trace, line spread function of the trace, optionally the pixel values correcponding to the trace. The arc_spec will be imported if available. Note that TwoDSpec exports each trace as a separate file.

Parameters:
  • fits (FITS filepath/object) – A FITS HDUList containining the trace, trace_sigma, and optionally the weight_map and arc_spec.

  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object, If not given, it will assign the smallest positive integer that is not taken.

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

from_twodspec(twodspec: TwoDSpec, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

To add a TwoDSpec object or numpy array to provide the traces, line spread function of the traces, optionally the pixel values correcponding to the traces. The arc_spec will be imported if available.

Parameters:
  • twodspec (TwoDSpec object) – TwoDSpec containing the trace and trace_sigma.

  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

get_count_continuum(spec_id: int | list | numpy.ndarray = None, method: str = 'lowess', stype: str = 'science+standard', **kwargs: dict)[source]

** fit_generic_continuum is EXPERIMENTAL, as of 23 May 2023 **

Get the continnum from the wave, count and flux.

Parameters:
  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

  • method (str) – “lowess” or “fit”. The former uses the lowess function from statsmodels. The latter fits with specutil’s fit_generic_continuum.

  • **kwargs (dictionary) – The keyword arguments for the lowess function or the fit_generic_continuum function.

get_flux_continuum(spec_id: int | list | numpy.ndarray = None, method: str = 'lowess', stype: str = 'science+standard', **kwargs: dict)[source]

** fit_generic_continuum is EXPERIMENTAL, as of 23 May 2023 **

Get the continnum from the wave, count and flux.

Parameters:
  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

  • method (str) – “lowess” or “fit”. The former uses the lowess function from statsmodels. The latter fits with specutil’s fit_generic_continuum.

  • **kwargs (dictionary) – The keyword arguments for the lowess function or the fit_generic_continuum function.

get_pix_wave_pairs(spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Return the list of matched_peaks and matched_atlas with their position in the array.

Parameters:
  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

Returns:

pw_pairs – Dictionary of ‘science’ and/or ‘standard’ where the values are lists of tuples each containing the array position, peak (pixel) and atlas (wavelength) in the order of the given spec_id.

Return type:

dictionary

get_sensitivity(k: int = 3, method: str = 'interpolate', mask_range: list = [[6850, 6960], [7580, 7700]], mask_fit_order: int = 1, mask_fit_size: int = 5, smooth: bool = True, return_function: bool = False, sens_deg: int = 7, use_continuum: bool = False, **kwargs)[source]
Parameters:
  • k (integer [1,2,3,4,5 only]) – The order of the spline.

  • method (str (Default: 'interpolate')) – This should be either ‘interpolate’ of ‘polynomial’. Note that the polynomial is computed from the interpolated function. The default is interpolate because it is much more stable at the wavelength limits of a spectrum in an automated system.

  • mask_range (None or list of list) – (Default: 6850-6960, 7575-7700, 8925-9050) Masking out regions not suitable for fitting the sensitivity curve. None for no mask. List of list has the pattern [[min1, max1], [min2, max2],…]

  • mask_fit_order (int (Default: 1)) – Order of polynomial to be fitted over the masked regions

  • mask_fit_size (int (Default: 5)) – Number of “pixels” to be fitted on each side of the masked regions.

  • smooth (bool (Default: True)) – set to smooth the input spectrum with a lowess function with statsmodels

  • return_function (bool (Default: False)) – Set to True to return the callable function of the sensitivity curve.

  • sens_deg (int (Default: 7)) – The degree of polynomial of the sensitivity curve, only used if the method is ‘polynomial’.

  • use_continuum (bool (Default: False)) – Set to True to use continuum for finding the sensitivity function. If used, the smoothing filter will be applied on the continuum.

  • **kwargs – keyword arguments for passing to the LOWESS function for getting the continuum, see statsmodels.nonparametric.smoothers_lowess.lowess()

get_telluric_profile(spec_id: int | list | numpy.ndarray = None, mask_range: list = [[6850, 6960], [7580, 7700]], use_continuum: bool = False, return_function: bool = False)[source]

Getting the Telluric absorption profile from the continuum of the standard star spectrum.

Parameters:
  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

  • mask_range (list of list) – list of lists with 2 values indicating the range marked by each of the Telluric regions.

  • return_function (bool (Default: False)) – Set to True to explicitly return the interpolated function of the Telluric profile.

get_telluric_strength(factor: float = 1.0, auto_apply: bool = False, spec_id: int | list | numpy.ndarray = None, *args: str)[source]

Get the telluric absorption profile from the standard star based on the masked regions given in generating the sensitivity curve. Note that the profile has a “positive” flux so that in the step of applying a correction, a POSITIVE constant is found to multiply with the normalised telluric profile before ADDING to the spectrum for telluric absorption correction (counter-intuitive to the term telluric absorption subtraction).

Parameters:
  • factor (float (Default: 1.0)) – The extra fudge factor multiplied to the telluric profile to manally adjust the strength.

  • auto_apply (bool (Default: False)) – Set to True to accept the computed telluric absorption correction automatically, which is currently an irresversible process through the public API.

  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

initialise_calibrator(peaks: list | numpy.ndarray = None, arc_spec: list | numpy.ndarray = None, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

If the peaks were found with find_arc_lines(), peaks and spectrum can be None.

Parameters:
  • peaks (list, numpy.ndarray or None (Default: None)) – The pixel values of the peaks (start from zero)

  • spectrum (list, numpy.ndarray or None (Default: None)) – The spectral intensity as a function of pixel.

  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

inspect_arc_lines(display: bool = True, width: int = 1280, height: int = 720, return_jsonstring: bool = False, renderer: str = 'default', save_fig: bool = False, fig_type: str = 'iframe+png', filename: str = None, open_iframe: bool = False, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]
Parameters:
  • display (bool (Default: False)) – Set to True to display disgnostic plot.

  • renderer (str (Default: 'default')) – plotly renderer options.

  • width (int/float (Default: 1280)) – Number of pixels in the horizontal direction of the outputs

  • height (int/float (Default: 720)) – Number of pixels in the vertical direction of the outputs

  • return_jsonstring (bool (Default: False)) – set to True to return JSON-string that can be rendered by Plotly in any support language.

  • renderer – plotly renderer options.

  • save_fig (bool (default: False)) – Save an image if set to True. Plotly uses the pio.write_html() or pio.write_image(). The support format types should be provided in fig_type.

  • fig_type (string (default: 'iframe+png')) – Image type to be saved, choose from: jpg, png, svg, pdf and iframe. Delimiter is ‘+’.

  • filename (str or None (Default: None)) – Filename for the output, all of them will share the same name but will have different extension.

  • open_iframe (bool (Default: False)) – Open the iframe in the default browser if set to True.

  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

Return type:

JSON strings if return_jsonstring is set to True

inspect_reduced_spectrum(wave_min: float = 3500.0, wave_max: float = 8500.0, atm_ext_corrected: bool = True, telluric_corrected: bool = True, display: bool = True, width: int = 1280, height: int = 720, renderer: str = 'default', save_fig: bool = False, fig_type: str = 'iframe+png', filename: str = None, open_iframe: bool = False, return_jsonstring: bool = False, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]
Parameters:
  • wave_min (float (Default: 3500.)) – Minimum wavelength to display

  • wave_max (float (Default: 8500.)) – Maximum wavelength to display

  • atm_ext_corrected (bool (Default: True)) – Set to True to use the atmospheric extinction corrected spectrum (if available).

  • telluric_corrected (bool (Default: True)) – Set to True to use the telluric corrected spectrum (if available).

  • display (bool (Default: True)) – Set to True to display disgnostic plot.

  • renderer (str (Default: 'default')) – plotly renderer options.

  • width (int/float (Default: 1280)) – Number of pixels in the horizontal direction of the outputs

  • height (int/float (Default: 720)) – Number of pixels in the vertical direction of the outputs

  • save_fig (bool (default: False)) – Save an image if set to True. Plotly uses the pio.write_html() or pio.write_image(). The support format types should be provided in fig_type.

  • fig_type (string (default: 'iframe+png')) – Image type to be saved, choose from: jpg, png, svg, pdf and iframe. Delimiter is ‘+’.

  • filename (str or None (Default: None)) – Filename for the output, all of them will share the same name but will have different extension.

  • open_iframe (bool (Default: False)) – Open the iframe in the default browser if set to True.

  • return_jsonstring (bool (Default: False)) – set to True to return JSON-string that can be rendered by Plotly in any support language.

  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

inspect_sensitivity(display: bool = True, width: int = 1280, height: int = 720, return_jsonstring: bool = False, renderer: str = 'default', save_fig: bool = False, fig_type: str = 'iframe+png', filename: str = None, open_iframe: bool = False)[source]
Parameters:
  • display (bool (Default: True)) – Set to True to display disgnostic plot.

  • renderer (str (Default: 'default')) – plotly renderer options.

  • width (int/float (Default: 1280)) – Number of pixels in the horizontal direction of the outputs

  • height (int/float (Default: 720)) – Number of pixels in the vertical direction of the outputs

  • return_jsonstring (bool (Default: False)) – set to True to return json str that can be rendered by Plotly in any support language.

  • save_fig (bool (default: False)) – Save an image if set to True. Plotly uses the pio.write_html() or pio.write_image(). The support format types should be provided in fig_type.

  • fig_type (string (default: 'iframe+png')) – Image type to be saved, choose from: jpg, png, svg, pdf and iframe. Delimiter is ‘+’.

  • filename (str or None (Default: None)) – Filename for the output, all of them will share the same name but will have different extension.

  • open_iframe (bool (Default: False)) – Open the iframe in the default browser if set to True.

inspect_standard(display: bool = True, width: int = 1280, height: int = 720, return_jsonstring: bool = False, renderer: str = 'default', save_fig: bool = False, fig_type: str = 'iframe+png', filename: str = None, open_iframe: bool = False)[source]
Parameters:
  • display (bool (Default: True)) – Set to True to display disgnostic plot.

  • renderer (str (Default: 'default')) – plotly renderer options.

  • width (int/float (Default: 1280)) – Number of pixels in the horizontal direction of the outputs

  • height (int/float (Default: 720)) – Number of pixels in the vertical direction of the outputs

  • return_jsonstring (bool (Default: False)) – set to True to return json str that can be rendered by Plotly in any support language.

  • save_fig (bool (default: False)) – Save an image if set to True. Plotly uses the pio.write_html() or pio.write_image(). The support format types should be provided in fig_type.

  • fig_type (string (default: 'iframe+png')) – Image type to be saved, choose from: jpg, png, svg, pdf and iframe. Delimiter is ‘+’.

  • filename (str or None (Default: None)) – Filename for the output, all of them will share the same name but will have different extension.

  • open_iframe (bool (Default: False)) – Open the iframe in the default browser if set to True.

Return type:

JSON strings if return_jsonstring is set to True.

inspect_telluric_correction(factor: float = 1.0, display: bool = True, width: int = 1280, height: int = 720, return_jsonstring: bool = False, renderer: str = 'default', save_fig: bool = False, fig_type: str = 'iframe+png', filename: str = None, open_iframe: bool = False, spec_id: int | list | numpy.ndarray = None)[source]

Inspect the Telluric absorption correction on top of the spectra. This does NOT apply the correction to the spectrum. This is for inspection and manually modifying an extrac multiplier (fnudge factor) to the absorption strength.

Parameters:
  • factor (float (Default: 1.0)) – The extra fudge factor multiplied to the telluric profile to manally adjust the strength.

  • display (bool (Default: True)) – Set to True to display disgnostic plot.

  • renderer (string (Default: 'default')) – plotly renderer options.

  • width (int/float (Default: 1280)) – Number of pixels in the horizontal direction of the outputs

  • height (int/float (Default: 720)) – Number of pixels in the vertical direction of the outputs

  • return_jsonstring (bool (Default: False)) – set to True to return json string that can be rendered by Plotly in any support language.

  • save_fig (bool (default: False)) – Save an image if set to True. Plotly uses the pio.write_html() or pio.write_image(). The support format types should be provided in fig_type.

  • fig_type (string (default: 'iframe+png')) – Image type to be saved, choose from: jpg, png, svg, pdf and iframe. Delimiter is ‘+’.

  • filename (str (Default: None)) – Filename for the output, all of them will share the same name but will have different extension.

  • open_iframe (bool (Default: False)) – Open the iframe in the default browser if set to True.

  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

Return type:

JSON strings if return_jsonstring is set to True.

inspect_telluric_profile(display: bool = True, width: int = 1280, height: int = 720, return_jsonstring: bool = False, renderer: str = 'default', save_fig: bool = False, fig_type: str = 'iframe+png', filename: str = None, open_iframe: bool = False)[source]

Display the Telluric profile.

Parameters:
  • display (bool (Default: True)) – Set to True to display disgnostic plot.

  • renderer (string (Default: 'default')) – plotly renderer options.

  • width (int/float (Default: 1280)) – Number of pixels in the horizontal direction of the outputs

  • height (int/float (Default: 720)) – Number of pixels in the vertical direction of the outputs

  • return_jsonstring (bool (Default: False)) – set to True to return json string that can be rendered by Plotly in any support language.

  • save_fig (bool (default: False)) – Save an image if set to True. Plotly uses the pio.write_html() or pio.write_image(). The support format types should be provided in fig_type.

  • fig_type (string (default: 'iframe+png')) – Image type to be saved, choose from: jpg, png, svg, pdf and iframe. Delimiter is ‘+’.

  • filename (str (Default: None)) – Filename for the output, all of them will share the same name but will have different extension.

  • open_iframe (bool (Default: False)) – Open the iframe in the default browser if set to True.

Return type:

JSON strings if return_jsonstring is set to True.

list_atlas(spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Remove all the atlas lines from the calibrator.

Parameters:
  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

load_standard(target: str, library: str = None, ftype: str = 'flux', cutoff: float = 0.4)[source]

Read the standard flux/magnitude file. And return the wavelength and flux/mag. The units of the data are always in

wavelength: A
flux: ergs / cm / cm / s / A
mag: mag (AB)
Parameters:
  • target (string) – Name of the standard star

  • library (string (Default: None)) – Name of the library of standard star

  • ftype (string (Default: 'flux')) – ‘flux’ or ‘mag’

  • cutoff (float (Default: 0.4)) – The toleranceold for the word similarity in the range of [0, 1].

lookup_standard_libraries(target: str, cutoff: float = 0.4)[source]
Parameters:
  • target (str) – Name of the standard star

  • cutoff (float (Default: 0.4)) – The similarity tolerance [0=completely different, 1=identical]

manual_refit(matched_peaks: list | numpy.ndarray = None, matched_atlas: list | numpy.ndarray = None, degree: int = None, x0: float = None, return_solution: bool = False, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Perform a refinement of the matched peaks and atlas lines.

This function takes lists of matched peaks and atlases, along with user-specified lists of lines to add/remove from the lists.

Any given peaks or atlas lines to remove are selected within a user-specified tolerance, by default 1 pixel and 5 atlas Angstrom.

The final set of matching peaks/lines is then matched using a robust polyfit of the desired degree. Optionally, an initial fit x0 can be provided to condition the optimiser.

The parameters are identical in the format in the fit() and match_peaks() functions, however, with manual changes to the lists of peaks and atlas, peak_utilisation and atlas_utilisation are meaningless so this function does not return in the same format.

Parameters:
  • matched_peaks (list (Default: None)) – List of matched peaks

  • matched_atlas (list (Default: None)) – List of matched atlas lines

  • degree (int (Default: None)) – Polynomial fit degree (Only used if x0 is None)

  • x0 (list (Default: None)) – Initial fit coefficients

  • return_solution (bool (Default: False)) – Set to True to return the best fit polynomial coefficients.

  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_arc_lines_header(idx: int, method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the arc lines header.

Parameters:
  • idx (int) – The HDU number of the arc lines FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_arc_spec_header(idx: int, method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the arc spectrum header.

Parameters:
  • idx (int) – The HDU number of the arc spectrum FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_atm_ext_header(method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the atmospheric extinction factor header.

Parameters:
  • idx (int) – The HDU number of the sensitivity FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_atm_ext_resampled_header(method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the resampled atmospheric extinction factor header.

Parameters:
  • idx (int) – The HDU number of the resampled atmospheric extinction FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_count_header(idx: int, method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the count header.

Parameters:
  • idx (int) – The HDU number of the trace FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_count_resampled_header(idx: int, method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the count resampled header.

Parameters:
  • idx (int) – The HDU number of the count resampled FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_flux_atm_ext_corrected_header(idx: int, method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the flux_atm_ext_corrected header.

Parameters:
  • idx (int) – The HDU number of the flux FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_flux_atm_ext_telluric_corrected_header(idx: int, method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the flux_atm_ext_telluric_corrected header.

Parameters:
  • idx (int) – The HDU number of the flux FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_flux_header(idx: int, method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the flux header.

Parameters:
  • idx (int) – The HDU number of the flux FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_flux_resampled_atm_ext_corrected_header(idx: int, method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the atmospheric extinction corrected flux resampled header.

Parameters:
  • idx (int) – The HDU number of the flux resampled FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_flux_resampled_atm_ext_telluric_corrected_header(idx: int, method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the telluric absorption corrected flux resampled header.

Parameters:
  • idx (int) – The HDU number of the flux resampled FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_flux_resampled_header(idx: int, method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the flux resampled header.

Parameters:
  • idx (int) – The HDU number of the flux resampled FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_flux_resampled_telluric_corrected_header(idx: int, method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the telluric absorption corrected flux resampled header.

Parameters:
  • idx (int) – The HDU number of the flux resampled FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_flux_telluric_corrected_header(idx: int, method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the flux_atm_ext_corrected header.

Parameters:
  • idx (int) – The HDU number of the flux FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_sensitivity_header(method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the sensitivity header.

Parameters:
  • idx (int) – The HDU number of the sensitivity FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_sensitivity_resampled_header(method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the sensitivity resampled header.

Parameters:
  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_telluric_profile_header(method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the telluric_profile header.

Parameters:
  • idx (int) – The HDU number of the telluric_profile FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_telluric_profile_resampled_header(method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the resampled telluric profile header.

Parameters:
  • idx (int) – The HDU number of the telluric_profile FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_trace_header(idx: int, method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the trace header.

Parameters:
  • idx (int) – The HDU number of the trace FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_wavecal_header(idx: int, method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the wavecal header.

Parameters:
  • idx (int) – The HDU number of the wavecal FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_wavelength_header(method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the wavelength header.

Parameters:
  • idx (int) – The HDU number of the wavelength FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_wavelength_resampled_header(method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the wavelength_resampled header.

Parameters:
  • idx (int) – The HDU number of the wavelength_resampled FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

modify_weight_map_header(idx: int, method: str, *args: str, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Wrapper function to modify the weight map header.

Parameters:
  • idx (int) – The HDU number of the weight map FITS

  • method (str) – The operation to modify the header with

  • *args – Extra arguments for the method

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

plot_search_space(fit_coeff: list | numpy.ndarray = None, top_n_candidate: int = 3, weighted: bool = True, save_fig: bool = False, fig_type: str = 'iframe+png', filename: str = None, return_jsonstring: bool = False, renderer: str = 'default', display: bool = False, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

A wrapper function to plot the search space in the Hough space.

If fit fit_coefficients are provided, the model solution will be overplotted.

Parameters:
  • fit_coeff (list (default: None)) – List of best polynomial fit_coefficients

  • top_n_candidate (int (default: 3)) – Top ranked lines to be fitted.

  • weighted ((default: True)) – Draw sample based on the distance from the matched known wavelength of the atlas.

  • save_fig (boolean (default: False)) – Save an image if set to True. matplotlib uses the pyplot.save_fig() while the plotly uses the pio.write_html() or pio.write_image(). The support format types should be provided in fig_type.

  • fig_type (string (default: 'png')) – Image type to be saved, choose from: jpg, png, svg, pdf and iframe. Delimiter is ‘+’.

  • filename ((default: None)) – The destination to save the image.

  • return_jsonstring ((default: False)) – Set to True to save the plotly figure as json string. Ignored if matplotlib is used.

  • renderer ((default: 'default')) – Set the rendered for the plotly display. Ignored if matplotlib is used.

  • display (boolean (Default: False)) – Set to True to display disgnostic plot.

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

remove_atlas_lines_range(wavelength: list | numpy.ndarray, tolerance: float = 10.0, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Remove arc lines within a certain wavelength range.

Parameters:
  • wavelength (float) – Wavelength to remove (Angstrom)

  • tolerance (float (Default: 10.)) – Tolerance around this wavelength where atlas lines will be removed

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

remove_pix_wave_pair(arg: int, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Remove fitted pixel-wavelength pair from the Calibrator for refitting. The positions can be found from get_pix_wave_pairs(). One at a time.

Parameters:
  • arg (int) – The position of the pairs in the arrays.

  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

resample(wave_start: float = None, wave_end: float = None, wave_bin: int = None, stype: str = 'science+standard', spec_id: int | list | numpy.ndarray = None)[source]
Parameters:
  • wave_min (None (Default to the minimum fitted wavlength)) – Minimum wavelength to display

  • wave_max (None (Default to the maximum fitted wavlength)) – Maximum wavelength to display

  • wave_bin (None (Deafult to median of the wavelength bin size)) – Provide the resampling bin size

  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str or None (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

robust_refit(fit_coeff: list | numpy.ndarray = None, n_delta: int = None, refine: bool = False, tolerance: float = 10.0, method: str = 'Nelder-Mead', convergence: float = 1e-06, robust_refit: bool = True, fit_deg: int = None, return_solution: bool = False, display: bool = False, renderer: str = 'default', save_fig: bool = False, filename: str = None, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

** EXPERIMENTAL, as of 1 October 2021 ** Refine the fitted solution with a minimisation method as provided by scipy.optimize.minimize().

Parameters:
  • fit_coeff (list or None (Default: None)) – List of polynomial fit coefficients.

  • n_delta (int (Default: None)) – The number of the highest polynomial order to be adjusted

  • refine (bool (Default: True)) – Set to True to refine solution.

  • tolerance (float (Default: 10.)) – Absolute difference between fit and model in the unit of nm.

  • method (str (Default: 'Nelder-Mead')) – scipy.optimize.minimize method.

  • convergence (float (Default: 1e-6)) – scipy.optimize.minimize tol.

  • robust_refit (bool (Default: True)) – Set to True to fit all the detected peaks with the given polynomial solution.

  • fit_deg (int (Default: length of the input coefficients - 1)) – Order of polynomial fit with all the detected peaks.

  • return_solution (bool (Default: True)) – Set to True to return the best fit polynomial coefficients.

  • display (bool (Default: False)) – Set to show diagnostic plot.

  • renderer (str (Default: 'default')) – plotly renderer options.

  • save_fig (bool (Default: False)) – Set to save figure.

  • filename (str or None (Default: None)) – Filename for the output, all of them will share the same name but will have different extension.

  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

save_csv(output: str = '*', filename: str = 'reduced', recreate: bool = False, overwrite: bool = False, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Save the reduced data to disk, with a choice of any combination of the 5 sets of data, see below the ‘output’ parameters for details.

Parameters:
  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

  • output (String) –

    (Default: ‘*’) Type of data to be saved, the order is fixed (in the order of the following description), but the options are flexible. The input strings are delimited by “+”,

    trace: 2 HDUs

    Trace, and trace width (pixel)

    count: 3 HDUs

    Count, uncertainty, and sky (pixel)

    weight_map: 1 HDU

    Weight (pixel)

    arc_spec: 1 HDU

    1D arc spectrum

    arc_lines: 2 HDUs

    arc line position (pixel), and arc line effective position (pixel)

    wavecal_coefficients: 1 HDU

    Polynomial coefficients for wavelength calibration

    wavelength: 1 HDU

    Wavelength of each pixel

    wavelength_resampled: 1 HDU

    Wavelength of each resampled position

    count_resampled: 3 HDUs

    Resampled Count, uncertainty, and sky (wavelength)

    sensitivity: 1 HDU

    Sensitivity (pixel)

    flux: 3 HDUs

    Flux, uncertainty, and sky (pixel)

    atm_ext: 1 HDU

    Atmospheric extinction correction factor

    flux_atm_ext_corrected: 3 HDUs

    Atmospheric extinction corrected flux, uncertainty, and sky (pixel)

    telluric_profile: 1 HDU

    Telluric absorption profile

    flux_telluric_corrected: 3 HDUs

    Telluric corrected flux, uncertainty, and sky (pixel)

    flux_atm_ext_telluric_corrected: 3 HDUs

    Atmospheric extinction and telluric corrected flux, uncertainty, and sky (pixel)

    sensitivity_resampled: 1 HDU

    Sensitivity (wavelength)

    flux_resampled: 4 HDUs

    Flux, uncertainty, and sky (wavelength)

    atm_ext_resampled: 1 HDU

    Atmospheric extinction correction factor

    flux_resampled_atm_ext_corrected: 3 HDUs

    Atmospheric extinction corrected flux, uncertainty, and sky (wavelength)

    telluric_profile_resampled: 1 HDU

    Telluric absorption profile

    flux_resampled_telluic_corrected: 3 HDUs

    Telluric corrected flux, uncertainty, and sky (wavelength)

    flux_resampled_atm_ext_telluric_corrected: 3 HDUs

    Atmospheric extinction and telluric corrected flux, uncertainty, and sky (wavelength)

  • filename (String (Default: 'reduced')) – Disk location to be written to. Default is at where the process/subprocess is execuated.

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

  • recreate (bool (Default: False)) – Set to True to overwrite the FITS data and header.

  • overwrite (bool (Default: False)) – Default is False.

save_fits(output: str = '*', filename: str = 'reduced', recreate: bool = False, empty_primary_hdu: bool = True, overwrite: bool = False, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Save the reduced data to disk, with a choice of any combination of the data, see below the ‘output’ parameters for details.

Parameters:
  • output (String) –

    (Default: ‘*’) Type of data to be saved, the order is fixed (in the order of the following description), but the options are flexible. The input strings are delimited by “+”,

    trace: 2 HDUs

    Trace, and trace width (pixel)

    count: 3 HDUs

    Count, uncertainty, and sky (pixel)

    weight_map: 1 HDU

    Weight (pixel)

    arc_spec: 1 HDU

    1D arc spectrum

    arc_lines: 2 HDUs

    arc line position (pixel), and arc line effective position (pixel)

    wavecal_coefficients: 1 HDU

    Polynomial coefficients for wavelength calibration

    wavelength: 1 HDU

    Wavelength of each pixel

    wavelength_resampled: 1 HDU

    Wavelength of each resampled position

    count_resampled: 3 HDUs

    Resampled Count, uncertainty, and sky (wavelength)

    sensitivity: 1 HDU

    Sensitivity (pixel)

    flux: 3 HDUs

    Flux, uncertainty, and sky (pixel)

    atm_ext: 1 HDU

    Atmospheric extinction correction factor

    flux_atm_ext_corrected: 3 HDUs

    Atmospheric extinction corrected flux, uncertainty, and sky (pixel)

    telluric_profile: 1 HDU

    Telluric absorption profile

    flux_telluric_corrected: 3 HDUs

    Telluric corrected flux, uncertainty, and sky (pixel)

    flux_atm_ext_telluric_corrected: 3 HDUs

    Atmospheric extinction and telluric corrected flux, uncertainty, and sky (pixel)

    sensitivity_resampled: 1 HDU

    Sensitivity (wavelength)

    flux_resampled: 4 HDUs

    Flux, uncertainty, and sky (wavelength)

    atm_ext_resampled: 1 HDU

    Atmospheric extinction correction factor

    flux_resampled_atm_ext_corrected: 3 HDUs

    Atmospheric extinction corrected flux, uncertainty, and sky (wavelength)

    telluric_profile_resampled: 1 HDU

    Telluric absorption profile

    flux_resampled_telluic_corrected: 3 HDUs

    Telluric corrected flux, uncertainty, and sky (wavelength)

    flux_resampled_atm_ext_telluric_corrected: 3 HDUs

    Atmospheric extinction and telluric corrected flux, uncertainty, and sky (wavelength)

  • filename (String (Default: 'reduced')) – Disk location to be written to. Default is at where the process/subprocess is execuated.

  • recreate (bool (Default: False)) – Set to True to overwrite the FITS data and header.

  • empty_primary_hdu (bool (Default: True)) – Set to True to leave the Primary HDU blank

  • overwrite (bool (Default: False)) – Default is False.

  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

save_sensitivity_func(filename: str = 'sensitivity_func.npy')[source]

Not-implemented wrapper.

Parameters:

filename (str) – Filename for the output interpolated sensivity curve.

set_atmospheric_extinction(location: str = 'orm', extinction_func: Callable = None, kind: str = 'cubic', fill_value: str = 'extrapolate', **kwargs: dict)[source]

The ORM atmospheric extinction correction table is taken from http://www.ing.iac.es/astronomy/observing/manuals/ps/tech_notes/tn031.pdf

The MK atmospheric extinction correction table is taken from Buton et al. (2013A&A…549A…8B)

The CP atmospheric extinction correction table is taken from Patat et al. (2011A&A…527A..91P)

The LS atmospheric extinction correction table is taken from THE ESO USERS MANUAL 1993 https://www.eso.org/public/archives/techdocs/pdf/report_0003.pdf

The KP (Kitt Peak) atmospheric extinction correction table is taken from iraf

The CT (Cerro Tololo) atmospheric extinctioncorrection table is taken from iraf

Parameters:
  • location (str (Default: orm)) – Location of the observatory, currently contains: (1) orm - Roque de los Muchachos Observatory (2420 m) (2) mk - Mauna Kea (4205 m) (3) cp - Cerro Paranal (2635 m) (4) ls - La Silla (2400 m) [up to 9000A only] (5) kp - Kitt Peak (2096 m) (6) ct - Cerro Tololo (2207 m) Only used if extinction_func is None.

  • extinction_func (callable function (Default: None)) – Input wavelength in Angstrom, output magnitude of extinction per airmass. It will override the ‘location’.

set_calibrator_logger(logger_name: str = 'Calibrator', log_level: str = 'info', spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]
Parameters:
  • logger_name (str (Default: 'Calibrator')) – This will set the name of the logger, if the name is used already, it will reference to the existing logger. This will be the first part of the default log file name unless log_file_name is provided.

  • log_level (str (Default: 'info')) – Choose {critical, error, warning, info, debug, notset}.

  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

set_calibrator_properties(num_pix: int = None, effective_pixel: list | numpy.ndarray = None, plotting_library: str = 'plotly', spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]
Parameters:
  • num_pix (int (Default: None)) – The number of pixels in the dispersion direction

  • effective_pixel (list or numpy array (Default: None)) – The pixel position of the trace in the dispersion direction. This should be provided if you wish to override the default range(num_pix), for example, in the case of accounting for chip gaps (10 pixels) in a 3-CCD setting, you should provide [0,1,2,…90, 100,101,…190, 200,201,…290]

  • plotting_library (str (Default: 'plotly')) – Choose between matplotlib and plotly.

  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

set_hough_properties(num_slopes: int = 5000, xbins: int = 200, ybins: int = 200, min_wavelength: float = 3000.0, max_wavelength: float = 10000.0, range_tolerance: float = 500.0, linearity_tolerance: float = 100.0, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]
Parameters:
  • num_slopes (int (Default: 5000)) – Number of slopes to consider during Hough transform

  • xbins (int (Default: 200)) – Number of bins for Hough accumulation

  • ybins (int (Default: 200)) – Number of bins for Hough accumulation

  • min_wavelength (float (Default: 3000.)) – Minimum wavelength of the spectrum.

  • max_wavelength (float (Default: 10000.)) – Maximum wavelength of the spectrum.

  • range_tolerance (float (Default: 500)) – Estimation of the error on the provided spectral range e.g. 3000-5000 with tolerance 500 will search for solutions that may satisfy 2500-5500

  • linearity_tolerance (float (Default: 100)) – A toleranceold (Ansgtroms) which defines some padding around the range tolerance to allow for non-linearity. This should be the maximum expected excursion from linearity.

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

set_known_pairs(pix: list | numpy.ndarray = None, wave: list | numpy.ndarray = None, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]
Parameters:
  • pix (numeric value, list or numpy 1D array (N) (Default: None)) – Any pixel value, can be outside the detector chip and serve purely as anchor points.

  • wave (numeric value, list or numpy 1D array (N) (Default: None)) – The matching wavelength for each of the pix.

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter

set_ransac_properties(sample_size: int = 5, top_n_candidate: int = 5, linear: bool = True, filter_close: bool = False, ransac_tolerance: float = 5.0, candidate_weighted: bool = True, hough_weight: float = 1.0, minimum_matches: int = 3, minimum_peak_utilisation: float = 0.0, minimum_fit_error: float = 0.0001, spec_id: int | list | numpy.ndarray = None, stype: str = 'science+standard')[source]

Configure the Calibrator. This may require some manual twiddling before the calibrator can work efficiently. However, in theory, a large max_tries in fit() should provide a good solution in the expense of performance (minutes instead of seconds).

Parameters:
  • sample_size (int (Default: 5)) – Number of pixel-wavelength hough pairs to be used for each arc line being picked.

  • top_n_candidate (int (Default: 5)) – Top ranked lines to be fitted.

  • linear (bool (Default: True)) – True to use the hough transformed gradient, otherwise, use the known polynomial.

  • filter_close (bool (Default: False)) – Remove the pairs that are out of bounds in the hough space.

  • ransac_tolerance (float (Default: 5)) – The distance criteria (Angstroms) to be considered an inlier to a fit. This should be close to the size of the expected residuals on the final fit (e.g. 1A is typical)

  • candidate_weighted (bool (Default: True)) – Set to True to down-weight pairs that are far from the fit.

  • hough_weight (float or None (Default: 1.0)) – Set to use the hough space to weigh the fit. The theoretical optimal weighting is unclear. The larger the value, the heavily it relies on the overdensity in the hough space for a good fit.

  • minimum_matches (int (Default: 3)) – Minimum number of fitted peaks to accept as a solution. This has to be smaller than or equal to the sample size.

  • minimum_peak_utilisation (float (Default: 0.)) – The minimum percentage of peaks used in order to accept as a valid solution.

  • minimum_fit_error (float (Default 1e-4)) – Set to remove overfitted/unrealistic fits.

  • spec_id (int (Default: None)) – The ID corresponding to the spectrum_oned object

  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter