hispecdrp.primitives.telluric_correction.telluric_models

Functions

_convolve_and_resample(model_wavelength, ...)

Convolve a model spectrum with a Gaussian LSF and sample it at given wavelengths.

_convolve_telluric_with_gaussian_lsf(...[, ...])

Convolve telluric transmission with the LFC Gaussian LSF and sample at fiber_wave.

airmass_scale_singlemodel(input_model, ...)

Apply an airmass-scaled telluric correction to fiber's spectrum.

_convolve_and_resample(model_wavelength, model_fluxes, observed_wavelength, sigma_array, num_sigma=5, mu_array=None, offset_array=None)[source]

Convolve a model spectrum with a Gaussian LSF and sample it at given wavelengths.

For each observed wavelength channel, builds a Gaussian kernel scaled by that channel’s LSF sigma (and optionally shifted by a per-channel mu), interpolates the model spectrum onto the kernel’s wavelength support via cubic interpolation, and computes the weighted average to produce the convolved, resampled flux.

Parameters:
  • model_wavelength (array) – Model spectrum wavelengths, sorted in increasing order.

  • model_fluxes (array) – Model spectrum flux values corresponding to model_wavelength.

  • observed_wavelength (array) – Observed wavelengths at which to sample the convolved model.

  • sigma_array (array) – LSF sigma (in wavelength units) for each observed channel.

  • num_sigma (int, optional) – Half-width of the convolution kernel, in units of sigma. Default is 5.

  • mu_array (array, optional) – LSF mean offset for each observed channel. Defaults to zeros if not provided.

  • offset_array (array, optional) – Constant additive offset applied to each channel’s result after convolution. Defaults to zeros if not provided.

Returns:

convolved (array) – Convolved and resampled flux at each observed wavelength channel.

Notes

The kernel resolution is set by the finest sampling of model_wavelength within the observed wavelength range, so an impractically fine model grid combined with a wide kernel (large sigma_array.max()) can result in a very large filter_size.

_convolve_telluric_with_gaussian_lsf(telluric_wavelength, telluric_trans, fiber_wave, lsf_model, *, fiber_number, order, kernel_size_sigma=5.0)[source]

Convolve telluric transmission with the LFC Gaussian LSF and sample at fiber_wave.

Interpolates the telluric model onto a uniform wavelength grid, builds chromatic kernels with GaussianLSFModel.make_kernels(), and applies convolve_numba_1d_chromatic().

airmass_scale_singlemodel(input_model, output_model, lsf_model, fiber_number, spec_key, order_vec, do_orders, basemodel_filepath=None, dq_threshold=0.5)[source]

Apply an airmass-scaled telluric correction to fiber’s spectrum.

Loads an airmass=1, PWV=1mm telluric transmission template (or a user-supplied template), scales it to the observation’s airmass, convolves it with the fiber’s wavelength-dependent LSF and resamples it onto the observed wavelength grid for each requested order, then divides the observed spectrum (and its error) by the resulting transmission curve. Pixels where the convolved telluric transmission falls below a threshold are flagged in the data quality array.

Parameters:
  • input_model (object) – Input data model containing the observed fiber spectra, errors, wavelengths, data quality arrays, and airmass metadata (meta.airmass_start, meta.airmass_end).

  • output_model (object) – Output data model to populate with the telluric-corrected spectrum, error, data quality, and convolved telluric transmission arrays.

  • lsf_model (GaussianLSFModel) – LFC-derived Gaussian LSF with Chebyshev FWHM coefficients. Kernels are built with GaussianLSFModel.make_kernels().

  • fiber_number (int or str) – Identifier of the fiber to process, used to build attribute names (e.g. SPEC_FIB{fiber_number}).

  • spec_key (str) – Prefix used to look up the spectrum and error attributes on input_model (e.g. SPEC or SPEC_UNCAL).

  • order_vec (sequence) – Sequence of order identifiers, indexed in parallel with the spectral arrays.

  • do_orders (sequence) – Subset of order_vec entries to actually process; orders not in this set are skipped.

  • basemodel_filepath (str or Path, optional) – Path to an alternate telluric basemodel file. If None, the default packaged model (mktrans_zm_10_10.dat) is used.

  • dq_threshold (float, optional) – Transmission threshold below which pixels are flagged in the data quality array.

Returns:

output_model (object) – The output model, updated in place with attributes TEL_FIB{fiber_number}, SPEC_FIB{fiber_number}, SPEC_ERR_FIB{fiber_number}, and SPEC_DQ_FIB{fiber_number}.