Basic Usage

To calculate the RV precision given a spectrum with wavelength and flux you can use the rv_precision function.

from eniric.precision import rv_precision
rv = rv_precision(wavelength, flux)

or for the flux independent spectral quality, Q,

from eniric.precision import quality
q = quality(wavelength, flux)
eniric.precision.rv_precision(wavelength: numpy.ndarray, flux: numpy.ndarray, mask: Optional[numpy.ndarray] = None, **kwargs) → astropy.units.quantity.Quantity[source]

Calculate the theoretical RV precision achievable on a spectrum.

Parameters:
  • wavelength (array-like or Quantity) – Wavelength of spectrum.
  • flux (array-like or Quantity) – Flux of spectrum.
  • mask (array-like, Quantity or None) – Masking function array to apply to the pixel weights.
  • kwargs – Kwargs for sqrt_sum_wis
Returns:

RVrms – Radial velocity precision of spectra in m/s.

Return type:

astropy.Quantity

eniric.precision.quality(wavelength: numpy.ndarray, flux: numpy.ndarray, mask: Optional[numpy.ndarray] = None, **kwargs) → float[source]

Calculation of the spectral Quality, Q, for a spectrum.

Q = sqrt{sum{W(i)}} / sqrt{sum{A_0{i}}

The spectral quality, Q, is independent of the flux level and is only a function of the spectral profile.

Parameters:
  • wavelength (array-like or Quantity) – Wavelength of spectrum.
  • flux (array-like or Quantity) – Flux of spectrum.
  • mask (array-like, Quantity or None) – Masking function array to apply to the pixel weights.
  • kwargs – Kwargs for sqrt_sum_wis (including mask).
Returns:

q – Spectral quality.

Return type:

float

Masking

It is possible to include custom pixel masks both rv_precision() and quality(), to selectively select, exclude, or weight the spectra. These are passed as the 3rd argument to either function.

rv = rv_precision(wavelength, flux, mask=my_mask)
q = quality(wavelength, flux, mask=my_mask)

Not supplying a mask or setting mask=None is equivalent to a mask of all 1’s which will have no impact on the precision (i.e. all pixels are weighted equally).

To use the default (supplied) telluric line model to apply spectral masking you can use the Atmosphere class:

from eniric.atmosphere import Atmosphere
# Assuming K is the correct band, and you want to mask for seasonal variation.
atm = Atmosphere.from_band("K", bary=True)

# Obtain closet telluric model values at the wavelength values (this telluric mask is super sampled).
atm = atm.at(wavelength)

# Boolean telluric line mask at 2% deep.
rv2 = rv_precision(wavelength, flux, mask=atm.mask)

# Perfect telluric correction mask.
rv3 = rv_precision(wavelength, flux, mask=atm.transmission**2)

For more details about about the masks used here see Telluric Masking.