API¶
The API is under active development and should be considered unstable. Feedback is welcomed.
datasets¶
This utility loads 1D echelle data, inheriting from the PyTorch Dataset model. We currently only support data from the HPF spectrograph.
HPFDataset¶
- class blase.datasets.HPFDataset(filename, device='cuda')¶
Read in an HPF spectrum
- Parameters
filename (list) – the Goldilocks echelle spectrum to read-in
device (str) – On which device to house the data, “cuda” or “cpu”
- get_goldilocks_dataframe(filename)¶
Return a pandas Dataframe given a Goldilocks FITS file name
Spectral Model¶
We fit an echelle spectrum with \(M\) total total orders, \(m\), with a single model. \(F(\lambda, \Theta)\) where \(\Theta\) are the set of stellar and nuisance parameters.
MultiOrder¶
- class blase.multiorder.MultiOrder(device='cuda', wl_data=None)¶
A PyTorch layer that provides a parameter set and transformations to model 1D echelle spectra.
- Parameters
device (str) – Either “cuda” for GPU acceleration, or “cpu” otherwise
wl_data (Tensor) – The array of wavelengths used for HPF science data
- forward(index)¶
The forward pass of the spectral model
- Parameters
index (int) – the index of the HPF spectral order
- Returns
the 1D generative spectral model destined for backpropagation parameter tuning
- Return type
(torch.tensor)
- read_native_PHOENIX_model(teff, logg, PHOENIX_path='~/libraries/raw/PHOENIX/')¶
Return the native model wavelength and flux as a torch tensor
- Parameters
Teff (int) – The Teff label of the PHOENIX model to read in. Must exist!
logg (float) – The logg label of the PHOENIX model to read in. Must exist!
- Returns
the PHOENIX model wavelength and normalized flux at native spectral resolution
- Return type
(tuple of tensors)
telluric¶
Telluric absorption forward modeling based on HITRAN
TelluricModel¶
- class blase.telluric.TelluricModel(device='cuda')¶
Make a model of Earth’s atmospheric absorption and/or sky emission
- Parameters
device (str) – On which device to run the model, “cuda” or “cpu”
- S_ij_of_T(T, S_ij_296, nu_ij, g_lower, E_lower)¶
The Spectral Line Intensity as a function of temperature
\[S_{ij}(T) = S_{ij}(T_\mathrm{ref}) \frac{Q(T_\mathrm{ref})}{Q(T)} \frac{\exp\left( -c_2 E''/T \right)}{\exp\left( -c_2 E''/T_\mathrm{ref} \right)} \frac{[1-\exp\left( -c_2 \nu_{ij}/T \right)]}{[1-\exp\left(-c_2 \nu_{ij}/T_\mathrm{ref} \right)]}\]- Parameters
T (float) – Temperature \(T\) in K
S_ij_296 (float) – The spectral line intensity at \(T_{ref}=296\) K
nu_ij (float) – Wavenumber of the spectral line transition \((\mathrm{cm^{-1}})\) in vacuum
g_lower (float) – The lower state statistical weights \(g''\)
E_lower (float) – The lower-state energy of the transition \(\mathrm{cm^{-1}}\)
- Returns
A vector of length \(N_{\mathrm{lines}}\)
- Return type
torch.Tensor
- forward()¶
The forward pass of the neural network
- gamma_of_p_and_T(p, T, p_self, n_air, gamma_air_ref, gamma_self_ref)¶
Compute the Lorentz half width at half maximum (HWHM) in units of \(\mathrm{cm^{-1}}\) with pressure and temperature:
\[\gamma(p, T) = \left( \frac{T_\mathrm{ref}}{T} \right)^{n_\mathrm{air}}\left( \gamma_\mathrm{air}(p_\mathrm{ref}, T_\mathrm{ref})(p-p_\mathrm{self}) + \gamma_\mathrm{self}(p_\mathrm{ref}, T_\mathrm{ref})p_\mathrm{self}\right)\]- Parameters
p (float) – Pressure \(p\) in standard atmospheres atm
T (float) – Temperature \(T\) in K
p_self (float) – Partial pressure of the species in atm
n_air (float) – The coefficient of the temperature dependence of the air-broadened half width (dimensionless)
gamma_air_ref (float) – The air-broadened HWHM at \(T_{ref}=296\;\) K and reference pressure \(p_{ref}=1\;\) atm
gamma_self_ref (float) – The self-broadened HWHM at \(T_{ref}=296\;\) K and reference pressure \(p_{ref}=1\;\) atm
- Returns
A vector of length \(N_{\mathrm{lines}}\)
- Return type
torch.Tensor
- get_hapi_molec_data(species)¶
Fetch HITRAN atomic and molecular data as torch tensors
- Parameters
species (str) – Which atomic/molecular species to examine
- Returns
- A dictionary containing tensors of size \(N_{\mathrm{lines}}\)
for each of the 8 HITRAN columns of interest
- Return type
dict
- lorentz_profile(nu, p, nu_ij, gamma, dp_ref, S_ij)¶
Return the Lorentz line profile given vectors and parameters
\[f_\mathrm{L}(\nu; \nu_{ij}, T, p) = \frac{1}{\pi}\frac{\gamma(p,T)}{\gamma(p,T)^2 + [\nu-(\nu_{ij} + \delta(p_\mathrm{ref})p)]^2}\]- Parameters
nu (float) – Wavenumber variable input \(\nu\) in \(\mathrm{cm^{-1}}\). For matrix output, nu should have shape \(N_{\lambda} \times 1\).
p (float) – Pressure \(p\) in standard atmospheres atm
nu_ij (float) – Wavenumber of the spectral line transition \((\mathrm{cm^{-1}})\) in vacuum
gamma (float) – Lorentz half width at half maximum (HWHM), \(\gamma\) in units of \(\mathrm{cm^{-1}}\)
dp_ref (float) – The pressure shift \(\mathrm{cm^{-1}/atm}\) at \(T_{ref}=296\) K and \(p_{ref} = 1\) atm of the line position with respect to the vacuum transition wavenumber \(\nu_{ij}\)
S_ij (float) – The spectral line intensity \(\mathrm{cm^{-1}/(molecule·cm^{-2}})\)
- Returns
Either a vector of length \(N_\lambda\) if \(\gamma\) is a scalar, or a matrix of size \(N_\lambda \times N_{lines}\) if \(\gamma\) is a vector
- Return type
torch.Tensor
- tips_Q_of_T(T, g_k, E_k)¶
Total Internal Partition Sum
\[Q(T) = \sum_k g_k \exp\left(-\frac{c_2E_k}{T}\right)\]- Parameters
T (float) – Temperature \(T\) in K
g_k (float) – The lower state statistical weights \(g_k\)
E_k (float) – The lower-state energy of the transition \(\mathrm{cm^{-1}}\)
- Returns
A scalar or a vector the same length as T
- Return type
torch.Tensor
- transmission_multilayer_atmosphere(T_vector, p_vector, nus, vol_mix_ratio, hitran)¶
Return the transmission spectrum \(\mathcal{T}(\nu; T, P)=\exp(-\tau_\nu)\) for a cascade of \(N_{layers}\) pathlengths with thickness 1 km.
- Parameters
T_vector (\(1 \times 1 \times N_{layers}\) tensor) – Temperature \(T\) in K
p_vector (\(1 \times 1 \times N_{layers}\) tensor) – Pressure \(p\) in standard atmospheres atm
nus (\(N_{\nu} \times 1 \times 1\) tensor) – Wavenumber variable input \(\nu\) in \(\mathrm{cm^{-1}}\).
vol_mix_ratio (scalar or \(1 \times 1 \times N_{layers}\) tensor) – The volume mixing ratio of the species assuming ideal gas
hitran (OrderedDict) – Each entry of consists of a \(N_{lines}\) vector that will be broadcasted to a \(1 \times N_{lines} \times 1\) tensor when operating with the other vectors.
- Returns
A vector of length \(N_{\nu}\)
- Return type
torch.Tensor
- transmission_of_T_p(T, p, nus, vol_mix_ratio, hitran)¶
Return the transmission spectrum \(\mathcal{T}(\nu; T, P)=\exp(-\tau_\nu)\) for 1 km of pathlength
- Parameters
T (float) – Temperature \(T\) in K
p (float) – Pressure \(p\) in standard atmospheres atm
nus (float) – Wavenumber variable input \(\nu\) in \(\mathrm{cm^{-1}}\).
vol_mix_ratio (float) – The volume mixing ratio of the species assuming ideal gas
- Returns
A vector of length \(N_{\nu}\)
- Return type
torch.Tensor