OneDSpec API

class aspired.spectral_reduction.OneDSpec(verbose=True, logger_name='OneDSpec', log_level='INFO', log_file_folder='default', log_file_name=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_arc_lines(peaks, spec_id=None, stype='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: None)) – The ID corresponding to the spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
add_arc_spec(arc_spec, spec_id=None, stype='science+standard')[source]
Parameters:
  • arc_spec (1-d array) – The count of the summed 1D arc spec
  • spec_id (int (Default: None)) – The ID corresponding to the spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
add_atlas(elements, min_atlas_wavelength=3000.0, max_atlas_wavelength=10000.0, min_intensity=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=None, stype='science+standard')[source]
Parameters:
  • elements (str or list of strings) – Chemical symbol, case insensitive
  • spec_id (int (Default: None)) – The ID corresponding to the spectrum1D object
  • 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.
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
add_fit_coeff(fit_coeff, fit_type='poly', spec_id=None, stype='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: None)) – The ID corresponding to the spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
add_fluxcalibration(fluxcal)[source]

Provide the pre-calibrated FluxCalibration object.

Parameters:fluxcal (FluxCalibration object) – The true mag/flux values.
add_pix_wave_pair(pix, wave, spec_id=None, stype='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: None)) – The ID corresponding to the spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
add_science_spectrum1D(spec_id)[source]

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

Parameters:spec_id (int or None (Default: None)) – The ID corresponding to the spectrum1D object
add_sensitivity_func(sensitivity_func)[source]

Provide a callable function of the detector sensitivity response.

Parameters:
  • sensitivity_func (str) – Interpolated sensivity curve object.
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
add_spec(count, count_err=None, count_sky=None, spec_id=None, stype='science+standard')[source]
Parameters:
  • count (1-d array) – The summed count at each column about the trace.
  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum1D object
  • 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 – The ID corresponding to the spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
add_telluric_function(telluric, spec_id=None, stype='science+standard')[source]

** EXPERIMENTAL, as of 1 October 2021 **

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: None)) – The ID corresponding to the spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
add_trace(trace, trace_sigma, pixel_list=None, spec_id=None, stype='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
  • pixel_list (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: None)) – The ID corresponding to the spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
add_user_atlas(elements, wavelengths, intensities=None, candidate_tolerance=10.0, constrain_poly=False, vacuum=False, pressure=101325.0, temperature=273.15, relative_humidity=0.0, spec_id=None, stype='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)
  • spec_id (int (Default: None)) – The ID corresponding to the spectrum1D object
  • 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.
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
add_wavelength(wave, spec_id=None, stype='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: None)) – The ID corresponding to the spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
add_wavelength_resampled(wave_resampled, spec_id=None, stype='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: None)) – The ID corresponding to the spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
add_wavelengthcalibration(wavecal, spec_id=None, stype='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: None)) – The ID corresponding to the spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
apply_atmospheric_extinction_correction(science_airmass=None, standard_airmass=None, spec_id=None)[source]

** EXPERIMENTAL, as of 1 October 2021 **

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 spectrum1D object
apply_flux_calibration(inspect=False, wave_min=3500.0, wave_max=8500.0, display=False, renderer='default', width=1280, height=720, return_jsonstring=False, save_fig=False, fig_type='iframe+png', filename=None, open_iframe=False, spec_id=None, stype='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_spectrum1D.

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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
apply_telluric_correction(factor=1.0, spec_id=None, stype='science+standard')[source]

** EXPERIMENTAL, as of 1 October 2021 **

Apply the telluric correction with the extra multiplier ‘factor’. The ‘factor’ provided in the profile() is NOT 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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
apply_wavelength_calibration(wave_start=None, wave_end=None, wave_bin=None, spec_id=None, stype='science+standard')[source]

Apply the wavelength calibration. Because the polynomial fit can run away at the two ends, the default minimum and maximum are limited to 1,000 and 12,000 A, respectively. This can be overridden by providing user’s choice of wave_start and wave_end.

Parameters:
  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum1D object
  • wave_start (float or None (Default: None)) – Provide the minimum wavelength for resampling.
  • wave_end (float or None (Default: None)) – Provide the maximum wavelength for resampling
  • wave_bin (float or None (Default: None)) – Provide the resampling bin size
  • stype (str or None (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
clear_atlas(spec_id=None, stype='science+standard')[source]

Remove all the atlas lines from the calibrator.

Parameters:
  • spec_id (int (Default: None)) – The ID corresponding to the spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
create_fits(output='arc_spec+wavecal+wavelength+flux+flux_resampled', recreate=True, empty_primary_hdu=True, spec_id=None, stype='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: ‘arc_spec+wavecal+wavelength+flux+flux_resampled’) 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: 4 HDUs
    Count, uncertainty, sky, optimal flag, and weight (pixel)
    arc_spec: 3 HDUs
    1D arc spectrum, arc line pixels, and arc line effective pixels
    wavecal: 1 HDU
    Polynomial coefficients for wavelength calibration
    wavelength: 1 HDU
    Wavelength of each pixel
    count_resampled: 3 HDUs
    Resampled Count, uncertainty, and sky (wavelength)
    sensitivity: 1 HDU
    Sensitivity (pixel)
    flux: 4 HDUs
    Flux, uncertainty, sky, and sensitivity (pixel)
    sensitivity_resampled: 1 HDU
    Sensitivity (wavelength)
    flux_resampled: 4 HDUs
    Flux, uncertainty, sky, and sensitivity (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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
do_hough_transform(brute_force=False, spec_id=None, stype='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:
  • spec_id (int (Default: None)) – The ID corresponding to the spectrum1D object
  • brute_force (bool (Default: False)) – Set to true to compute the gradient and intercept between every two data points
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
find_arc_lines(prominence=5.0, top_n_peaks=None, distance=5.0, refine=False, refine_window_width=5, display=False, width=1280, height=720, return_jsonstring=False, renderer='default', save_fig=False, fig_type='iframe+png', filename=None, open_iframe=False, spec_id=None, stype='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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
Returns:

Return type:

JSON strings if return_jsonstring is set to True

fit(max_tries=5000, fit_deg=4, fit_coeff=None, fit_tolerance=10.0, fit_type='poly', candidate_tolerance=2.0, brute_force=False, progress=True, return_solution=False, display=False, renderer='default', save_fig=False, fig_type='iframe+png', filename=None, spec_id=None, stype='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 or None (Default: None)) – The ID corresponding to the spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
from_twodspec(twodspec, spec_id=None, stype='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. If the arc is provided, the saxis and flip properties of the TwoDSpec will be applied to the arc, and then the spec_mask and the spatial_mask from the TwoDSpec object will be applied.

Parameters:
  • twodspec (TwoDSpec object) – TwoDSpec of the science image containin the trace(s) and trace_sigma(s).
  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
get_continuum(spec_id=None, **kwargs)[source]

** EXPERIMENTAL, as of 1 October 2021 **

Get the continnum from the wave, count and flux.

Parameters:
  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum1D object
  • **kwargs (dictionary) – The keyword arguments to be passed to the lowess function for generating the continuum.
get_pix_wave_pairs(spec_id=None, stype='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 spectrum1D 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_resampled_continuum(spec_id=None, **kwargs)[source]

** EXPERIMENTAL, as of 1 October 2021 **

Get the continnum from the resampled wave, count and flux.

Parameters:
  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum1D object
  • **kwargs (dictionary) – The keyword arguments to be passed to the lowess function for generating the continuum.
get_sensitivity(k=3, method='interpolate', mask_range=[[6850, 6960], [7580, 7700]], mask_fit_order=1, mask_fit_size=5, smooth=False, slength=5, sorder=3, return_function=False, sens_deg=7, **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: False)) – set to smooth the input spectrum with scipy.signal.savgol_filter
  • slength (int (Default:5)) – SG-filter window size
  • sorder (int (Default: 3)) – SG-filter polynomial order
  • 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’.
  • **kwargs – keyword arguments for passing to the LOWESS function, see statsmodels.nonparametric.smoothers_lowess.lowess()
get_telluric_correction(factor=1.0, auto_apply=False, spec_id=None, **kwargs)[source]

** EXPERIMENTAL, as of 1 October 2021 **

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 spectrum1D object
get_telluric_profile(mask_range=[[6850, 6960], [7580, 7700]], return_function=False, spec_id=None)[source]

** EXPERIMENTAL, as of 1 October 2021 **

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

Parameters:
  • 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.
  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum1D object
initialise_calibrator(peaks=None, arc_spec=None, spec_id=None, stype='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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
inspect_reduced_spectrum(wave_min=3500.0, wave_max=8500.0, display=True, renderer='default', width=1280, height=720, save_fig=False, fig_type='iframe+png', filename=None, open_iframe=False, return_jsonstring=False, spec_id=None, stype='science+standard')[source]
Parameters:
  • wave_min (float (Default: 3500.)) – Minimum wavelength to display
  • wave_max (float (Default: 8500.)) – Maximum wavelength to display
  • 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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
inspect_sensitivity(display=True, renderer='default', width=1280, height=720, return_jsonstring=False, save_fig=False, fig_type='iframe+png', filename=None, open_iframe=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=True, renderer='default', width=1280, height=720, return_jsonstring=False, save_fig=False, fig_type='iframe+png', filename=None, open_iframe=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.
Returns:

Return type:

JSON strings if return_jsonstring is set to True.

inspect_telluric_correction(factor=1.0, display=True, renderer='default', width=1280, height=720, return_jsonstring=False, save_fig=False, fig_type='iframe+png', filename=None, open_iframe=False, spec_id=None)[source]

** EXPERIMENTAL, as of 1 October 2021 **

Inspect the Telluric absorption correction on top of pre-corrected spectra.

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 spectrum1D object
Returns:

Return type:

JSON strings if return_jsonstring is set to True.

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

** EXPERIMENTAL, as of 1 October 2021 **

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.
Returns:

Return type:

JSON strings if return_jsonstring is set to True.

list_atlas(spec_id=None, stype='science+standard')[source]

Remove all the atlas lines from the calibrator.

Parameters:
  • spec_id (int (Default: None)) – The ID corresponding to the spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
load_standard(target, library=None, ftype='flux', cutoff=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, cutoff=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=None, matched_atlas=None, degree=None, x0=None, return_solution=False, spec_id=None, stype='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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
modify_arc_spec_header(idx, method, *args, spec_id=None, stype='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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
modify_count_header(idx, method, *args, spec_id=None, stype='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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
modify_count_resampled_header(idx, method, *args, spec_id=None, stype='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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
modify_flux_header(idx, method, *args, spec_id=None, stype='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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
modify_flux_resampled_header(idx, method, *args, spec_id=None, stype='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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
modify_sensitivity_header(idx, method, *args, spec_id=None, stype='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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
modify_sensitivity_resampled_header(idx, method, *args, spec_id=None, stype='science+standard')[source]

Wrapper function to modify the sensitivity resampled header.

Parameters:
  • idx (int) – The HDU number of the sensitivity 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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
modify_trace_header(idx, method, *args, spec_id=None, stype='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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
modify_wavecal_header(idx, method, *args, spec_id=None, stype='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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
modify_wavelength_header(idx, method, *args, spec_id=None, stype='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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
modify_weight_map_header(idx, method, *args, spec_id=None, stype='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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
plot_search_space(fit_coeff=None, top_n_candidate=3, weighted=True, save_fig=False, fig_type='iframe+png', filename=None, return_jsonstring=False, renderer='default', display=False, spec_id=None, stype='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:
  • spec_id (int (Default: None)) – The ID corresponding to the spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
remove_atlas_lines_range(wavelength, tolerance=10.0, spec_id=None, stype='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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
remove_pix_wave_pair(arg, spec_id=None, stype='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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
robust_refit(fit_coeff=None, n_delta=None, refine=False, tolerance=10.0, method='Nelder-Mead', convergence=1e-06, robust_refit=True, fit_deg=None, return_solution=False, display=False, renderer='default', save_fig=False, filename=None, spec_id=None, stype='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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
save_csv(output='arc_spec+wavecal+wavelength+flux+flux_resampled', filename='reduced', recreate=False, overwrite=False, spec_id=None, stype='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:
  • output (String) –

    (Default: ‘arc_spec+wavecal+wavelength+flux+flux_resampled’) 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: 4 HDUs
    Count, uncertainty, sky, optimal flag, and weight (pixel)
    arc_spec: 3 HDUs
    1D arc spectrum, arc line pixels, and arc line effective pixels
    wavecal: 1 HDU
    Polynomial coefficients for wavelength calibration
    wavelength: 1 HDU
    Wavelength of each pixel
    count_resampled: 3 HDUs
    Resampled Count, uncertainty, and sky (wavelength)
    sensitivity: 1 HDU
    Sensitivity (pixel)
    flux: 3 HDUs
    Flux, uncertainty, sky, and sensitivity (pixel)
    sensitivity_resampled: 1 HDU
    Sensitivity (wavelength)
    flux_resampled: 3 HDUs
    Flux, uncertainty, sky, and sensitivity (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.
  • overwrite (bool (Default: False)) – Default is False.
  • spec_id (int or None (Default: None)) – The ID corresponding to the spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
save_fits(output='arc_spec+wavecal+wavelength+flux+flux_resampled', filename='reduced', recreate=False, empty_primary_hdu=True, overwrite=False, spec_id=None, stype='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: ‘arc_spec+wavecal+wavelength+flux+flux_resampled’) 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: 4 HDUs
    Count, uncertainty, sky, optimal flag, and weight (pixel)
    arc_spec: 3 HDUs
    1D arc spectrum, arc line pixels, and arc line effective pixels
    wavecal: 1 HDU
    Polynomial coefficients for wavelength calibration
    wavelength: 1 HDU
    Wavelength of each pixel
    count_resampled: 3 HDUs
    Resampled Count, uncertainty, and sky (wavelength)
    sensitivity: 1 HDU
    Sensitivity (pixel)
    flux: 3 HDUs
    Flux, uncertainty, and sky (pixel)
    sensitivity_resampled: 1 HDU
    Sensitivity (wavelength)
    flux_resampled: 3 HDUs
    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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
save_sensitivity_func(filename='sensitivity_func.npy')[source]

Not-implemented wrapper.

Parameters:filename (str) – Filename for the output interpolated sensivity curve.
set_atmospheric_extinction(location='orm', extinction_func=None, kind='cubic', fill_value='extrapolate', **kwargs)[source]

** EXPERIMENTAL, as of 1 October 2021 **

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

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] 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_properties(num_pix=None, pixel_list=None, plotting_library='plotly', logger_name='Calibrator', log_level='info', spec_id=None, stype='science+standard')[source]
Parameters:
  • num_pix (int (Default: None)) – The number of pixels in the dispersion direction
  • pixel_list (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.
  • 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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
set_hough_properties(num_slopes=5000, xbins=200, ybins=200, min_wavelength=3000.0, max_wavelength=10000.0, range_tolerance=500, linearity_tolerance=100, spec_id=None, stype='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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
set_known_pairs(pix=None, wave=None, spec_id=None, stype='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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter
set_ransac_properties(sample_size=5, top_n_candidate=5, linear=True, filter_close=False, ransac_tolerance=5, candidate_weighted=True, hough_weight=1.0, minimum_matches=3, minimum_peak_utilisation=0.0, minimum_fit_error=0.0001, spec_id=None, stype='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 spectrum1D object
  • stype (str (Default: 'science+standard')) – ‘science’ and/or ‘standard’ to indicate type, use ‘+’ as delimiter