exojax.opacity.lpf package

Submodules

exojax.opacity.lpf.api module

API for Line Profile Function (LPF) opacity calculations.

This module provides the OpaDirect class for direct line-by-line opacity calculations using the LPF method.

class exojax.opacity.lpf.api.OpaDirect(mdb, nu_grid: ndarray, wavelength_order: Literal['ascending', 'descending'] = 'descending')

Bases: OpaCalc

Opacity Calculator Class for Direct Line-by-Line calculations (LPF).

This class performs direct line-by-line opacity calculations without approximations, providing the most accurate results at the cost of computational efficiency.

method

Always β€œlpf” for this calculator

mdb

Molecular database instance

wavelength_order

Order of wavelength grid

opainfo

Opacity information from initialization

apply_params() None

Apply database parameters and initialize opacity info.

xsmatrix(Tarr: Union[ndarray, Array], Parr: Union[ndarray, Array]) Array

Compute cross section matrix for temperature and pressure arrays.

Note

Self-pressure (Pself) is currently set to zero for HITEMP/HITRAN.

Parameters:
  • Tarr – Temperature array in K

  • Parr – Pressure array in bar

Returns:

Cross section matrix with shape (Nlayer, N_wavenumber) in cmΒ²

Raises:

ValueError – If database type is not supported

xsvector(T: float, P: float, Pself: float = 0.0) Array

Compute cross section vector for given temperature and pressure.

Parameters:
  • T – Temperature in Kelvin

  • P – Pressure in bar

  • Pself – Self-pressure for HITEMP/HITRAN in bar

Returns:

Cross section vector in cmΒ²

Raises:

ValueError – If database type is not supported

exojax.opacity.lpf.lpf module

Line Profile Functions method for opacity calculation.

exojax.opacity.lpf.lpf.exomol(mdb, Tarr, Parr, molmass)

Computes molecular line information required for MODIT using Exomol mdb.

Parameters:
  • mdb – mdb instance

  • Tarr – Temperature array

  • Parr – Pressure array

  • molmass – molecular mass

Returns:

line intensity matrix, gammaL matrix, sigmaD matrix

exojax.opacity.lpf.lpf.hjert_jvp(primals, tangents)
exojax.opacity.lpf.lpf.ljert(x, a)

ljert function, consisting of a combination of imwofz and imag(asymptiotic wofz).

Parameters:
  • x –

  • a –

Returns:

L(x,a) or Imag(wofz(x+ia))

Note

ljert provides a L(x,a) function. This function accepts a scalar value as an input. Use jax.vmap to use a vector as an input.

exojax.opacity.lpf.lpf.vald(adb, Tarr, PH, PHe, PHH)

Computes VALD line information required for LPF using VALD atomic database (adb)

Parameters:
  • adb – adb instance made by the AdbVald class in moldb.py

  • Tarr – Temperature array

  • PH – Partial pressure array of neutral hydrogen (H)

  • PHe – Partial pressure array of neutral helium (He)

  • PHH – Partial pressure array of molecular hydrogen (H2)

Returns:

line intensity matrix gammaLM: gammaL matrix sigmaDM: sigmaD matrix

Return type:

SijM

exojax.opacity.lpf.lpf.vald_each(Tarr, PH, PHe, PHH, qt_284_T, QTmask, QTref_284, logsij0, nu_lines, ielem, iion, dev_nu_lines, elower, eupper, atomicmass, ionE, gamRad, gamSta, vdWdamp, Tref)

Compute VALD line information required for LPF for separated each species

Parameters:
  • Tarr – temperature array [N_layer]

  • PH – partial pressure array of neutral hydrogen (H) [N_layer]

  • PHe – partial pressure array of neutral helium (He) [N_layer]

  • PHH – partial pressure array of molecular hydrogen (H2) [N_layer]

  • qt_284_T – partition function at the temperature T Q(T), for 284 species

  • QTmask – array of index of Q(Tref) grid (gQT) for each line

  • QTref_284 – partition function at the reference temperature Q(Tref), for 284 species

  • logsij0 – log line strength at T=Tref

  • nu_lines – line center (cm-1) in np.array (float64)

  • ielem – atomic number (e.g., Fe=26)

  • iion – ionized level (e.g., neutral=1, singly ionized=2, etc.)

  • dev_nu_lines – line center (cm-1) in device (float32)

  • elower – the lower state energy (cm-1)

  • eupper – the upper state energy (cm-1)

  • atomicmass – atomic mass (amu)

  • ionE – ionization potential (eV)

  • gamRad – log of gamma of radiation damping (s-1)

  • gamSta – log of gamma of Stark damping (s-1)

  • vdWdamp – log of (van der Waals damping constant / neutral hydrogen number) (s-1)

Returns:

