mangadap.proc.rukia module

Implements a full-spectrum fitting algorithm that fits a wavelength-dependent dispersion.


License

Copyright © 2019, SDSS-IV/MaNGA Pipeline Group


class mangadap.proc.rukia.LegendrePolynomial(deg, c=None, rng=None)[source]

Bases: object

reset_range(rng)[source]
class mangadap.proc.rukia.PieceWiseLinear(deg, c=None, rng=[-1, 1])[source]

Bases: object

reset_range(rng)[source]
class mangadap.proc.rukia.Rukia(sigma_model, mul_model=None, add_model=None)[source]

Bases: object

Fit a spectrum by convolving a single template spectrum with a Gaussian kernel that has a wavelength-dependent width.

This instantiation defines up to three functional forms used to define the fitted model. The objects used to describe each functional form must have an np attribute that provides the number of parameters and it must be callable with a form:

func(x, a=a)

where func is the object, x is the coordinate vector, and a are the model parameters. For example, see LegendrePolynomial.

The total number of parameters for the fitted model is the sum of the number of parameters for each functional form, plus one additional parameter if a Doppler shift is also included in the fit (see fit_shift).

Parameters:
  • sigma_model (object) – An object that provides the parametrized form of sigma as a function of wavelength.

  • add_model (object, optional) – An object that provides the parametrized form of an additive function included in the model.

  • mul_model (object, optional) – An object that provides the parametrized form of a multiplicative function included in the model.

_add_par_slice()[source]
static _init_data(wave, flux, err, mask, sres)[source]
_init_par(shift=0.0, fit_shift=True, sigma_p0=None, sigma_f=None, add_p0=None, add_f=None, mul_p0=None, mul_f=None)[source]
_mul_par_slice()[source]
_reset_range(rng)[source]
_set_par(par)[source]

Set the parameters by accounting for any fixed parameters.

_sigma_par_slice()[source]
add_par(par=None)[source]
bitmask = <mangadap.proc.rukia.RukiaBitMask object>

Bitmask for Rukia results.

fit(wave, flux, tpl_wave, tpl_flux, err=None, mask=None, sres=None, tpl_sres=None, shift=0.0, fit_shift=True, shift_range=[-300.0, 300.0], rejiter=None, rejsig=3.0, rejbox=101, sigma_p0=None, sigma_f=None, add_p0=None, add_f=None, mul_p0=None, mul_f=None, rng=None)[source]

Fit the spectrum.

If err is provided:
  • the fit figure-of-merit is chi-square

  • rejections are based on error-normalized residuals

Otherwise:
  • the fit figure-of-merit is the fit RMS

  • rejections are based on un-normalized residuals.

Parameters:
  • shift (float, optional) –

    The Doppler (multiplicative) shift between the input spectrum wavelengths and the template wavelengths; i.e., this is \(z\) is the Doppler shift such that the best match in the spectra is achieved when the wavelengths of the spectrum to fit are

    \[\lambda = (1+z) \lambda_{\rm tpl}.\]

    If fit_shift is False, this shift is fixed during the fit; otherwise, it is included as a fitted model parameter and the provided value is used as an initial guess.

  • fit_shift (bool, optional) – In addition to the broadening, fit a Doppler (i.e., multiplicative) shift between the template and target wavelengths.

fitting_range(wave, tpl_wave, shift=None, shift_range=None, rng=None)[source]
property has_template
model(par, wave=None, tpl_wave=None, tpl_flux=None, rng=None, pixel_sigma_bounds=[0.01, 100])[source]

Construct the model spectrum.

Parameters:
  • par (numpy.ndarray) – List of model parameters. Shape must be \((N_{\rm par},)\) or the number of free parameters (see free).

  • wave (numpy.ndarray, optional) – The wavelength vector on which to construct the model. If not provided, the wavelengths for the model must have already been defined for this instance, e.g., via a fit to a provided spectrum (see fit()).

  • tpl_wave (numpy.ndarray, optional) – Wavelength vector for template spectrum. If provided, tpl_flux must also be provided. If not provided, the template spectrum must have already been defined for this instance, e.g., via a fit to a provided spectrum (see fit()).

  • tpl_flux (numpy.ndarray, optional) – Flux vector for template spectrum. If provided, tpl_wave must also be provided. If not provided, the template spectrum must have already been defined for this instance, e.g., via a fit to a provided spectrum (see fit()).

  • rng (numpy.ndarray, optional) – The wavelength range used to scale the functional forms used for the model parameters. If None, the range is assumed to be already defined or irrelevant to the construction of the model.

Returns:

The model spectrum.

Return type:

numpy.ndarray

mul_par(par=None)[source]
shifted_wave(wave, shift=None)[source]
sigma_par(par=None)[source]
class mangadap.proc.rukia.RukiaBitMask[source]

Bases: BitMask

Global mask bits used for Rukia.

class mangadap.proc.rukia.ScaledEmpirical(x, y, scale_func=None, rng=None, assume_sorted=True)[source]

Bases: object

reset_rng(rng)[source]