API#

The API is under active development and should be considered unstable. Feedback is welcomed.

echelle#

Spectral dispersion and slit length axes are generally not perfectly aligned with the rectilinear pixel grid of a spectrograph detector, complicating the extraction of echelle spectroscopy. There exists some mapping of each 2D \((x,y)\) pixel to a new coordinate system of wavelength and slit position \((\lambda,s)\), with \(x\) and \(y\) in units of pixels, \(\lambda\) in units of Ångstroms, and \(s\) in units of arcseconds. These surfaces can therefore be represented as scalar functions over \(x\) and \(y\). The ynot project infers this mapping for all pixels in an echelle order. For example, this mapping could be parameterized as separable polynomials:

\[ \begin{align}\begin{aligned}\lambda(x,y) &= \lambda_0 + c_1 x + c_2 x^2 + c_3 y\\s(x,y) &= s_0 + b_1 y + b_2 x\end{aligned}\end{align} \]

Echellogram#

class ynot.echelle.Echellogram(device='cuda', ybounds=(425, 510), dense_sky=False)[source]#

A PyTorch layer that provides a parameter set and transformations to model echellograms.

Parameters:
  • device (str) – Either “cuda” for GPU acceleration, or “cpu” otherwise

  • ybounds (tuple) – the \(y_0\) and \(y_{max}\) of the raw echellogram to analyze. Default: (425, 510)

  • dense_sky (bool) – whether or not to treat the sky background as dense (~1400) parameters or fit a few (~3-10) lines from a pre-determined line list. A pre-determined line list is needed for wavelength calibration, while a dense sky gives the best sky subtraction for weak lines that are not in the line list. The best approach—a hybrid of the two—is not yet implemented. Default: False

dense_sky_model()[source]#

A sky model with dense (~1400) spectral lines

edge_mask(log_smoothness)[source]#

The soft-edge pixel mask defined by the extent of the spectrograph slit length

Constructed by the product of two sigmoid functions to make a smooth tophat:

\[m_e = \mathscr{S}(0) \cdot (1 - \mathscr{S}(12) )\]

Currently hard-coded to a 12 arcsecond slit.

Parameters:

log_smoothness (torch.tensor or tuple) – the \(\beta\) smoothness parameter related to image quality

Returns:

the 2D surface map \(m_e(x,y)\)

Return type:

(torch.tensor)

forward(index)[source]#

The forward pass of the neural network model

Parameters:

index (int) – the index of the ABB’A’ nod frames: e.g. A=0, B=1, B’=2, A’=3

Returns:

the 2D generative scene model destined for backpropagation parameter tuning

Return type:

(torch.tensor)

generative_model(index)[source]#

The generative model resembles echelle spectra traces in astronomy data

get_skyline_wavelengths()[source]#

Get the wavelengths of bright sky lines (e.g. OH)

lam_xy(c)[source]#

A 2D Surface mapping \((x,y)\) pixels to \(\lambda\)

Each (x,y) pixel coordinate maps to a single central wavelength. This function performs that transformation, given the coefficents of polynomials, the x and y values, and a fiducial central wavelength and dispersion. The coefficients in this function are intended to be fit through iterative stochastic gradient descent.

Parameters:

c (torch.tensor) – polynomial weights and bias fitted through backpropagation

Returns:

the 2D surface map \(\lambda(x,y)\)

Return type:

(torch.tensor)

native_pixel_model(amp_of_lambda, lam_vec)[source]#

A Native-pixel model of the scene

s_of_xy(params)[source]#

The along-slit coordinate \(s\) as a function of \((x,y)\), given coefficients

Parameters:

params (torch.tensor or tuple) – the polynomial weights, first order in \(x\) and \(y\)

Returns:

the 2D surface map \(s(x,y)\)

Return type:

(torch.tensor)

single_arcline(amp, lam_0, lam_sigma)[source]#

Evaluate a normalized arcline given a 2D wavelength map

sky_continuum_model()[source]#

A smooth model for the background sky emission in sparse-sky models

Returns:

the 2D sky emission continuum

Return type:

(torch.tensor)

source_profile_medium(p_coeffs)[source]#

The profile of the sky source, given position, width, trend coefficients

p_coeffs[0]: Position in arcseconds (0,12) p_coeffs[1]: Width in arcseconds ~1.0 p_coeffs[2]: Position drift as a function of x (arcseconds per pixel) p_coeffs[3]: Position drift as a function of x^2 (arcseconds per pixel^2)

source_profile_simple(p_coeffs)[source]#

The profile of the sky source, given position and width coefficients and s

p_coeffs[0]: Position in arcseconds (0,12) p_coeffs[1]: Width in arcseconds ~1.0

sparse_sky_model()[source]#

A sky model with a few (~3-10) spectral lines