line intensity matrix [N_layer x N_line] gammaLM: gammaL matrix [N_layer x N_line] sigmaDM: sigmaD matrix [N_layer x N_line]

Return type:

SijM

exojax.opacity.lpf.lpf.voigt(nuvector, sigmaD, gammaL)

Custom JVP version of Voigt profile using Voigt-Hjerting function.

Parameters:
  • nu – wavenumber array

  • sigmaD – sigma parameter in Doppler profile

  • gammaL – broadening coefficient in Lorentz profile

Returns:

Voigt profile

Return type:

v

exojax.opacity.lpf.lpf.voigtone(nu, sigmaD, gammaL)

Custom JVP version of (non-vmapped) Voigt function using Voigt-Hjerting function.

Parameters:
  • nu – wavenumber

  • sigmaD – sigma parameter in Doppler profile

  • gammaL – broadening coefficient in Lorentz profile

Returns:

Voigt funtion

Return type:

v

exojax.opacity.lpf.lpf.vvoigt(numatrix, sigmaD, gammaL)

Custom JVP version of vmaped voigt profile.

Parameters:
  • numatrix – wavenumber matrix in R^(Nline x Nwav)

  • sigmaD – doppler sigma vector in R^Nline

  • gammaL – gamma factor vector in R^Nline

Returns:

Voigt profile vector in R^Nwav

exojax.opacity.lpf.lpf.xsmatrix(numatrix, sigmaDM, gammaLM, SijM)

Custom JVP version of cross section matrix.

Parameters:
  • numatrix – wavenumber matrix in R^(Nline x Nwav)

  • sigmaDM – doppler sigma matrix in R^(Nlayer x Nline)

  • gammaLM – gamma factor matrix in R^(Nlayer x Nline)

  • SijM – line strength matrix in R^(Nlayer x Nline)

Returns:

cross section matrix in R^(Nlayer x Nwav)

exojax.opacity.lpf.lpf.xsvector(numatrix, sigmaD, gammaL, Sij)

Custom JVP version of cross section vector.

Parameters:
  • numatrix – wavenumber matrix in R^(Nline x Nwav)

  • sigmaD – doppler sigma vector in R^Nline

  • gammaL – gamma factor vector in R^Nline

  • Sij – line strength vector in R^Nline

Returns:

cross section vector in R^Nwav

exojax.opacity.lpf.make_numatrix module

exojax.opacity.lpf.make_numatrix.add_nu(dd, fnu, fhatnu, Nz)

re-adding an interger part w/JIT.

Parameters:
  • dd – difference matrix

  • fnu – integer part of wavenumber

  • fhatnu – residual wavenumber

  • Nz – boost factor

Returns:

an integer part readded value

exojax.opacity.lpf.make_numatrix.divwavnum(nu, Nz=1)

separate an integer part from a residual.

Parameters:
  • nu – wavenumber array

  • Nz – boost factor (default=1)

Returns:

integer part of wavenumber, residual wavenumber, boost factor

exojax.opacity.lpf.make_numatrix.make_numatrix0(nu, hatnu, warning=True)

Generate numatrix0.

Note

Use float64 as inputs.

Parameters:
  • nu – wavenumber matrix (Nnu,)

  • hatnu – line center wavenumber vector (Nline,), where Nm is the number of lines

  • warning – True=warning on for nu.dtype=float32

Returns:

numatrix (Nline,Nnu)

exojax.opacity.lpf.make_numatrix.make_numatrix0_subtract(nu, hatnu, Nz=1, warning=True)

Generate numatrix0 using gpu.

Note

This function computes a wavenumber matrix using XLA. Because XLA does not support float64, a direct computation sometimes results in large uncertainity. For instace, let’s assume nu=2000.0396123 cm-1 and hatnu=2000.0396122 cm-1. If applying float32, we get np.float32(2000.0396123)-np.float32(2000.0396122) = 0.0. But, after subtracting 2000 from both nu and hatnu, we get np.float32(0.0396123)-np.float32(0.0396122)=1.0058284e-07. make_numatrix0 does such computation. Nz=1 means we subtract a integer part (i.e. 2000), Nz=10 means we subtract 2000.0, and Nz=10 means we subtract 2000.00.

Parameters:
  • nu – wavenumber matrix (Nnu,)

  • hatnu – line center wavenumber vector (Nline,), where Nm is the number of lines

  • Nz – boost factor (default=1)

  • warning – True=warning on for nu.dtype=float32

Returns:

wavenumber matrix w/ no shift

Return type:

numatrix0

exojax.opacity.lpf.make_numatrix.subtract_nu(dnu, dhatnu)

compute nu - hatnu by subtracting an integer part w/JIT

Parameters:
  • dnu – residual wavenumber array

  • dhatnu – residual line center array

Returns:

difference matrix

Module contents