exojax.spec package

Submodules

exojax.spec.api module

Molecular database (MDB) class using a common API w/ RADIS = (CAPI), will be renamed.

  • MdbExomol is the MDB for ExoMol

  • MdbHit is the MDB for HITRAN or HITEMP

class exojax.spec.api.MdbExomol(path, nurange=[- inf, inf], crit=0.0, elower_max=None, Ttyp=1000.0, bkgdatm='H2', broadf=True, gpu_transfer=True, inherit_dataframe=False, optional_quantum_states=False, activation=True, local_databases='./')

Bases: MdbExomol

molecular database of ExoMol.

MdbExomol is a class for ExoMol.

simple_molecule_name

simple molecule name

nurange

nu range [min,max] (cm-1)

nu_lines

line center (cm-1)

Type:

nd array

Sij0

line strength at T=Tref (cm)

Type:

nd array

logsij0

log line strength at T=Tref

Type:

jnp array

A

Einstein A coeeficient

Type:

jnp array

gamma_natural

gamma factor of the natural broadening

Type:

DataFrame or jnp array

elower

the lower state energy (cm-1)

Type:

DataFrame or jnp array

gpp

statistical weight

Type:

DataFrame or jnp array

jlower

J_lower

Type:

DataFrame or jnp array

jupper

J_upper

Type:

DataFrame or jnp array

n_Texp

temperature exponent

Type:

DataFrame or jnp array

dev_nu_lines

line center in device (cm-1)

Type:

jnp array

alpha_ref

alpha_ref (gamma0), Lorentzian half-width at reference temperature and pressure in cm-1/bar

Type:

jnp array

n_Texp_def

default temperature exponent in .def file, used for jlower not given in .broad

alpha_ref_def

default alpha_ref (gamma0) in .def file, used for jlower not given in .broad

QT_interp(T)

interpolated partition function.

Parameters:

T – temperature

Returns:

Q(T) interpolated in jnp.array

Sij0()

Deprecated line_strength_ref.

Returns:

line_strength_ref

Return type:

ndarray

activate(df, mask=None)

activation of moldb,

Notes

activation includes, making instances, computing broadening parameters, natural width, and transfering instances to gpu arrays when self.gpu_transfer = True

Parameters:
  • df – DataFrame

  • mask – mask of DataFrame to be used for the activation, if None, no additional mask is applied.

Note

self.df_load_mask is always applied when the activation.

Examples

>>> # we would extract the line with delta nu = 2 here
>>> mdb = api.MdbExomol(emf, nus, optional_quantum_states=True, activation=False)
>>> load_mask = (mdb.df["v_u"] - mdb.df["v_l"] == 2)
>>> mdb.activate(mdb.df, load_mask)
apply_mask_mdb(mask)

apply mask for mdb class

Parameters:

mask – mask to be applied

Examples

>>> mdb = api.MdbExomol(emf, nus)
>>> # we would extract the lines with elower > 100.
>>> mask = mdb.elower > 100.
>>> mdb.apply_mask_mdb(mask)
change_reference_temperature(Tref_new)

change the reference temperature Tref and recompute Sij0

Parameters:

Tref_new (float) – new Tref in Kelvin

compute_load_mask(df)
generate_jnp_arrays()

(re)generate jnp.arrays.

Note

We have nd arrays and jnp arrays. We usually apply the mask to nd arrays and then generate jnp array from the corresponding nd array. For instance, self._A is nd array and self.A is jnp array.

instances_from_dataframes(df_masked)

generate instances from (usually masked) data frame

Parameters:

df_masked (DataFrame) – (masked) data frame

Raises:

ValueError – _description_

qr_interp(T)

interpolated partition function ratio.

Parameters:

T – temperature

Returns:

qr(T)=Q(T)/Q(Tref) interpolated in jnp.array

set_wavenum(nurange)
class exojax.spec.api.MdbHitemp(path, nurange=[- inf, inf], crit=0.0, elower_max=None, Ttyp=1000.0, isotope=1, gpu_transfer=False, inherit_dataframe=False, activation=True, parfile=None, with_error=False)

Bases: MdbCommonHitempHitran, HITEMPDatabaseManager

molecular database of HITEMP.

simple_molecule_name

simple molecule name

nurange

nu range [min,max] (cm-1)

nu_lines

line center (cm-1)

Type:

nd array

Sij0

line strength at T=Tref (cm)

Type:

nd array

dev_nu_lines

line center in device (cm-1)

Type:

jnp array

logsij0

log line strength at T=Tref

Type:

jnp array

A

Einstein A coeeficient

Type:

jnp array

gamma_natural

gamma factor of the natural broadening

Type:

jnp array

gamma_air

gamma factor of air pressure broadening

Type:

jnp array

gamma_self

gamma factor of self pressure broadening

Type:

jnp array

elower

the lower state energy (cm-1)

Type:

jnp array

gpp

statistical weight

Type:

jnp array

n_air

air temperature exponent

Type:

jnp array

generate_jnp_arrays()

(re)generate jnp.arrays.

Note

We have nd arrays and jnp arrays. We usually apply the mask to nd arrays and then generate jnp array from the corresponding nd array. For instance, self._A is nd array and self.A is jnp array.

instances_from_dataframes(df_masked)

generate instances from (usually masked) data farame

Parameters:

df_load_mask (DataFrame) – (masked) data frame

class exojax.spec.api.MdbHitran(path, nurange=[- inf, inf], crit=0.0, elower_max=None, Ttyp=1000.0, isotope=0, gpu_transfer=False, inherit_dataframe=False, activation=True, parfile=None, nonair_broadening=False, with_error=False)

Bases: MdbCommonHitempHitran, HITRANDatabaseManager

molecular database of HITRAN

simple_molecule_name

simple molecule name

nurange

nu range [min,max] (cm-1)

nu_lines

line center (cm-1)

Type:

nd array

Sij0

line strength at T=Tref (cm)

Type:

nd array

dev_nu_lines

line center in device (cm-1)

Type:

jnp array

logsij0

log line strength at T=Tref

Type:

jnp array

A

Einstein A coeeficient

Type:

jnp array

gamma_natural

gamma factor of the natural broadening

Type:

jnp array

gamma_air

gamma factor of air pressure broadening

Type:

jnp array

gamma_self

gamma factor of self pressure broadening

Type:

jnp array

elower

the lower state energy (cm-1)

Type:

jnp array

gpp

statistical weight

Type:

jnp array

n_air

air temperature exponent

Type:

jnp array

generate_jnp_arrays()

(re)generate jnp.arrays.

Note

We have nd arrays and jnp arrays. We usually apply the mask to nd arrays and then generate jnp array from the corresponding nd array. For instance, self._A is nd array and self.A is jnp array.

instances_from_dataframes(df_load_mask)

generate instances from (usually masked) data farame

Parameters:

df_load_mask (DataFrame) – (masked) data frame

Raises:

ValueError – _description_

exojax.spec.atmrt module

Atmospheric Radiative Transfer (art) class

Notes

opacity is computed in art because it uses planet physical quantities such as gravity, mmr.

class exojax.spec.atmrt.ArtCommon(pressure_top, pressure_btm, nlayer, nu_grid=None)

Bases: object

Common Atmospheric Radiative Transfer

atmosphere_height(temperature, mean_molecular_weight, radius_btm, gravity_btm)

atmosphere height and radius

Parameters:
  • temperature (1D array) – temparature profile (Nlayer)

  • mean_molecular_weight (float/1D array) – mean molecular weight profile (float/Nlayer)

  • radius_btm (float) – the bottom radius of the atmospheric layer

  • gravity_btm (float) – the bottom gravity cm2/s at radius_btm, i.e. G M_p/radius_btm

Returns:

height normalized by radius_btm (Nlayer) 1D array: layer radius r_n normalized by radius_btm (Nlayer) 1D array: radius at lower boundary normalized by radius_btm (Nlayer)

Return type:

1D array

Notes

Our definitions of the radius_lower, radius_layer, and height are as follows: n=0,1,…,N-1 radius_lower[N-1] = radius_btm (i.e. R0) radius_lower[n-1] = radius_lower[n] + height[n] radius_layer[n] = radius_lower[n] + height[n]/2 “normalized” means physical length divided by radius_btm

change_temperature_range(Tlow, Thigh)

temperature range to be assumed.

Note

The default temperature range is self.Tlow = 0 K, self.Thigh = jnp.inf.

Parameters:
  • Tlow (float) – lower temperature

  • Thigh (float) – higher temperature

check_pressure()
clip_temperature(temperature)

temperature clipping

Parameters:

temperature (array) – temperature profile

Returns:

temperature profile clipped in the range of (self.Tlow-self.Thigh)

Return type:

array

constant_gravity_profile(value)
constant_mmr_profile(value)
gravity_profile(temperature, mean_molecular_weight, radius_btm, gravity_btm)

gravity layer profile assuming hydrostatic equilibrium

Parameters:
  • temperature (1D array) – temparature profile (Nlayer)

  • mean_molecular_weight (float/1D array) – mean molecular weight profile (float/Nlayer)

  • radius_btm (float) – the bottom radius of the atmospheric layer

  • gravity_btm (float) – the bottom gravity cm2/s at radius_btm, i.e. G M_p/radius_btm

Returns:

gravity in cm2/s (Nlayer, 1), suitable for the input of opacity_profile_lines

Return type:

2D array

gray_temperature(gravity, kappa, Tint)

gray temperature profile

Parameters:
  • gravity – gravity (cm/s2)

  • kappa – infrared opacity

  • Tint – temperature equivalence of the intrinsic energy flow in K

Returns:

temperature profile

Return type:

array

guillot_temeprature(gravity, kappa, gamma, Tint, Tirr)

Guillot tempearture profile

Notes

Set self.fguillot (default 0.25) to change the assumption of irradiation. self.fguillot = 1. at the substellar point, self.fguillot = 0.5 for a day-side average and self.fguillot = 0.25 for an averaging over the whole planetary surface See Guillot (2010) Equation (29) for details.

Parameters:
  • gravity – gravity (cm/s2)

  • kappa – thermal/IR opacity (kappa_th in Guillot 2010)

  • gamma – ratio of optical and IR opacity (kappa_v/kappa_th), gamma > 1 means thermal inversion

  • Tint – temperature equivalence of the intrinsic energy flow in K

  • Tirr – temperature equivalence of the irradiation in K

Returns:

temperature profile

Return type:

array

init_pressure_profile()
opacity_profile_cia(logacia_matrix, temperature, vmr1, vmr2, mmw, gravity)
opacity_profile_lines(xsmatrix, mixing_ratio, molmass, gravity)

opacity profile (delta tau) for lines

Parameters:
  • xsmatrix (2D array) – cross section matrix (Nlayer, N_wavenumber)

  • mixing_ratio (1D array) – mass mixing ratio, Nlayer, (or volume mixing ratio profile)

  • molmass (float) – molecular mass (or mean molecular weight)

  • gravity (float/1D profile) – constant or 1d profile of gravity in cgs

Returns:

opacity profile, whose element is optical depth in each layer.

Return type:

dtau

powerlaw_temperature(T0, alpha)

powerlaw temperature profile

Parameters:
  • T0 (float) – T at P=1 bar in K

  • alpha (float) – powerlaw index

Returns:

temperature profile

Return type:

array

class exojax.spec.atmrt.ArtEmisPure(pressure_top=1e-08, pressure_btm=100.0, nlayer=100, nu_grid=None)

Bases: ArtCommon

Atmospheric RT for emission w/ pure absorption

pressure_layer

pressure profile in bar

run(dtau, temperature, nu_grid=None)

run radiative transfer

Parameters:
  • dtau (2D array) – optical depth matrix, dtau (N_layer, N_nus)

  • temperature (1D array) – temperature profile (Nlayer)

  • nu_grid (1D array) – if nu_grid is not initialized, provide it.

Returns:

_description_

Return type:

_type_

class exojax.spec.atmrt.ArtTransPure(pressure_top=1e-08, pressure_btm=100.0, nlayer=100)

Bases: ArtCommon

run(dtau, temperature, mean_molecular_weight, radius_btm, gravity_btm)

run radiative transfer

Parameters:
  • dtau (2D array) – optical depth matrix, dtau (N_layer, N_nus)

  • temperature (1D array) – temperature profile (Nlayer)

  • mean_molecular_weight (1D array) – mean molecular weight profile, (Nlayer, from atmospheric top to bottom)

  • radius_btm (float) – radius (cm) at the lower boundary of the bottom layer, R0 or r_N

  • gravity_btm (float) – gravity (cm/s2) at the lower boundary of the bottom layer, g_N

Returns:

transit squared radius normalized by radius_btm**2, i.e. it returns (radius/radius_btm)**2

Return type:

1D array

Notes

This function gives the sqaure of the transit radius. If you would like to obtain the transit radius, take sqaure root of the output and multiply radius_btm. If you would like to compute the transit depth, divide the output by (stellar radius/radius_btm)**2

exojax.spec.atomll module

exojax.spec.atomll.Sij0(A, gupper, nu_lines, elower, QTref_284, QTmask, Irwin=False)

Reference Line Strength in Tref=296K, S0.

Parameters:
  • A – Einstein coefficient (s-1)

  • gupper – the upper state statistical weight

  • nu_lines – line center wavenumber (cm-1)

  • elower – elower

  • QTref_284 – partition function Q(Tref)

  • QTmask – mask to identify a rows of QTref_284 to apply for each line

  • Irwin – if True(1), the partition functions of Irwin1981 is used, otherwise those of Barklem&Collet2016

Returns:

Line strength (cm)

Return type:

Sij(T)

exojax.spec.atomll.gamma_KA3(T, PH, PHH, PHe, ielem, iion, nu_lines, elower, eupper, atomicmass, ionE, gamRad, gamSta, vdWdamp, enh_damp=1.0)

HWHM of Lorentzian (cm-1) caluculated with the 3rd equation in p.4 of Kurucz&Avrett1981.

Parameters:
  • T – temperature (K)

  • PH – hydrogen pressure (bar) #1 bar = 1e6 dyn/cm2

  • PHH – H2 molecule pressure (bar)

  • PHe – helium pressure (bar)

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

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

  • nu_lines – transition waveNUMBER in [cm-1] (NOT frequency in [s-1])

  • elower – excitation potential (lower level) [cm-1]

  • eupper – excitation potential (upper level) [cm-1]

  • atomicmass – atomic mass [amu]

  • ionE – ionization potential [eV]

  • gamRad – log of gamma of radiation damping (s-1) #(https://www.astro.uu.se/valdwiki/Vald3Format)

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

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

  • enh_damp – empirical “enhancement factor” for classical Unsoeld’s damping constant cf.) This coefficient (enh_damp) depends on each species in some codes such as Turbospectrum. #tako210917

  • chi_lam (=h*nu=1.2398e4/wvl[AA]) – energy of a photon in the line (computed)

  • C6 – interaction constant (Eq.11.17 in Gray2005) (computed)

  • logg6 – log(gamma6) (Eq.11.29 in Gray2005) (computed)

  • gam6H – 17*v**(0.6)*C6**(0.4)*N (v:relative velocity, N:number density of neutral perturber) (computed)

  • Texp – temperature dependency (gamma6 sim T**((1-α)/2) ranging 0.3–0.4) (computed)

Returns:

pressure gamma factor (cm-1)

Return type:

gamma

Note

“/(4*np.pi*ccgs)” means: damping constant -> HWHM of Lorentzian in [cm^-1]

exojax.spec.atomll.gamma_KA3s(T, PH, PHH, PHe, ielem, iion, nu_lines, elower, eupper, atomicmass, ionE, gamRad, gamSta, vdWdamp, enh_damp=1.0)

(supplemetary:) HWHM of Lorentzian (cm-1) caluculated with the 3rd equation in p.4 of Kurucz&Avrett1981 but without discriminating iron group elements.

Parameters:
  • T – temperature (K)

  • PH – hydrogen pressure (bar) #1 bar = 1e6 dyn/cm2

  • PHH – H2 molecule pressure (bar)

  • PHe – helium pressure (bar)

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

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

  • nu_lines – transition waveNUMBER in [cm-1] (NOT frequency in [s-1])

  • elower – excitation potential (lower level) [cm-1]

  • eupper – excitation potential (upper level) [cm-1]

  • atomicmass – atomic mass [amu]

  • ionE – ionization potential [eV]

  • gamRad – log of gamma of radiation damping (s-1) #(https://www.astro.uu.se/valdwiki/Vald3Format)

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

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

  • enh_damp – empirical “enhancement factor” for classical Unsoeld’s damping constant cf.) This coefficient (enh_damp) depends on each species in some codes such as Turbospectrum. #tako210917

  • chi_lam (=h*nu=1.2398e4/wvl[AA]) – energy of a photon in the line (computed)

  • C6 – interaction constant (Eq.11.17 in Gray2005) (computed)

  • logg6 – log(gamma6) (Eq.11.29 in Gray2005) (computed)

  • gam6H – 17*v**(0.6)*C6**(0.4)*N (v:relative velocity, N:number density of neutral perturber) (computed)

  • Texp – temperature dependency (gamma6 sim T**((1-α)/2) ranging 0.3–0.4)(computed)

Returns:

pressure gamma factor (cm-1)

Return type:

gamma

Note

“/(4*np.pi*ccgs)” means: damping constant -> HWHM of Lorentzian in [cm^-1]

exojax.spec.atomll.gamma_KA4(T, PH, PHH, PHe, ielem, iion, nu_lines, elower, eupper, atomicmass, ionE, gamRad, gamSta, vdWdamp, enh_damp=1.0)

HWHM of Lorentzian (cm-1) caluculated with the 4rd equation in p.4 of Kurucz&Avrett1981.

Parameters:
  • T – temperature (K)

  • PH – hydrogen pressure (bar) #1 bar = 1e6 dyn/cm2

  • PHH – H2 molecule pressure (bar)

  • PHe – helium pressure (bar)

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

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

  • nu_lines – transition waveNUMBER in [cm-1] (NOT frequency in [s-1])

  • elower – excitation potential (lower level) [cm-1]

  • eupper – excitation potential (upper level) [cm-1]

  • atomicmass – atomic mass [amu]

  • ionE – ionization potential [eV]

  • gamRad – log of gamma of radiation damping (s-1) #(https://www.astro.uu.se/valdwiki/Vald3Format)

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

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

  • enh_damp – empirical “enhancement factor” for classical Unsoeld’s damping constant #cf.) This coefficient (enh_damp) depends on each species in some codes such as Turbospectrum. #tako210917

  • chi_lam (=h*nu=1.2398e4/wvl[AA]) – energy of a photon in the line (computed)

  • C6 – interaction constant (Eq.11.17 in Gray2005) (computed)

  • logg6 – log(gamma6) (Eq.11.29 in Gray2005) (computed)

  • gam6H – 17*v**(0.6)*C6**(0.4)*N (v:relative velocity, N:number density of neutral perturber) (computed)

  • Texp – temperature dependency (gamma6 sim T**((1-α)/2) ranging 0.3–0.4) (computed)

Returns:

pressure gamma factor (cm-1)

Return type:

gamma

Note

Approximation of case4 assume “that the atomic weight A is much greater than 4, and that the mean-square-radius of the lower level <r^2>_lo is small compared to <r^2>_up”.

“/(4*np.pi*ccgs)” means: damping constant -> HWHM of Lorentzian in [cm^-1]

exojax.spec.atomll.gamma_uns(T, PH, PHH, PHe, ielem, iion, nu_lines, elower, eupper, atomicmass, ionE, gamRad, gamSta, vdWdamp, enh_damp=1.0)

HWHM of Lorentzian (cm-1) estimated with the classical approximation by Unsoeld (1955)

Parameters:
  • T – temperature (K)

  • PH – hydrogen pressure (bar) #1 bar = 1e6 dyn/cm2

  • PHH – H2 molecule pressure (bar)

  • PHe – helium pressure (bar)

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

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

  • nu_lines – transition waveNUMBER in [cm-1] (NOT frequency in [s-1])

  • elower – excitation potential (lower level) [cm-1]

  • eupper – excitation potential (upper level) [cm-1]

  • atomicmass – atomic mass [amu]

  • ionE – ionization potential [eV]

  • gamRad – log of gamma of radiation damping (s-1) #(https://www.astro.uu.se/valdwiki/Vald3Format)

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

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

  • enh_damp – empirical “enhancement factor” for classical Unsoeld’s damping constant cf.) This coefficient (enh_damp) depends on each species in some codes such as Turbospectrum. #tako210917

  • chi_lam (=h*nu=1.2398e4/wvl[AA]) – energy of a photon in the line (computed)

  • C6 – interaction constant (Eq.11.17 in Gray2005) (computed)

  • logg6 – log(gamma6) (Eq.11.29 in Gray2005) (computed)

  • gam6H – 17*v**(0.6)*C6**(0.4)*N (v:relative velocity, N:number density of neutral perturber) (computed)

  • Texp – temperature dependency (gamma6 sim T**((1-α)/2) ranging 0.3–0.4)(computed)

Returns:

pressure gamma factor (cm-1)

Return type:

gamma

Note

“/(4*np.pi*ccgs)” means: damping constant -> HWHM of Lorentzian in [cm^-1]

exojax.spec.atomll.gamma_vald3(T, PH, PHH, PHe, ielem, iion, nu_lines, elower, eupper, atomicmass, ionE, gamRad, gamSta, vdWdamp, enh_damp=1.0)

HWHM of Lorentzian (cm-1) caluculated as gamma/(4*pi*c) [cm-1] for lines with the van der Waals gamma in the line list (VALD or Kurucz), otherwise estimated according to the Unsoeld (1955)

Parameters:
  • T – temperature (K)

  • PH – hydrogen pressure (bar) #1 bar = 1e6 dyn/cm2

  • PHH – H2 molecule pressure (bar)

  • PHe – helium pressure (bar)

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

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

  • nu_lines – transition waveNUMBER in [cm-1] (NOT frequency in [s-1])

  • elower – excitation potential (lower level) [cm-1]

  • eupper – excitation potential (upper level) [cm-1]

  • atomicmass – atomic mass [amu]

  • ionE – ionization potential [eV]

  • gamRad – log of gamma of radiation damping (s-1) (https://www.astro.uu.se/valdwiki/Vald3Format)

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

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

  • enh_damp – empirical “enhancement factor” for classical Unsoeld’s damping constant cf.) This coefficient (enh_damp) depends on each species in some codes such as Turbospectrum. #tako210917

  • chi_lam (=h*nu=1.2398e4/wvl[AA]) – energy of a photon in the line (computed)

  • C6 – interaction constant (Eq.11.17 in Gray2005) (computed)

  • logg6 – log(gamma6) (Eq.11.29 in Gray2005) (computed)

  • gam6H – 17*v**(0.6)*C6**(0.4)*N (computed) (v:relative velocity, N:number density of neutral perturber)

  • Texp – temperature dependency (gamma6 sim T**((1-α)/2) ranging 0.3–0.4) (computed)

Returns:

pressure gamma factor (cm-1)

Return type:

gamma

Note

“/(4*np.pi*ccgs)” means: damping constant -> HWHM of Lorentzian in [cm^-1]

exojax.spec.atomll.get_VMR_uspecies(uspecies, mods_ID=Array([[0, 0]], dtype=int32), mods=Array([0], dtype=int32))

Extract VMR arrays of the species that contribute the opacity (“uspecies” made with “get_unique_species”)

Parameters:
  • uspecies – jnp.array of unique list of the species contributing the opacity [N_species x 2(ielem and iion)]

  • mods_ID – jnp.array listing the species whose abundances are different from the solar [N_modified_species x 2(ielem and iion)]

  • mods – jnp.array of each abundance deviation from the Sun [dex] for each modified species listed in mods_ID [N_modified_species]

Returns:

jnp.array of volume mixing ratio [N_species]

Return type:

VMR_uspecies

exojax.spec.atomll.get_VMR_uspecies_FC(FCSpIndex_uspecies, mixing_ratios)

By using FastChem, extract volume mixing ratio (VMR) of the species that contribute the opacity (“uspecies” made with “get_unique_species”)

Parameters:
  • FCSpIndex_uspecies – SpeciesIndex in FastChem for each species of interest [N_species]

  • mixing_ratios – volume mixing ratios of all available gases calculated using fastchem2_call.run_fastchem [N_layer x N_species]

Returns:

VMR of each species in each atmospheric layer [N_species x N_layer]

Return type:

VMR_uspecies

exojax.spec.atomll.get_unique_species(adb)

Extract a unique list of line contributing species from VALD atomic database (adb)

Parameters:

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

Returns:

unique elements of the combination of ielem and iion (jnp.array with a shape of N_UniqueSpecies x 2(ielem and iion))

Return type:

uspecies

exojax.spec.atomll.ielemion_to_FastChemSymbol(ielem, iion)

Translate atomic number and ionization level into SpeciesSymbol in FastChem.

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

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

Returns:

//github.com/exoclime/FastChem/blob/master/input/logK_ext.dat)

Return type:

SpeciesSymbol in FastChem (str) (cf. https

exojax.spec.atomll.interp_QT284(T, T_gQT, gQT_284species)

interpolated partition function of all 284 species.

Parameters:
  • T – temperature

  • T_gQT – temperature in the grid obtained from the adb instance [N_grid(42)]

  • gQT_284species – partition function in the grid from the adb instance [N_species(284) x N_grid(42)]

Returns:

interpolated partition function at T Q(T) for all 284 Atomic Species [284]

Return type:

QT_284

exojax.spec.atomll.padding_2Darray_for_each_atom(orig_arr, adb, sp)

Extract only data of the species of interest from 2D-array and pad with zeros to adjust the length.

Parameters:
  • orig_arr – array [N_any (e.g., N_nu or N_layer), N_line] Note that if your ARRAY is 1D, it must be broadcasted with ARRAY[None,:], and the output must be also reshaped with OUTPUTARRAY.reshape(ARRAY.shape)

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

  • sp – array of [ielem, iion]

Returns:

padded_valid_arr

exojax.spec.atomll.sep_arr_of_sp(arr, adb, trans_jnp=True, inttype=False)

Separate by species (atoms or ions) the jnp.array stored as an instance variable in adb, and pad with zeros to adjust the length

Parameters:
  • arr – array of a parameter (one of the attributes of adb below) to be separated [N_line]

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

  • trans_jnp – if True, the output is converted to jnp.array (dtype=’float32’)

  • inttype – if True (along with trans_jnp = True), the output is converted to jnp.array of dtype=’int32’

Returns:

species-separated array [N_species x N_line_max]

Return type:

arr_stacksp

exojax.spec.atomll.uspecies_info(uspecies, ielem_to_index_of_ipccd, mods_ID=Array([[0, 0]], dtype=int32), mods=Array([0], dtype=int32), mods_id_trans=Array([], dtype=float32))

Provide arrays of information of the species that contribute the opacity (“uspecies” made with “get_unique_species”)

Parameters:
  • uspecies – jnp.array of unique list of the species contributing the opacity

  • ielem_to_index_of_ipccd – jnp.array for conversion from ielem to the index of ipccd

  • mods_ID – jnp.array listing the species whose abundances are different from the solar

  • mods – jnp.array of each abundance deviation from the Sun [dex] for each modified species in mods_ID

  • mods_id_trans – jnp.array for converting index in “mods_ID” of each species into index in uspecies

Returns:

jnp.array of mass mixing ratio in the Sun of each species in “uspecies” atomicmass_uspecies_list: jnp.array of atomic mass [amu] of each species in “uspecies” mods_uspecies_list: jnp.array of abundance deviation from the Sun [dex] for each species in “uspecies”

Return type:

MMR_uspecies_list

exojax.spec.atomllapi module

API for VALD 3.

exojax.spec.atomllapi.air_to_vac(wlair)

Convert wavelengths [AA] in air into those in vacuum.

Parameters:
  • wlair – wavelengthe in air [Angstrom]

  • n – Refractive Index in dry air at 1 atm pressure and 15ºC with 0.045% CO2 by volume (Birch and Downs, 1994, Metrologia, 31, 315)

Returns:

wavelength in vacuum [Angstrom]

Return type:

wlvac

exojax.spec.atomllapi.load_atomicdata()

load atomic data and solar composition.

  • See Asplund et al. 2009, Gerevesse et al. 1996

Returns:

table of atomic data

Return type:

ipccd (pd.DataFrame)

Note

atomic.txt is in data/atom

exojax.spec.atomllapi.load_ionization_energies()

Load atomic ionization energies.

Returns:

table of ionization energies

Return type:

df_ionE (pd.DataFrame)

Note

NIST_Atomic_Ionization_Energies.txt is in data/atom

exojax.spec.atomllapi.load_pf_Barklem2016()

load a table of the partition functions for 284 atomic species.

Returns:

steps of temperature (K) pfdat (pd.DataFrame): partition functions for 284 atomic species

Return type:

pfTdat (pd.DataFrame)

exojax.spec.atomllapi.make_ielem_to_index_of_ipccd()

index conversion for atomll.uspecies_info (Preparation for LPF)

Returns:

jnp.array to convert ielem into index of ipccd

Return type:

ielem_to_index_of_ipccd

exojax.spec.atomllapi.partfn_Fe(T)

Partition function of Fe I from Irwin_1981.

Parameters:

T – temperature

Returns:

partition function Q

exojax.spec.atomllapi.pick_ionE(ielem, iion, df_ionE)

Pick up ionization energy of a specific atomic species.

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

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

  • df_ionE (pd.DataFrame) – table of ionization energies

Returns:

ionization energy

Return type:

ionE (float)

Note

NIST_Atomic_Ionization_Energies.txt is in data/atom

exojax.spec.atomllapi.pickup_param(ExAll)

extract transition parameters from VALD3 line list and insert the same DataFrame.

Parameters:

ExAll – VALD3 line list as pandas DataFrame (Output of read_ExAll)

Returns:

Einstein coefficient in [s-1] nu_lines: transition waveNUMBER in [cm-1] (#NOT frequency in [s-1]) elower: lower excitation potential [cm-1] (#converted from eV) eupper: upper excitation potential [cm-1] (#converted from eV) gupper: upper statistical weight jlower: lower J (rotational quantum number, total angular momentum) jupper: upper J ielem: atomic number (e.g., Fe=26) iion: ionized level (e.g., neutral=1, singly) gamRad: log of gamma of radiation damping (s-1) #(https://www.astro.uu.se/valdwiki/Vald3Format) gamSta: log of gamma of Stark damping (s-1) vdWdamp: log of (van der Waals damping constant / neutral hydrogen number) (s-1)

Return type:

A

exojax.spec.atomllapi.read_ExAll(allf)

IO for linelists downloaded from VALD3 with a query of “Long format” in the format of “Extract All” or “Extract Element”.

Note

About input linelists obtained from VALD3 (http://vald.astro.uu.se/). VALD data access is free but requires registration through the Contact form (http://vald.astro.uu.se/~vald/php/vald.php?docpage=contact.html). After the registration, you can login and choose the “Extract Element” mode. For example, if you want the Fe I linelist, the request form should be filled as

>>> Starting wavelength :    1500
>>> Ending wavelength :    100000
>>> Element [ + ionization ] :    Fe 1
>>> Extraction format :    Long format
>>> Retrieve data via :    FTP
>>> Linelist configuration :    Default
>>> Unit selection:    Energy unit: eV - Medium: vacuum - Wavelength unit: angstrom - VdW syntax: default

Please assign the fullpath of the output file sent by VALD ([user_name_at_VALD].[request_number_at_VALD].gz) to the variable “allf”. See https://www.astro.uu.se/valdwiki/presformat_output for the detail of the format.

Parameters:
  • allf – fullpath to the input VALD linelist (See Notes above for more details.)

  • Ion (Elm) –

  • WL_vac (AA) –

  • gf* (log) –

  • E_low (eV) – lower excitation potential

  • lo (J) – lower rotational quantum number

  • E_up (eV) – upper excitation potential

  • up (J) – upper rotational quantum number

  • lower (Lande) –

  • upper (Lande) –

  • mean (Lande) –

  • Rad. (Damping) –

  • Stark (Damping) –

  • Waals (Damping) –

Returns:

line data in vaex DataFrame

exojax.spec.atomllapi.read_kurucz(kuruczf)

Input Kurucz line list (http://kurucz.harvard.edu/linelists/)

Parameters:

kuruczf – file path

Returns:

Einstein coefficient in [s-1] nu_lines: transition waveNUMBER in [cm-1] (#NOT frequency in [s-1]) elower: lower excitation potential [cm-1] (#converted from eV) eupper: upper excitation potential [cm-1] (#converted from eV) gupper: upper statistical weight jlower: lower J (rotational quantum number, total angular momentum) jupper: upper J ielem: atomic number (e.g., Fe=26) iion: ionized level (e.g., neutral=1, singly) gamRad: log of gamma of radiation damping (s-1) #(https://www.astro.uu.se/valdwiki/Vald3Format) gamSta: log of gamma of Stark damping (s-1) gamvdW: log of (van der Waals damping constant / neutral hydrogen number) (s-1)

Return type:

A

exojax.spec.atomllapi.vac_to_air(wlvac)

Convert wavelengths [AA] in vacuum into those in air.

Parameters:
  • wlvac – wavelength in vacuum [Angstrom]

  • n – Refractive Index in dry air at 1 atm pressure and 15ºC with 0.045% CO2 by volume (Birch and Downs, 1994, Metrologia, 31, 315)

Returns:

wavelengthe in air [Angstrom]

Return type:

wlair

exojax.spec.contdb module

Continuum database (CDB) class.

  • CdbCIA is the CDB for CIA

class exojax.spec.contdb.CdbCIA(path, nurange=[- inf, inf], margin=10.0)

Bases: object

download()

Downloading HITRAN cia file.

Note

The download URL is written in exojax.utils.url.

exojax.spec.dit module

Line profile computation using Discrete Integral Transform.

  • Line profile computation of Discrete Integral Transform for rapid spectral synthesis, originally proposed by D.C.M van den Bekerom and E.Pannier.

  • This module consists of selected functions in addit package.

  • The concept of “folding” can be understood by reading the discussion by D.C.M van den Bekerom.

exojax.spec.dit.dgmatrix(x, dit_grid_resolution=0.1, adopt=True)

DIT GRID MATRIX (alias)

Parameters:
  • x – simgaD or gammaL matrix (Nlayer x Nline)

  • dit_grid_resolution – grid resolution. dit_grid_resolution=0.1 (defaut) means a grid point per digit

  • adopt – if True, min, max grid points are used at min and max values of x. In this case, the grid width does not need to be dit_grid_resolution exactly.

Returns:

grid for DIT (Nlayer x NDITgrid)

exojax.spec.dit.ditgrid(x, dit_grid_resolution=0.1, adopt=True)

DIT GRID (deplicated).

Parameters:
  • x – simgaD or gammaL array (Nline)

  • dit_grid_resolution – grid resolution. res=0.1 (defaut) means a grid point per digit

  • adopt – if True, min, max grid points are used at min and max values of x. In this case, the grid width does not need to be res exactly.

Returns:

grid for DIT

exojax.spec.dit.dtauM_vald(dParr, g, adb, nus, cnu, indexnu, pmarray, SijM, gammaLM, sigmaDM, uspecies, mods_uspecies_list, MMR_uspecies_list, atomicmass_uspecies_list, dgm_sigmaD, dgm_gammaL)

Compute dtau caused by VALD lines from cross section xs (DIT)

Parameters:
  • dParr – delta pressure profile (bar) [N_layer]

  • g – gravity (cm/s^2)

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

  • nus – wavenumber matrix (cm-1) [N_nus]

  • cnu – cont (contribution) jnp.array [N_line]

  • indexnu – index (index) jnp.array [N_line]

  • pmarray – (+1,-1) array [len(nu_grid)+1,]

  • SijM – line intensity matrix [N_layer x N_line]

  • gammaLM – gammaL matrix [N_layer x N_line]

  • sigmaDM – sigmaD matrix [N_layer x N_line]

  • uspecies – unique elements of the combination of ielem and iion [N_UniqueSpecies x 2(ielem and iion)]

  • mods_uspecies_list – jnp.array of abundance deviation from the Sun [dex] for each species in “uspecies” [N_UniqueSpecies]

  • MMR_uspecies_list – jnp.array of mass mixing ratio in the Sun of each species in “uspecies” [N_UniqueSpecies]

  • atomicmass_uspecies_list – jnp.array of atomic mass [amu] of each species in “uspecies” [N_UniqueSpecies]

Returns:

optical depth matrix [N_layer, N_nus]

Return type:

dtauatom

exojax.spec.dit.dtauM_vald_old(dParr, xsm, g, uspecies, mods_uspecies_list, MMR_uspecies_list, atomicmass_uspecies_list)

Compute dtau caused by VALD lines from cross section xs (DIT)

Parameters:
  • dParr – delta pressure profile (bar) [N_layer]

  • xsm – cross section matrix (cm^2) [N_layer, N_nus]

  • g – gravity (cm/s^2)

  • uspecies – unique elements of the combination of ielem and iion [N_UniqueSpecies x 2(ielem and iion)]

  • mods_uspecies_list – jnp.array of abundance deviation from the Sun [dex] for each species in “uspecies” [N_UniqueSpecies]

  • MMR_uspecies_list – jnp.array of mass mixing ratio in the Sun of each species in “uspecies” [N_UniqueSpecies]

  • atomicmass_uspecies_list – jnp.array of atomic mass [amu] of each species in “uspecies” [N_UniqueSpecies]

Returns:

optical depth matrix [N_layer, N_nus]

Return type:

dtauatom

exojax.spec.dit.sigma_voigt(dgm_sigmaD, dgm_gammaL)

compute sigma of the Voigt profile.

Parameters:
  • dgm_sigmaD – DIT grid matrix for sigmaD

  • dgm_gammaL – DIT grid matrix for gammaL

Returns:

sigma

exojax.spec.dit.vald(adb, Tarr, PH, PHe, PHH)

(alias of lpf.vald)

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.spec.dit.xsmatrix(cnu, indexnu, pmarray, sigmaDM, gammaLM, SijM, nu_grid, dgm_sigmaD, dgm_gammaL)

Cross section matrix (DIT/2D+ version)

Parameters:
  • cnu – contribution by npgetix for wavenumber

  • indexnu – index by npgetix for wavenumber

  • pmarray – (+1,-1) array whose length of len(nu_grid)+1

  • 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)

  • nu_grid – linear wavenumber grid

  • dgm_sigmaD – DIT Grid Matrix for sigmaD R^(Nlayer, NDITgrid)

  • dgm_gammaL – DIT Grid Matrix for gammaL R^(Nlayer, NDITgrid)

Returns:

cross section matrix in R^(Nlayer x Nwav)

Warning

This function have not been well tested.

exojax.spec.dit.xsvector(cnu, indexnu, pmarray, sigmaD, gammaL, S, nu_grid, sigmaD_grid, gammaL_grid)

Cross section vector (DIT/2D+ version; default)

The original code is rundit in [addit package](https://github.com/HajimeKawahara/addit)

Parameters:
  • cnu – contribution by npgetix for wavenumber

  • indexnu – index by npgetix for wavenumber

  • pmarray – (+1,-1) array whose length of len(nu_grid)+1

  • sigmaD – Gaussian STD (Nlines)

  • gammaL – Lorentzian half width (Nlines)

  • S – line strength (Nlines)

  • nu_grid – linear wavenumber grid

  • sigmaD_grid – sigmaD grid

  • gammaL_grid – gammaL grid

Returns:

Cross section in the linear nu grid

Note

This function uses the precomputed neibouring contribution function for wavenumber (nu_ncf). Use npnc1D to compute nu_ncf in float64 precision.

exojax.spec.ditkernel module

Kernels for Discrete Integral Transform.

exojax.spec.ditkernel.fold_voigt_kernel(k, beta, gammaL, vmax, pmarray)

Fourier Kernel of the Voigt Profile.

Parameters:
  • k – conjugated of wavenumber

  • beta – Gaussian standard deviation

  • gammaL – Lorentian Half Width

  • vmax – Nnu x dq

  • pmarray – (+1,-1) array whose length of len(nu_grid)+1

Returns:

kernel (N_x,N_beta,N_gammaL)

Note

Conversions to the (full) width, wG and wL are as follows: wG=2*sqrt(2*ln2) beta wL=2*gamma

exojax.spec.ditkernel.fold_voigt_kernel_logst(k, log_nstbeta, log_ngammaL, vmax, pmarray)

Folded Fourier Kernel of the Voigt Profile for a common normalized beta. See https://github.com/dcmvdbekerom/discrete-integral- transform/blob/master/demo/discrete_integral_transform_log.py for the alias correction.

Parameters:
  • k – conjugate wavenumber

  • log_nstbeta – log normalized Gaussian standard deviation (scalar)

  • log_ngammaL – log normalized Lorentian Half Width (Nlines)

  • vmax – vmax

  • pmarray – (+1,-1) array whose length of len(nu_grid)+1

Returns:

kernel (N_x,N_gammaL)

Note

Conversions to the (full) width, wG and wL are as follows: wG=2*sqrt(2*ln2) beta wL=2*gamma

exojax.spec.ditkernel.voigt_kernel(k, beta, gammaL)

Fourier Kernel of the Voigt Profile.

Parameters:
  • k – conjugated of wavenumber

  • beta – Gaussian standard deviation

  • gammaL – Lorentzian Half Width

Returns:

kernel (N_x,N_beta,N_gammaL)

Note

Conversions to the (full) width, wG and wL are as follows: wG=2*sqrt(2*ln2) beta wL=2*gamma

exojax.spec.ditkernel.voigt_kernel_logst(k, log_nstbeta, log_ngammaL)

Fourier Kernel of the Voigt Profile for a common normalized beta.

Parameters:
  • k – conjugate wavenumber

  • log_nstbeta – log normalized Gaussian standard deviation (scalar)

  • log_ngammaL – log normalized Lorentian Half Width (Nlines)

Returns:

kernel (N_x,N_gammaL)

Note

Conversions to the (full) width, wG and wL are as follows: wG=2*sqrt(2*ln2) beta wL=2*gamma

exojax.spec.dtau_mmwl module

compute dtau (opacity difference in atmospheric layers) using mean molecular weight

exojax.spec.dtau_mmwl.dtauCIA_mmwl(nus, Tarr, Parr, dParr, vmr1, vmr2, mmw, g, nucia, tcia, logac)
dtau of the CIA continuum.

(for the case where mmw is given for each atmospheric layer)

Parameters:
  • nus – wavenumber matrix (cm-1)

  • Tarr – temperature array (K)

  • Parr – temperature array (bar)

  • dParr – delta temperature array (bar)

  • vmr1 – volume mixing ratio (VMR) for molecules 1 [N_layer]

  • vmr2 – volume mixing ratio (VMR) for molecules 2 [N_layer]

  • mmw – mean molecular weight of atmosphere [N_layer]

  • g – gravity (cm2/s)

  • nucia – wavenumber array for CIA

  • tcia – temperature array for CIA

  • logac – log10(absorption coefficient of CIA)

Returns:

optical depth matrix [N_layer, N_nus]

exojax.spec.dtau_mmwl.dtauHminus_mmwl(nus, Tarr, Parr, dParr, vmre, vmrh, mmw, g)
dtau of the H- continuum.

(for the case where mmw is given for each atmospheric layer)

Parameters:
  • nus – wavenumber matrix (cm-1)

  • Tarr – temperature array (K)

  • Parr – temperature array (bar)

  • dParr – delta temperature array (bar)

  • vmre – volume mixing ratio (VMR) for e- [N_layer]

  • vmrH – volume mixing ratio (VMR) for H atoms [N_layer]

  • mmw – mean molecular weight of atmosphere [N_layer]

  • g – gravity (cm2/s)

Returns:

optical depth matrix [N_layer, N_nus]

exojax.spec.dtau_mmwl.dtauM_mmwl(dParr, xsm, MR, mass, g)
dtau of the molecular cross section.

(for the case where mmw is given for each atmospheric layer)

Note

opfac=bar_cgs/(m_u (g)). m_u: atomic mass unit. It can be obtained by fac=1.e3/m_u, where m_u = scipy.constants.m_u.

Parameters:
  • dParr – delta pressure profile (bar) [N_layer]

  • xsm – cross section matrix (cm2) [N_layer, N_nus]

  • MR – volume mixing ratio (VMR) or mass mixing ratio (MMR) [N_layer]

  • mass – mean molecular weight for VMR or molecular mass for MMR [N_layer]

  • g – gravity (cm/s2)

Returns:

optical depth matrix [N_layer, N_nus]

exojax.spec.exomol module

exojax.spec.exomol.Sij0(A, g, nu_lines, elower, QTref)

Reference Line Strength in Tref=296K, S0.

Note

Tref=296K

Parameters:
  • A – Einstein coefficient (s-1)

  • g – the upper state statistical weight

  • nu_lines – line center wavenumber (cm-1)

  • elower – elower

  • QTref – partition function Q(Tref)

  • Mmol – molecular mass (normalized by m_u)

Returns:

Line strength (cm)

Return type:

Sij(T)

exojax.spec.exomol.gamma_exomol(P, T, n_air, alpha_ref)

gamma factor by a pressure broadening.

Parameters:
  • P – pressure (bar)

  • T – temperature (K)

  • n_air – coefficient of the temperature dependence of the air-broadened halfwidth

  • alpha_ref – broadening parameter

Returns:

pressure gamma factor (cm-1)

Return type:

gamma

exojax.spec.exomol.gamma_natural(A)

gamma factor by natural broadning.

1/(4 pi c) = 2.6544188e-12 (cm-1 s)

Parameters:

A – Einstein A-factor (1/s)

Returns:

natural width (cm-1)

Return type:

gamma_natural

exojax.spec.hitran module

exojax.spec.hitran.doppler_sigma(nu_lines, T, M)

Dopper width (sigmaD)

Note

c3 is sqrt(kB/m_u)/c

Parameters:
  • nu_lines – line center wavenumber (cm-1)

  • T – temperature (K)

  • M – atom/molecular mass

Returns:

doppler width (standard deviation) (cm-1)

Return type:

sigma

exojax.spec.hitran.gamma_hitran(P, T, Pself, n_air, gamma_air_ref, gamma_self_ref)

gamma factor by a pressure broadening.

Parameters:
  • P – pressure (bar)

  • T – temperature (K)

  • Pself – partial pressure (bar)

  • n_air – coefficient of the temperature dependence of the air-broadened halfwidth

  • gamma_air_ref – gamma air

  • gamma_self_ref – gamma self

Returns:

pressure gamma factor (cm-1)

Return type:

gamma

exojax.spec.hitran.gamma_natural(A)

gamma factor by natural broadning.

1/(4 pi c) = 2.6544188e-12 (cm-1 s)

Parameters:

A – Einstein A-factor (1/s)

Returns:

natural width (cm-1)

Return type:

gamma_natural

exojax.spec.hitran.line_strength(T, logsij0, nu_lines, elower, qr)

Line strength as a function of temperature, JAX/XLA compatible

Notes

Use Tref=296.0 (default) in moldb

Parameters:
  • T – temperature (K)

  • logsij0 – log(Sij(Tref)) (Tref=296K)

  • nu_lines – line center wavenumber (cm-1)

  • elower – elower

  • qr – partition function ratio qr(T) = Q(T)/Q(Tref)

Returns:

Line strength (cm)

Return type:

Sij(T)

exojax.spec.hitran.line_strength_numpy(T, Sij0, nu_lines, elower, qr, Tref=296.0)

Line strength as a function of temperature, numpy version

Parameters:
  • T – temperature (K)

  • Sij0 – line strength at Tref=296K

  • elower – elower

  • nu_lines – line center wavenumber

  • qr – partition function ratio qr(T) = Q(T)/Q(Tref)

  • Tref – reference temeparture

Returns:

line strength at Ttyp

exojax.spec.hitran.normalized_doppler_sigma(T, M, R)

Normalized Dopper width (nsigmaD) by wavenumber difference at line centers.

Note

This quantity is used in MODIT. c3 is sqrt(kB/m_u)/c

Parameters:
  • T – temperature (K)

  • M – atom/molecular mass

  • R – spectral resolution

Returns:

normalized Doppler width (standard deviation)

Return type:

nsigma

exojax.spec.hitranapi module

API for HITRAN and HITEMP outside HAPI.

exojax.spec.hitranapi.make_partition_function_grid_hitran(M, I_list)

HITRAN/HITEMP IO for partition function

Parameters:
  • M – HITRAN molecule number

  • I_list – HITRAN isotopologue number list

Returns:

jnp array of partition function grid T_gQT: jnp array of temperature grid for gQT

Return type:

gQT

exojax.spec.hitranapi.molecid_hitran(molec)

molec id from Hitran/Hitemp filename or molecule name or molecid itself.

Parameters:

molec – Hitran/Hitemp filename or molecule name or molec id itself.

Returns:

molecid (HITRAN molecular id)

Return type:

int

exojax.spec.hitrancia module

exojax.spec.hitrancia.interp_logacia_matrix(Tarr, nu_grid, nucia, tcia, logac)

interpolated function of log10(alpha_CIA)

Parameters:
  • Tarr (1D array) – temperature array (K)

  • nu_grid (1D array) – wavenumber array (cm-1)

  • nucia – CIA wavenumber (cm-1)

  • tcia – CIA temperature (K)

  • logac – log10 cia coefficient

Returns:

logac(Tarr, nus)

Example

>>> nucia,tcia,ac=read_cia("../../data/CIA/H2-H2_2011.cia",nus[0]-1.0,nus[-1]+1.0)
>>> logac=jnp.array(np.log10(ac))
>>> interp_logacia_matrix(Tarr,nus,nucia,tcia,logac)
exojax.spec.hitrancia.interp_logacia_vector(T, nu_grid, nucia, tcia, logac)

interpolated function of log10(alpha_CIA)

Parameters:
  • T (float) – temperature (K)

  • nu_grid – wavenumber array (cm-1)

  • nucia – CIA wavenumber (cm-1)

  • tcia – CIA temperature (K)

  • logac – log10 cia coefficient

Returns:

vector logac(T, nus)

exojax.spec.hitrancia.read_cia(filename, nus, nue)

READ HITRAN CIA data.

Parameters:
  • filename – HITRAN CIA file name (_2011.cia)

  • nus – wavenumber min (cm-1)

  • nue – wavenumber max (cm-1)

Returns:

wavenumber (cm-1) tcia: temperature (K) ac: cia coefficient

Return type:

nucia

exojax.spec.hminus module

H minus opacity by John (1988)

exojax.spec.hminus.bound_free_absorption(wavelength_um, temperature)

bound free absorption of H-

Note

alpha has a value of 1.439e4 micron-1 K-1, the value stated in John (1988) is wrong

Parameters:
  • wavelength_um – wavelength in the unit of micron

  • temperature – temperature in the unit of Kelvin

Returns:

absorption coefficient [cm4/dyne]

exojax.spec.hminus.free_free_absorption(wavelength_um, temperature)

free free absorption of H- (coefficients from John (1988))

Note

to follow his notation (which starts at an index of 1), the 0-index components are 0 for wavelengths larger than 0.3645 micron

Parameters:
  • wavelength_um – wavelength in the unit of micron

  • temperature – temperature in the unit of Kelvin

Returns:

absorption coefficient [cm4/dyne]

exojax.spec.hminus.log_hminus_continuum(nus, temperature, number_density_e, number_density_h)

John (1988) H- continuum opacity.

Parameters:
  • nus – wavenumber grid (cm-1) [Nnu]

  • temperature – gas temperature array [K] [Nlayer]

  • number_density_e – electron number density array [Nlayer]

  • number_density_h – H atom number density array [Nlayer]

Returns:

log10(absorption coefficient) [Nlayer,Nnu]

exojax.spec.initspec module

Initialization for opacity computation.

The functions in this module are a wrapper for initialization processes for opacity computation.

exojax.spec.initspec.broadening_grid_for_single_broadening_mode(nu_lines, gamma_ref, n_Texp, single_broadening_parameters, R)
exojax.spec.initspec.init_dit(nu_lines, nu_grid, warning=False)
Initialization for DIT. i.e. Generate nu contribution and index for the

line shape density (actually, this is a numpy version of getix)

Parameters:
  • nu_lines – wavenumber list of lines [Nline] (should be numpy F64)

  • nu_grid – wavenumenr grid [Nnugrid] (should be numpy F64)

Returns:

cont (contribution) jnp.array index (index) jnp.array pmarray: (+1.,-1.) array whose length of len(nu_grid)+1

Note

cont is the contribution for i=index+1. 1 - cont is the contribution for i=index. For other i, the contribution should be zero.

exojax.spec.initspec.init_lpf(nu_lines, nu_grid)

Initialization for LPF.

Parameters:
  • nu_lines – wavenumber list of lines [Nline] (should be numpy F64)

  • nu_grid – wavenumenr grid [Nnugrid] (should be numpy F64)

Returns:

numatrix [Nline,Nnu]

exojax.spec.initspec.init_modit(nu_lines, nu_grid, warning=False)

Initialization for MODIT. i.e. Generate nu contribution and index for the line shape density (actually, this is a numpy version of getix)

Parameters:
  • nu_lines – wavenumber list of lines [Nline] (should be numpy F64)

  • nu_grid – wavenumenr grid [Nnugrid] (should be numpy F64)

Returns:

(contribution for q) jnp.array index: (index for q) jnp.array spectral_resolution: spectral resolution (R) pmarray: (+1.,-1.) array whose length of len(nu_grid)+1

Return type:

cont

Note

cont is the contribution for i=index+1. 1 - cont is the contribution for i=index. For other i, the contribution should be zero. dq is computed using numpy not jnp.numpy. If you use jnp, you might observe a significant residual because of the float32 truncation error.

exojax.spec.initspec.init_modit_vald(nu_linesM, nus, N_usp)

Initialization for MODIT for asdb from VALD

Parameters:
  • nu_linesM – wavenumbers of lines for each species [N_species x N_line] (should be numpy F64)

  • nu_grid – wavenumenr grid [Nnugrid] (should be numpy F64)

  • N_usp – number of species

Returns:

(contribution) jnp.array [N_species x N_line] indexS: (index) jnp.array [N_species x N_line] R: spectral resolution

pmarray: (+1,-1) array whose length of len(nu_grid)+1

Return type:

contS

exojax.spec.initspec.init_premodit(nu_lines, nu_grid, elower, gamma_ref, n_Texp, line_strength_ref, Twt, Tref, Tref_broadening, Tmax=None, Tmin=None, dE=160.0, dit_grid_resolution=0.2, diffmode=0, single_broadening=False, single_broadening_parameters=None, warning=False)

Initialization for PreMODIT.

Parameters:
  • nu_lines – wavenumber list of lines [Nline] (should be numpy F64)

  • nu_grid – wavenumenr grid [Nnugrid] (should be numpy F64)

  • elower – elower of lines

  • gamma_ref – half-width at reference (alpha_ref for ExoMol, gamma_air for HITRAN/HITEMP etc)

  • n_Texp – temperature exponent (n_Texp for ExoMol, n_air for HITRAN/HITEMP)

  • line_strength_ref – line strength at reference Tref

  • Twt – temperature for weight in Kelvin

  • Tref – reference temperature of premodit grid

  • Tref_broadening – reference temperature for broadening.

  • Tmax – max temperature to construct n_Texp grid, if None, max(Twt and Tref) is used

  • Tmin – min temperature to construct n_Texp grid, if None, max(Twt and Tref) is used

  • dE – Elower grid interval

  • dit_grid_resolution (float) – DIT grid resolution. when np.inf, the minmax simplex is used

  • diffmode (int) – i-th Taylor expansion is used for the weight, default is 1.

  • single_broadening (optional) – if True, single_braodening_parameters is used. Defaults to False.

  • single_broadening_parameters (optional) – [gamma_ref, n_Texp] at 296K for single broadening. When None, the median is used.

Returns:

contribution for wavenumber jnp.array index_nu: index for wavenumber jnp.array elower_grid: elower grid cont_broadpar: contribution for broadening parmaeters index_broadpar: index for broadening parmaeters R: spectral resolution pmarray: (+1,-1) array whose length of len(nu_grid)+1

Return type:

cont_nu

Note

cont is the contribution for i=index+1. 1 - cont is the contribution for i=index. For other i, the contribution should be zero. dq is computed using numpy not jnp.numpy. If you use jnp, you might observe a significant residual because of the float32 truncation error.

exojax.spec.initspec.warn_dtype64(arr, warning, tag='')

check arr’s dtype.

Parameters:
  • arr – input array

  • warning – True/False

  • tag

exojax.spec.initspec.warn_out_of_nu_grid(nu_lines, nu_grid)

warning for out-of-nu grid

Note

See Issue 341, https://github.com/HajimeKawahara/exojax/issues/341 Only for DIT and MODIT. For PreMODIT or newer Opacalc, this issue is automatically fixed.

Parameters:
  • nu_lines (_type_) – line center

  • nu_grid (_type_) – wavenumber grid

exojax.spec.initspec.warn_outside_wavenumber_grid(nu_lines, nu_grid)

Check if all the line centers are in the wavenumber grid.

Parameters:
  • nu_lines – line center

  • nu_grid – wavenumber grid

Note

For MODIT/DIT, if the lines whose center are outside of the wavenumber grid, they contribute the edges of the wavenumber grid. This function is to check it. This warning often occurs when you set non-negative value to margin in MdbExomol, MdbHit, AdbVALD, and AdbKurucz in moldb. See #190 for the details.

exojax.spec.layeropacity module

compute opacity difference in atmospheric layers

exojax.spec.layeropacity.layer_optical_depth(dParr, xsmatrix, mixing_ratio, mass, gravity)

dtau of the molecular cross section.

Note

opfac=bar_cgs/(m_u (g)). m_u: atomic mass unit. It can be obtained by fac=1.e3/m_u, where m_u = scipy.constants.m_u.

Parameters:
  • dParr – delta pressure profile (bar) [N_layer]

  • xsmatrix – cross section matrix (cm2) [N_layer, N_nus]

  • mixing_ratio – volume mixing ratio (VMR) or mass mixing ratio (MMR) [N_layer]

  • mass – mean molecular weight for VMR or molecular mass for MMR

  • gravity – gravity (cm/s2)

Returns:

optical depth matrix, dtau [N_layer, N_nus]

Return type:

2D array

exojax.spec.layeropacity.layer_optical_depth_CIA(nu_grid, temperature, pressure, dParr, vmr1, vmr2, mmw, g, nucia, tcia, logac)

dtau of the CIA continuum. Not used in art.

Parameters:
  • nu_grid – wavenumber matrix (cm-1)

  • temperature – temperature array (K)

  • pressure – pressure array (bar)

  • dParr – delta temperature array (bar)

  • vmr1 – volume mixing ratio (VMR) for molecules 1 [N_layer]

  • vmr2 – volume mixing ratio (VMR) for molecules 2 [N_layer]

  • mmw – mean molecular weight of atmosphere

  • g – gravity (cm2/s)

  • nucia – wavenumber array for CIA

  • tcia – temperature array for CIA

  • logac – log10(absorption coefficient of CIA)

Returns:

optical depth matrix, dtau [N_layer, N_nus]

Return type:

2D array

exojax.spec.layeropacity.layer_optical_depth_Hminus(nu_grid, temperature, Parr, dParr, vmre, vmrh, mmw, g)

dtau of the H- continuum.

Parameters:
  • nu_grid – wavenumber matrix (cm-1)

  • Tarr – temperature array (K)

  • Parr – temperature array (bar)

  • dParr – delta temperature array (bar)

  • vmre – volume mixing ratio (VMR) for e- [N_layer]

  • vmrH – volume mixing ratio (VMR) for H atoms [N_layer]

  • mmw – mean molecular weight of atmosphere

  • g – gravity (cm2/s)

Returns:

optical depth matrix [N_layer, N_nus]

exojax.spec.layeropacity.layer_optical_depth_VALD(dParr, xsm, VMR, mean_molecular_weight, gravity)

dtau of the atomic (+ionic) cross section from VALD.

Parameters:
  • dParr – delta pressure profile (bar) [N_layer]

  • xsm – cross section matrix (cm2) [N_species x N_layer x N_wav]

  • VMR – volume mixing ratio [N_species x N_layer]

  • mean_molecular_weight – mean molecular weight [N_layer]

  • gravity – gravity (cm/s2)

Returns:

optical depth matrix, dtau [N_layer, N_nus]

Return type:

2D array

exojax.spec.lbd module

exojax.spec.lbd.lbd_coefficients(elower_lines, elower_grid, Tref, Twt, diffmode=2, conversion_dtype=<class 'numpy.float64'>)

compute the LBD zeroth and first coefficients

Parameters:
  • elower_lines – Line’s Elower

  • elower_grid – Elower grid for LBD

  • Tref – reference tempreature to be used for the line strength S0

  • Twt – temperature used for the weight coefficient computation

  • diffmode (int) – i-th Taylor expansion is used for the weight, default is 2.

  • converted_dtype – data type for conversion. Needs enough large because this code uses exp.

Returns:

the zeroth coefficient at Point 2 the first coefficient at Point 2 index

Note

Twp (Temperature at the weight point) corresponds to Ttyp, but not typical temparture at all. zeroth and first coefficients are at Point 2, i.e. for i=index+1. 1 - zeroth_coefficient gives the zeroth coefficient at Point 1, i.e. for i=index. - first_coefficient gives the first coefficient at Point 1.

exojax.spec.lbd.weight(T, Twt, zeroth_coeff, first_coeff)

construct lbd from zeroth and first terms in the first Taylor approximation

Parameters:
  • Tref – reference tempreature to be used for the line strength S0

  • Twt (float) – temperature used for the weight coefficient computation

  • T (float) – _description_

  • Twt – _description_

  • zeroth_coeff (ndarray) – zeroth coefficient of the Taylor expansion of the weight at Twt

  • first_coeff (ndarray) – first coefficient of the Taylor expansion of the weight at Twt

Returns:

weight at the points 1 and 2

Return type:

ndarray

exojax.spec.lbderror module

exojax.spec.lbderror.default_elower_grid_trange_file()

default elower_grid_trange filename :returns: default_elower_grid_trange filename

Note

This file assumes 1 % precision of line strength within [Tl, Tu] default_elower_grid_trange_file generated by examples/gendata/gen_elower_grid_trange.py.

exojax.spec.lbderror.evaluate_trange(Tarr, tlide_line_strength, crit, Twt)

evaluate robust temperature range

Parameters:
  • Tarr (ndarray) – temperature array, shape = (N,)

  • tlide_line_strength (ndarray) – line strength error, shape = (N,)

  • crit (float) – criterion of line strength error (0.01=1%)

  • Twt (float) – weight temperature

Returns:

Tl, Tu. The line strength error is below crit within [Tl, Tu]

Return type:

float, float

exojax.spec.lbderror.optimal_params(Tl, Tu, diffmode=2, makefig=False, filename=None)
derive the optimal parameters for a given Tu and Tl,

which satisfies x % (1% if filename=None) precision within [Tl, Tu]

Parameters:
  • Tl (float) – lower temperature

  • Tu (float) – upper temperature

  • diffmode (int, optional) – diff mode. Defaults to 2.

  • makefig (bool, optional) – if you wanna make a fig. Defaults to False.

  • filename – grid_trange file, if None default_elower_grid_trange_file is used.

Returns:

dE, Tref, Twt (optimal ones)

Return type:

float

exojax.spec.lbderror.single_tilde_line_strength(t, w1, w2, tref, dE, p=0.5)
Parameters:
  • t (float) – inverse temperature

  • w1 (_type_) – weight at point 1

  • w2 (_type_) – weight at point 2

  • tref (_type_) – reference temperature

  • dE (_type_) – energy interval in cm-1

  • p (float, optional) – between 0 to 1 Defaults to 0.5.

Returns:

_description_

Return type:

_type_

exojax.spec.lbderror.single_tilde_line_strength_first(t, twp, tref, dE, p=0.5)

Single Line Line strength prediction for Premodit/diffmode=1

Parameters:
  • t (_type_) – inverse temperature

  • twp (_type_) – inverse weight temperature

  • tref (_type_) – inverse reference temperature

  • dE (_type_) – Elower interval

  • p (float, optional) – fraction of the line point. Defaults to 0.5.

Returns:

_description_

Return type:

_type_

exojax.spec.lbderror.single_tilde_line_strength_second(t, twp, tref, dE, p=0.5)

Single Line Line strength prediction for Premodit/diffmode=1

Parameters:
  • t (_type_) – inverse temperature

  • twp (_type_) – inverse weight temperature

  • tref (_type_) – inverse reference temperature

  • dE (_type_) – Elower interval

  • p (float, optional) – fraction of the line point. Defaults to 0.5.

Returns:

_description_

Return type:

_type_

exojax.spec.lbderror.single_tilde_line_strength_zeroth(t, twp, tref, dE, p=0.5)
exojax.spec.lbderror.weight_point1_dE(t, tref, dE, p=0.5)

dE version of the weight at point 1 for PreMODIT

Parameters:
  • t (float) – inverse temperature

  • tref (float) – reference inverse temperature

  • dE (float) – envergy interval between points 1 nad 2 (cm-1)

  • p (float) – between 0 to 1

Returns:

weight at point 1

exojax.spec.lbderror.weight_point2_dE(t, tref, dE, p=0.5)

dE version of the weight at point 2 for PreMODIT

Parameters:
  • t (float) – inverse temperature

  • tref (float) – reference inverse temperature

  • dE (float) – envergy interval between points 1 nad 2 (cm-1)

  • p (float) – between 0 to 1

Returns:

weight at point 2

exojax.spec.lbderror.worst_tilde_line_strength_first(T, Ttyp, Tref, dE)

worst deviation of single tilde line search first in terms of p

Parameters:
  • T (float, ndarray) – temperature (array) K

  • Twp (float) – weight temperature K

  • Tref (float) – reference tempearture K

  • dE (float) – Elower interval cm-1

Returns:

worst value of single_tilde_line_strength_first in terms of p

exojax.spec.lbderror.worst_tilde_line_strength_second(T, Ttyp, Tref, dE)

worst deviation of single tilde line search first in terms of p

Parameters:
  • T (float, ndarray) – temperature (array) K

  • Twp (float) – weight temperature K

  • Tref (float) – reference tempearture K

  • dE (float) – Elower interval cm-1

Returns:

worst value of single_tilde_line_strength_first in terms of p

exojax.spec.limb_darkening module

Limb darkening functions.

exojax.spec.limb_darkening.ld_kipping(q1, q2)

Uninformative prior conversion of the limb darkening by Kipping (arxiv:1308.0009)

Parameters:
  • q1 – U(0,1)

  • q2 – U(0,1)

Returns:

quadratic LD coefficient u1 u2: quadratic LD coefficient u2

Return type:

u1

exojax.spec.lpf module

Custom JVP version of the line profile functions used in exospectral analysis.

exojax.spec.lpf.auto_xsection(nu, nu_lines, sigmaD, gammaL, Sij, memory_size=15.0)

compute cross section.

Warning

This is NOT auto-differentiable function.

Parameters:
  • nu – wavenumber array

  • nu_lines – line center

  • sigmaD – sigma parameter in Doppler profile

  • gammaL – broadening coefficient in Lorentz profile

  • Sij – line strength

  • memory_size – memory size for numatrix0 (MB)

Returns:

cross section (xsv)

Return type:

numpy.array

Example

>>> from exojax.spec.lpf import auto_xsection
>>> from exojax.spec.hitran import SijT, doppler_sigma, gamma_hitran, gamma_natural
>>> from exojax.spec import moldb
>>> import numpy as np
>>> nus=np.linspace(1000.0,10000.0,900000,dtype=np.float64) #cm-1
>>> mdbCO=moldb.MdbHit('~/exojax/data/CO','05_hit12',nus)
>>> Mmol=28.010446441149536 # molecular weight
>>> Tfix=1000.0 # we assume T=1000K
>>> Pfix=1.e-3 # we compute P=1.e-3 bar
>>> Ppart=Pfix #partial pressure of CO. here we assume a 100% CO atmosphere.
>>> qt=mdbCO.qr_interp_lines(Tfix)
>>> Sij=SijT(Tfix,mdbCO.logsij0,mdbCO.nu_lines,mdbCO.elower,qt)
>>> gammaL = gamma_hitran(Pfix,Tfix, Ppart, mdbCO.n_air, mdbCO.gamma_air, mdbCO.gamma_self) + gamma_natural(mdbCO.A)
>>> sigmaD=doppler_sigma(mdbCO.nu_lines,Tfix,Mmol)
>>> nu_lines=mdbCO.nu_lines
>>> xsv=auto_xsection(nus,nu_lines,sigmaD,gammaL,Sij,memory_size=30)
 100%|████████████████████████████████████████████████████| 456/456 [00:03<00:00, 80.59it/s]
exojax.spec.lpf.exomol(mdb, Tarr, Parr, molmass)

compute 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.spec.lpf.hjert_jvp(primals, tangents)
exojax.spec.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.spec.lpf.vald(adb, Tarr, PH, PHe, PHH)

Compute 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.spec.lpf.vald_each(Tarr, PH, PHe, PHH, qt_284_T, QTmask, logsij0, nu_lines, ielem, iion, dev_nu_lines, elower, eupper, atomicmass, ionE, gamRad, gamSta, vdWdamp)

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

  • 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.spec.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.spec.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.spec.lpf.vvoigt(numatrix, sigmaD, gammas)

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.spec.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.spec.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.spec.lsd module

functions for computation of line shape density (LSD)

  • there are both numpy and jnp versions. (np)*** is numpy version.

  • (np)getix provides the contribution and index.

  • (np)add(x)D constructs the (x)Dimensional LSD array given the contribution and index.

exojax.spec.lsd.add2D(a, w, cx, ix, cy, iy)

Add into an array when contirbutions and indices are given (2D).

Parameters:
  • a – lineshape density (LSD) array (np.array)

  • w – weight (N)

  • cx – given contribution for x

  • ix – given index for x

  • cy – given contribution for y

  • iy – given index for y

Returns:

a

exojax.spec.lsd.add3D(a, w, cx, ix, cy, iy, cz, iz)

Add into an array when contirbutions and indices are given (3D).

Parameters:
  • a – lineshape density (LSD) array (np.array)

  • w – weight (N)

  • cx – given contribution for x

  • ix – given index for x

  • cy – given contribution for y

  • iy – given index for y

  • cz – given contribution for z

  • iz – given index for z

Returns:

a

exojax.spec.lsd.getix(x, xv)

jnp version of getix.

Parameters:
  • x – x array

  • xv – x grid, should be ascending order

Returns:

cont (contribution) index (index)

Note

cont is the contribution for i=index+1. 1 - cont is the contribution for i=index. For other i, the contribution should be zero.

Example

>>> from exojax.spec.lsd import getix
>>> import jax.numpy as jnp
>>> y=jnp.array([1.1,4.3])
>>> yv=jnp.arange(6)
>>> getix(y,yv)
(DeviceArray([0.10000002, 0.3000002 ], dtype=float32), DeviceArray([1, 4], dtype=int32))
exojax.spec.lsd.inc2D_givenx(a, w, cx, ix, y, yv)

Compute integrated neighbouring contribution for 2D LSD (memory reduced sum) but using given contribution and index for x .

Parameters:
  • a – lineshape density (LSD) array (jnp.array)

  • w – weight (N)

  • cx – given contribution for x

  • ix – given index for x

  • y – y values (N)

  • yv – y grid

Returns:

lineshape distribution matrix (integrated neighbouring contribution for 2D)

Note

This function computes sum_n w_n fx_n otimes fy_n, where w_n is the weight, fx_n, fy_n, are the n-th NCFs for 1D. A direct sum uses huge RAM.

exojax.spec.lsd.inc3D_givenx(a, w, cx, ix, y, z, xv, yv, zv)

Compute integrated neighbouring contribution for the 3D lineshape distribution (LSD) matrix (memory reduced sum) but using given contribution and index for x .

Parameters:
  • a – lineshape density (LSD) array (jnp.array)

  • w – weight (N)

  • cx – given contribution for x

  • ix – given index for x

  • y – y values (N)

  • z – z values (N)

  • xv – x grid

  • yv – y grid

  • zv – z grid

Returns:

lineshape distribution matrix (integrated neighbouring contribution for 3D)

Note

This function computes sum_n w_n fx_n otimes fy_n otimes fz_n, where w_n is the weight, fx_n, fy_n, and fz_n are the n-th NCFs for 1D. A direct sum uses huge RAM.

exojax.spec.lsd.npadd3D_direct1D(a, w, cx, ix, direct_cy, direct_iy, cz, iz, sumx=1.0, sumz=1.0)

numpy version: Add into an array when contirbutions and indices are given (2D+direct).

Parameters:
  • a – lineshape density (LSD) array (np.array)

  • w – weight (N)

  • cx – given contribution for x

  • ix – given index for x

  • direct_cy – direct contribution for y

  • direct_iy – direct index for y

  • cz – given contribution for z

  • iz – given index for z

  • sumx – a sum of contribution for x at point 1 and point 2, default=1.0

  • sumz – a sum of contribution for z at point 1 and point 2, default=1.0

Returns:

lineshape density a(nx,ny,nz)

Note

sumx or sumz gives a sum of contribution at point 1 and point 2. For the zeroth coeeficient, it should be 1.0 while it should be 0.0 for the first coefficient.

exojax.spec.lsd.npadd3D_multi_index(a, w, cx, ix, cz, iz, uidx, multi_cont_lines, neighbor_uidx, sumx=1.0, sumz=1.0)

numpy version: Add into an array using multi_index system in y :param a: lineshape density (LSD) array (np.array) :param w: weight (N) :param cx: given contribution for x :param ix: given index for x :param cz: given contribution for z :param iz: given index for z :param sumx: a sum of contribution for x at point 1 and point 2, default=1.0 :param sumz: a sum of contribution for z at point 1 and point 2, default=1.0

Returns:

lineshape density a(nx,ny,nz)

Note

sumx or sumz gives a sum of contribution at point 1 and point 2. For the zeroth coeeficient, it should be 1.0 while it should be 0.0 for the first coefficient.

exojax.spec.lsd.npgetix(x, xv)

numpy version of getix.

Parameters:
  • x – x array

  • xv – x grid, should be ascending order

Returns:

cont (contribution) index (index)

Note

cont is the contribution for i=index+1. 1 - cont is the contribution for i=index. For other i, the contribution should be zero.

exojax.spec.make_numatrix module

exojax.spec.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.spec.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.spec.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.spec.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.spec.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

exojax.spec.modit module

Line profile computation using Discrete Integral Transform.

exojax.spec.modit.calc_xsection_from_lsd(Slsd, R, pmarray, nsigmaD, nu_grid, log_ngammaL_grid)

Compute cross section from LSD in MODIT algorithm

The original code is rundit_fold_logredst in addit package ). MODIT folded voigt for ESLOG for reduced wavenumebr inputs (against the truncation error) for a constant normalized beta

Parameters:
  • Slsd – line shape density

  • R – spectral resolution

  • pmarray – (+1,-1) array whose length of len(nu_grid)+1

  • nsigmaD – normaized Gaussian STD

  • nu_grid – linear wavenumber grid

  • log_gammaL_grid – logarithm of gammaL grid

Note: When you have the error such as: “failed to initialize batched cufft plan with customized allocator: Allocating 8000000160 bytes exceeds the memory limit of 4294967296 bytes.” consider to use moditscanfft.calc_xsection_from_lsd, instead.

Returns:

Cross section in the log nu grid

exojax.spec.modit.dgmatrix(x, dit_grid_resolution=0.1, adopt=True)

DIT GRID MATRIX (alias)

Parameters:
  • x – simgaD or gammaL matrix (Nlayer x Nline)

  • dit_grid_resolution – grid resolution. dit_grid_resolution=0.1 (defaut) means a grid point per digit

  • adopt – if True, min, max grid points are used at min and max values of x. In this case, the grid width does not need to be dit_grid_resolution exactly.

Returns:

grid for DIT (Nlayer x NDITgrid)

exojax.spec.modit.ditgrid(x, dit_grid_resolution=0.1, adopt=True)

DIT GRID (deprecated).

Parameters:
  • x – simgaD or gammaL array (Nline)

  • dit_grid_resolution – grid resolution. res=0.1 (defaut) means a grid point per digit

  • adopt – if True, min, max grid points are used at min and max values of x. In this case, the grid width does not need to be res exactly.

Returns:

grid for DIT

exojax.spec.modit.exomol(mdb, Tarr, Parr, R, molmass)

compute molecular line information required for MODIT using Exomol mdb.

Parameters:
  • mdb – mdb instance

  • Tarr – Temperature array

  • Parr – Pressure array

  • R – spectral resolution

  • molmass – molecular mass

  • wavmask – mask for wavenumber #Issue 341

Returns:

line intensity matrix, normalized gammaL matrix, normalized sigmaD matrix

exojax.spec.modit.hitran(mdb, Tarr, Parr, Pself, R, molmass)

compute molecular line information required for MODIT using HITRAN/HITEMP mdb.

Parameters:
  • mdb – mdb instance

  • Tarr – Temperature array

  • Parr – Pressure array

  • Pself – Partial pressure array

  • R – spectral resolution

  • molmass – molecular mass

Returns:

line intensity matrix, normalized gammaL matrix, normalized sigmaD matrix

exojax.spec.modit.minmax_dgmatrix(x, dit_grid_resolution=0.1, adopt=True)

compute MIN and MAX DIT GRID MATRIX.

Parameters:
  • x – gammaL matrix (Nlayer x Nline)

  • dit_grid_resolution – grid resolution. dit_grid_resolution=0.1 (defaut) means a grid point per digit

  • adopt – if True, min, max grid points are used at min and max values of x. In this case, the grid width does not need to be dit_grid_resolution exactly.

Returns:

minimum and maximum for DIT (dgm_minmax)

exojax.spec.modit.precompute_dgmatrix(set_gm_minmax, dit_grid_resolution=0.1, adopt=True)

Precomputing MODIT GRID MATRIX for normalized GammaL.

Parameters:
  • set_gm_minmax – set of gm_minmax for different parameters [Nsample, Nlayers, 2], 2=min,max

  • dit_grid_resolution – grid resolution. dit_grid_resolution=0.1 (defaut) means a grid point per digit

  • adopt – if True, min, max grid points are used at min and max values of x. In this case, the grid width does not need to be dit_grid_resolution exactly.

Returns:

grid for DIT (Nlayer x NDITgrid)

exojax.spec.modit.set_ditgrid_matrix_exomol(mdb, fT, Parr, R, molmass, dit_grid_resolution, *kargs)

Easy Setting of DIT Grid Matrix (dgm) using Exomol.

Parameters:
  • mdb – mdb instance

  • fT – function of temperature array

  • Parr – pressure array

  • R – spectral resolution

  • molmass – molecular mass

  • dit_grid_resolution – resolution of dgm

  • *kargs – arguments for fT

Returns:

DIT Grid Matrix (dgm) of normalized gammaL

Example

>>> fT = lambda T0,alpha: T0[:,None]*(Parr[None,:]/Pref)**alpha[:,None]
>>> T0_test=np.array([1100.0,1500.0,1100.0,1500.0])
>>> alpha_test=np.array([0.2,0.2,0.05,0.05])
>>> dit_grid_resolution=0.2
>>> dgm_ngammaL=setdgm_exomol(mdbCH4,fT,Parr,R,molmassCH4,dit_grid_resolution,T0_test,alpha_test)
exojax.spec.modit.set_ditgrid_matrix_hitran(mdb, fT, Parr, Pself_ref, R, molmass, dit_grid_resolution, *kargs)

Easy Setting of DIT Grid Matrix (dgm) using HITRAN/HITEMP.

Parameters:
  • mdb – mdb instance

  • fT – function of temperature array

  • Parr – pressure array

  • Pself_ref – reference partial pressure array

  • R – spectral resolution

  • molmass – molecular mass

  • dit_grid_resolution – resolution of dgm

  • *kargs – arguments for fT

Returns:

DIT Grid Matrix (dgm) of normalized gammaL

Example

>>> fT = lambda T0,alpha: T0[:,None]*(Parr[None,:]/Pref)**alpha[:,None]
>>> T0_test=np.array([1100.0,1500.0,1100.0,1500.0])
>>> alpha_test=np.array([0.2,0.2,0.05,0.05])
>>> dit_grid_resolution=0.2
>>> dgm_ngammaL=setdgm_hitran(mdbCH4,fT,Parr,Pself,R,molmassCH4,dit_grid_resolution,T0_test,alpha_test)
exojax.spec.modit.set_ditgrid_matrix_vald_all(asdb, PH, PHe, PHH, R, fT, dit_grid_resolution, *kargs)

Easy Setting of DIT Grid Matrix (dgm) using VALD.

Parameters:
  • asdb – asdb instance made by the AdbSepVald class in moldb.py

  • 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]

  • R – spectral resolution

  • fT – function of temperature array

  • dit_grid_resolution – resolution of dgm

  • *kargs – arguments for fT

Returns:

DIT Grid Matrix (dgm) of normalized gammaL [N_species x N_layer x N_DITgrid]

Return type:

dgm_ngammaLS

Example

>>> fT = lambda T0,alpha:  T0[:,None]*(Parr[None,:]/Pref)**alpha[:,None]
>>> T0_test=np.array([3000.0,4000.0,3000.0,4000.0])
>>> alpha_test=np.array([0.2,0.2,0.05,0.05])
>>> dit_grid_resolution=0.2
>>> dgm_ngammaLS = setdgm_vald_all(asdb, PH, PHe, PHH, R, fT, dit_grid_resolution, T0_test, alpha_test)
exojax.spec.modit.set_ditgrid_matrix_vald_each(ielem, iion, atomicmass, ionE, dev_nu_lines, logsij0, elower, eupper, gamRad, gamSta, vdWdamp, QTmask, T_gQT, gQT_284species, PH, PHe, PHH, R, fT, dit_grid_resolution, *kargs)

Easy Setting of DIT Grid Matrix (dgm) using VALD.

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

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

  • atomicmass – atomic mass (amu)

  • ionE – ionization potential (eV)

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

  • logsij0 – log line strength at T=Tref

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

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

  • 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)

  • T_gQT – temperature in the grid obtained from the adb instance

  • gQT_284species – partition function in the grid from the adb instance

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

  • 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]

  • R – spectral resolution

  • fT – function of temperature array

  • dit_grid_resolution – resolution of dgm

  • *kargs – arguments for fT

Returns:

DIT Grid Matrix (dgm) of normalized gammaL [N_layer x N_DITgrid]

Return type:

dgm_ngammaL

exojax.spec.modit.setdgm_exomol(mdb, fT, Parr, R, molmass, dit_grid_resolution, *kargs)
exojax.spec.modit.setdgm_hitran(mdb, fT, Parr, Pself_ref, R, molmass, dit_grid_resolution, *kargs)
exojax.spec.modit.setdgm_vald_all(asdb, PH, PHe, PHH, R, fT, dit_grid_resolution, *kargs)
exojax.spec.modit.setdgm_vald_each(ielem, iion, atomicmass, ionE, dev_nu_lines, logsij0, elower, eupper, gamRad, gamSta, vdWdamp, QTmask, T_gQT, gQT_284species, PH, PHe, PHH, R, fT, dit_grid_resolution, *kargs)
exojax.spec.modit.vald_all(asdb, Tarr, PH, PHe, PHH, R)

Compute atomic line information required for MODIT for separated ALL species, using VALD separated atomic database (asdb).

Parameters:
  • asdb – asdb instance made by the AdbSepVald class in moldb.py

  • 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]

  • R – spectral resolution [scalar]

Returns:

line intensity matrix [N_species x N_layer x N_line] ngammaLMS: normalized gammaL matrix [N_species x N_layer x N_line] nsigmaDlS: normalized sigmaD matrix [N_species x N_layer x 1]

Return type:

SijMS

exojax.spec.modit.vald_each(Tarr, PH, PHe, PHH, R, qt_284_T, QTmask, ielem, iion, atomicmass, ionE, dev_nu_lines, logsij0, elower, eupper, gamRad, gamSta, vdWdamp)

Compute atomic line information required for MODIT for separated EACH species, using parameters attributed in VALD separated atomic database (asdb).

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]

  • R – spectral resolution [scalar]

  • 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

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

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

  • atomicmass – atomic mass (amu)

  • ionE – ionization potential (eV)

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

  • logsij0 – log line strength at T=Tref

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

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

  • 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] ngammaLM: normalized gammaL matrix [N_layer x N_line] nsigmaDl: normalized sigmaD matrix [N_layer x 1]

Return type:

SijM

exojax.spec.modit.xsmatrix(cnu, indexnu, R, pmarray, nsigmaDl, ngammaLM, SijM, nu_grid, dgm_ngammaL)

Cross section matrix for xsvector (MODIT)

Notes

Currently due to #277, we recommend to use modit_scanfft.xsmatrix_scanfft instead of xsmatrix. However, this will be changed when cufft fixes the 4GB limit.

Parameters:
  • cnu – contribution by npgetix for wavenumber

  • indexnu – index by npgetix for wavenumber

  • R – spectral resolution

  • pmarray – (+1,-1) array whose length of len(nu_grid)+1

  • nu_lines – line center (Nlines)

  • nsigmaDl – normalized doppler sigma in layers in R^(Nlayer x 1)

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

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

  • nu_grid – linear wavenumber grid

  • dgm_ngammaL – DIT Grid Matrix for normalized gammaL R^(Nlayer, NDITgrid)

Returns:

cross section matrix in R^(Nlayer x Nwav)

exojax.spec.modit.xsmatrix_vald(cnuS, indexnuS, R, pmarray, nsigmaDlS, ngammaLMS, SijMS, nu_grid, dgm_ngammaLS)

Cross section matrix for xsvector (MODIT) for VALD lines (asdb)

Parameters:
  • cnuS – contribution by npgetix for wavenumber [N_species x N_line]

  • indexnuS – index by npgetix for wavenumber [N_species x N_line]

  • R – spectral resolution

  • pmarray – (+1,-1) array whose length of len(nu_grid)+1

  • nsigmaDlS – normalized sigmaD matrix [N_species x N_layer x 1]

  • ngammaLMS – normalized gammaL matrix [N_species x N_layer x N_line]

  • SijMS – line intensity matrix [N_species x N_layer x N_line]

  • nu_grid – linear wavenumber grid

  • dgm_ngammaLS – DIT Grid Matrix (dgm) of normalized gammaL [N_species x N_layer x N_DITgrid]

Returns:

cross section matrix [N_species x N_layer x N_wav]

Return type:

xsmS

exojax.spec.modit.xsvector(cnu, indexnu, R, pmarray, nsigmaD, ngammaL, S, nu_grid, ngammaL_grid)

Cross section vector (MODIT)

Notes

Currently due to #277, we recommend to use modit_scanfft.xsvector_scanfft instead of xsvector. However, this will be changed when cufft fixes the 4GB limit.

Parameters:
  • cnu – contribution by npgetix for wavenumber

  • indexnu – index by npgetix for wavenumber

  • R – spectral resolution

  • pmarray – (+1,-1) array whose length of len(nu_grid)+1

  • nsigmaD – normaized Gaussian STD

  • gammaL – Lorentzian half width (Nlines)

  • S – line strength (Nlines)

  • nu_grid – linear wavenumber grid

  • gammaL_grid – gammaL grid

Returns:

Cross section in the log nu grid

exojax.spec.modit_scanfft module

Line profile computation using Discrete Integral Transform using scan+fft (#277).

  • MODIT using scan+fft allows > 4GB fft memory. but approximately 2 times slower than modit.

  • When you use modit and get the error such as “failed to initialize batched cufft plan with customized allocator: Allocating 8000000160 bytes exceeds the memory limit of 4294967296 bytes.”,

you should consider to modit_scanfft

exojax.spec.modit_scanfft.calc_xsection_from_lsd_scanfft(Slsd, R, pmarray, nsigmaD, nu_grid, log_ngammaL_grid)

Compute cross section from LSD in MODIT algorithm using scan+fft to avoid 4GB memory limit in fft (see #277)

Parameters:
  • Slsd – line shape density

  • R – spectral resolution

  • pmarray – (+1,-1) array whose length of len(nu_grid)+1

  • nsigmaD – normaized Gaussian STD

  • nu_grid – linear wavenumber grid

  • log_gammaL_grid – logarithm of gammaL grid

Returns:

Cross section in the log nu grid

exojax.spec.modit_scanfft.xsmatrix_scanfft(cnu, indexnu, R, pmarray, nsigmaDl, ngammaLM, SijM, nu_grid, dgm_ngammaL)

Cross section matrix for xsvector (MODIT), scan+fft

Parameters:
  • cnu – contribution by npgetix for wavenumber

  • indexnu – index by npgetix for wavenumber

  • R – spectral resolution

  • pmarray – (+1,-1) array whose length of len(nu_grid)+1

  • nu_lines – line center (Nlines)

  • nsigmaDl – normalized doppler sigma in layers in R^(Nlayer x 1)

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

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

  • nu_grid – linear wavenumber grid

  • dgm_ngammaL – DIT Grid Matrix for normalized gammaL R^(Nlayer, NDITgrid)

Returns:

cross section matrix in R^(Nlayer x Nwav)

exojax.spec.modit_scanfft.xsmatrix_vald_scanfft(cnuS, indexnuS, R, pmarray, nsigmaDlS, ngammaLMS, SijMS, nu_grid, dgm_ngammaLS)

Cross section matrix for xsvector (MODIT) with scan+fft, for VALD lines (asdb)

Parameters:
  • cnuS – contribution by npgetix for wavenumber [N_species x N_line]

  • indexnuS – index by npgetix for wavenumber [N_species x N_line]

  • R – spectral resolution

  • pmarray – (+1,-1) array whose length of len(nu_grid)+1

  • nsigmaDlS – normalized sigmaD matrix [N_species x N_layer x 1]

  • ngammaLMS – normalized gammaL matrix [N_species x N_layer x N_line]

  • SijMS – line intensity matrix [N_species x N_layer x N_line]

  • nu_grid – linear wavenumber grid

  • dgm_ngammaLS – DIT Grid Matrix (dgm) of normalized gammaL [N_species x N_layer x N_DITgrid]

Returns:

cross section matrix [N_species x N_layer x N_wav]

Return type:

xsmS

exojax.spec.modit_scanfft.xsvector_scanfft(cnu, indexnu, R, pmarray, nsigmaD, ngammaL, S, nu_grid, ngammaL_grid)

Cross section vector (MODIT scanfft)

Parameters:
  • cnu – contribution by npgetix for wavenumber

  • indexnu – index by npgetix for wavenumber

  • R – spectral resolution

  • pmarray – (+1,-1) array whose length of len(nu_grid)+1

  • nsigmaD – normaized Gaussian STD

  • gammaL – Lorentzian half width (Nlines)

  • S – line strength (Nlines)

  • nu_grid – linear wavenumber grid

  • gammaL_grid – gammaL grid

Returns:

Cross section in the log nu grid

exojax.spec.moldb module

Molecular database (MDB) class.

class exojax.spec.moldb.AdbKurucz(path, nurange=[- inf, inf], margin=0.0, crit=0.0, Irwin=False, gpu_transfer=True, vmr_fraction=None)

Bases: object

atomic database from Kurucz (http://kurucz.harvard.edu/linelists/)

AdbKurucz is a class for Kurucz line list.

nurange

nu range [min,max] (cm-1)

nu_lines

line center (cm-1) (#NOT frequency in (s-1))

Type:

nd array

dev_nu_lines

line center (cm-1) in device

Type:

jnp array

Sij0

line strength at T=Tref (cm)

Type:

nd array

logsij0

log line strength at T=Tref

Type:

jnp array

A

Einstein A coeeficient in (s-1)

Type:

jnp array

elower

the lower state energy (cm-1)

Type:

jnp array

eupper

the upper state energy (cm-1)

Type:

jnp array

gupper

(jnp array): upper statistical weight

jlower

lower J (rotational quantum number, total angular momentum)

Type:

jnp array

jupper

upper J

Type:

jnp array

QTmask

identifier of species for Q(T)

Type:

jnp array

ielem

atomic number (e.g., Fe=26)

Type:

jnp array

iion

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

Type:

jnp array

gamRad

log of gamma of radiation damping (s-1) #(https://www.astro.uu.se/valdwiki/Vald3Format)

Type:

jnp array

gamSta

log of gamma of Stark damping (s-1)

Type:

jnp array

vdWdamp

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

Type:

jnp array

Atomic_gQT(atomspecies)

Select grid of partition function especially for the species of interest.

Parameters:

atomspecies – species e.g., “Fe 1”, “Sr 2”, etc.

Returns:

grid Q(T) for the species

Return type:

gQT

QT_interp(atomspecies, T)

interpolated partition function The partition functions of Barklem & Collet (2016) are adopted.

Parameters:
  • atomspecies – species e.g., “Fe 1”

  • T – temperature

Returns:

interpolated in jnp.array for the Atomic Species

Return type:

Q(T)

QT_interp_284(T)

interpolated partition function of all 284 species.

Parameters:

T – temperature

Returns:

interpolated in jnp.array for all 284 Atomic Species

Return type:

Q(T)*284

QT_interp_Irwin_Fe(T, atomspecies='Fe 1')

interpolated partition function This function is for the exceptional case where you want to adopt partition functions of Irwin (1981) for Fe I (Other species are not yet implemented).

Parameters:
  • atomspecies – species e.g., “Fe 1”

  • T – temperature

Returns:

interpolated in jnp.array for the Atomic Species

Return type:

Q(T)

generate_jnp_arrays()

(re)generate jnp.arrays.

Note

We have nd arrays and jnp arrays. We usually apply the mask to nd arrays and then generate jnp array from the corresponding nd array. For instance, self._A is nd array and self.A is jnp array.

make_QTmask(ielem, iion)

Convert the species identifier to the index for Q(Tref) grid (gQT) for each line.

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

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

Returns:

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

Return type:

QTmask_sp

masking(mask)

applying mask

Parameters:

mask – mask to be applied. self.mask is updated.

qr_interp(atomspecies, T)

interpolated partition function ratio The partition functions of Barklem & Collet (2016) are adopted.

Parameters:
  • T – temperature

  • atomspecies – species e.g., “Fe 1”

Returns:

interpolated in jnp.array

Return type:

qr(T)=Q(T)/Q(Tref)

qr_interp_Irwin_Fe(T, atomspecies='Fe 1')

interpolated partition function ratio This function is for the exceptional case where you want to adopt partition functions of Irwin (1981) for Fe I (Other species are not yet implemented).

Parameters:
  • T – temperature

  • atomspecies – species e.g., “Fe 1”

Returns:

interpolated in jnp.array

Return type:

qr(T)=Q(T)/Q(Tref)

class exojax.spec.moldb.AdbSepVald(adb)

Bases: object

atomic database from VALD3 with an additional axis for separating each species (atom or ion)

AdbSepVald is a class for VALD3.

nu_lines

line center (cm-1) (#NOT frequency in (s-1))

Type:

nd array

dev_nu_lines

line center (cm-1) in device

Type:

jnp array

logsij0

log line strength at T=Tref

Type:

jnp array

elower

the lower state energy (cm-1)

Type:

jnp array

eupper

the upper state energy (cm-1)

Type:

jnp array

QTmask

identifier of species for Q(T)

Type:

jnp array

ielem

atomic number (e.g., Fe=26)

Type:

jnp array

iion

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

Type:

jnp array

atomicmass

atomic mass (amu)

Type:

jnp array

ionE

ionization potential (eV)

Type:

jnp array

gamRad

log of gamma of radiation damping (s-1) #(https://www.astro.uu.se/valdwiki/Vald3Format)

Type:

jnp array

gamSta

log of gamma of Stark damping (s-1)

Type:

jnp array

vdWdamp

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

Type:

jnp array

uspecies

unique combinations of ielem and iion [N_species x 2(ielem and iion)]

Type:

jnp array

N_usp

number of species (atoms and ions)

Type:

int

L_max

maximum number of spectral lines for a single species

Type:

int

gQT_284species

partition function grid of 284 species

Type:

jnp array

T_gQT

temperatures in the partition function grid

Type:

jnp array

class exojax.spec.moldb.AdbVald(path, nurange=[- inf, inf], margin=0.0, crit=0.0, Irwin=False, gpu_transfer=True)

Bases: object

atomic database from VALD3 (http://vald.astro.uu.se/)

AdbVald is a class for VALD3.

nurange

nu range [min,max] (cm-1)

nu_lines

line center (cm-1) (#NOT frequency in (s-1))

Type:

nd array

dev_nu_lines

line center (cm-1) in device

Type:

jnp array

Sij0

line strength at T=Tref (cm)

Type:

nd array

logsij0

log line strength at T=Tref

Type:

jnp array

A

Einstein A coeeficient in (s-1)

Type:

jnp array

elower

the lower state energy (cm-1)

Type:

jnp array

eupper

the upper state energy (cm-1)

Type:

jnp array

gupper

(jnp array): upper statistical weight

jlower

lower J (rotational quantum number, total angular momentum)

Type:

jnp array

jupper

upper J

Type:

jnp array

QTmask

identifier of species for Q(T)

Type:

jnp array

ielem

atomic number (e.g., Fe=26)

Type:

jnp array

iion

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

Type:

jnp array

solarA

solar abundance (log10 of number density in the Sun)

Type:

jnp array

atomicmass

atomic mass (amu)

Type:

jnp array

ionE

ionization potential (eV)

Type:

jnp array

gamRad

log of gamma of radiation damping (s-1) #(https://www.astro.uu.se/valdwiki/Vald3Format)

Type:

jnp array

gamSta

log of gamma of Stark damping (s-1)

Type:

jnp array

vdWdamp

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

Type:

jnp array

Note

For the first time to read the VALD line list, it is converted to HDF/vaex. After the second-time, we use the HDF5 format with vaex instead.

Atomic_gQT(atomspecies)

Select grid of partition function especially for the species of interest.

Parameters:

atomspecies – species e.g., “Fe 1”, “Sr 2”, etc.

Returns:

grid Q(T) for the species

Return type:

gQT

QT_interp(atomspecies, T)

interpolated partition function The partition functions of Barklem & Collet (2016) are adopted.

Parameters:
  • atomspecies – species e.g., “Fe 1”

  • T – temperature

Returns:

interpolated in jnp.array for the Atomic Species

Return type:

Q(T)

QT_interp_284(T)

interpolated partition function of all 284 species.

Parameters:

T – temperature

Returns:

interpolated in jnp.array for all 284 Atomic Species

Return type:

Q(T)*284

QT_interp_Irwin_Fe(T, atomspecies='Fe 1')

interpolated partition function This function is for the exceptional case where you want to adopt partition functions of Irwin (1981) for Fe I (Other species are not yet implemented).

Parameters:
  • atomspecies – species e.g., “Fe 1”

  • T – temperature

Returns:

interpolated in jnp.array for the Atomic Species

Return type:

Q(T)

generate_jnp_arrays()

(re)generate jnp.arrays.

Note

We have nd arrays and jnp arrays. We usually apply the mask to nd arrays and then generate jnp array from the corresponding nd array. For instance, self._A is nd array and self.A is jnp array.

make_QTmask(ielem, iion)

Convert the species identifier to the index for Q(Tref) grid (gQT) for each line.

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

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

Returns:

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

Return type:

QTmask_sp

masking(mask)

applying mask.

Parameters:

mask – mask to be applied. self.mask is updated.

qr_interp(atomspecies, T)

interpolated partition function ratio The partition functions of Barklem & Collet (2016) are adopted.

Parameters:
  • T – temperature

  • atomspecies – species e.g., “Fe 1”

Returns:

interpolated in jnp.array

Return type:

qr(T)=Q(T)/Q(Tref)

qr_interp_Irwin_Fe(T, atomspecies='Fe 1')

interpolated partition function ratio This function is for the exceptional case where you want to adopt partition functions of Irwin (1981) for Fe I (Other species are not yet implemented).

Parameters:
  • T – temperature

  • atomspecies – species e.g., “Fe 1”

Returns:

interpolated in jnp.array

Return type:

qr(T)=Q(T)/Q(Tref)

exojax.spec.molinfo module

exojax.spec.molinfo.isotope_molmass(exact_molecule_name)

isotope molecular mass

Parameters:

exact_molecule_name (str) – exact exomol, hitran, molecule name such as 12C-16O, (12C)(16O)

Returns:

molecular mass g/mol

Return type:

float or None

exojax.spec.molinfo.mean_molmass_manual(simple_molecule_name)

molecular mass for major isotope given manually

Parameters:

simple_molecule_name (_type_) – _description_

Returns:

_description_

Return type:

_type_

exojax.spec.molinfo.molmass(simple_molecule_name, db_HIT=True)

provide molecular mass for the major isotope from the simple molecular name.

Parameters:
  • molecule – molecular name e.g. CO2, He

  • db_HIT – if True, use the molecular mass considering the natural terrestrial abundance and mass of each isotopologue provided by HITRAN (https://hitran.org/docs/iso-meta/)

Returns:

molecular mass

Example

>>> from exojax.spec.moinfo import mean_molmass
>>> print(molmass("H2"))
>>> 2.01588
>>> print(molmass("CO2"))
>>> 44.0095
>>> print(molmass("He"))
>>> 4.002602
>>> print(molmass("air"))
>>> 28.97
exojax.spec.molinfo.molmass_isotope(simple_molecule_name, db_HIT=True)

provide molecular mass for the major isotope from the simple molecular name.

Parameters:
  • molecule – molecular name e.g. CO2, He

  • db_HIT – if True, use the molecular mass considering the natural terrestrial abundance and mass of each isotopologue provided by HITRAN (https://hitran.org/docs/iso-meta/)

Returns:

molecular mass

Example

>>> from exojax.spec.moinfo import mean_molmass
>>> print(molmass("H2"))
>>> 2.01588
>>> print(molmass("CO2"))
>>> 44.0095
>>> print(molmass("He"))
>>> 4.002602
>>> print(molmass("air"))
>>> 28.97

exojax.spec.multimol module

class exojax.spec.multimol.MultiMol(molmulti, dbmulti, database_root_path='.database')

Bases: object

multiple molecular database handler

Notes

MultiMol provides an easy way to generate multiple mdb (multimdb) and multiple opa (multiopa) for multiple molecules/wavenumber segements.

molmulti

multiple simple molecule names [n_wavenumber_segments, n_molecules], such as [[“H2O”,”CO”],[“H2O”],[“CO”]]

dbmulti

multiple database names, such as [[“HITEMP”,”EXOMOL”],[“HITEMP”,”HITRAN12”]]]

masked_molmulti

masked multiple simple molecule names [n_wavenumber_segments, n_molecules], such as [[“H2O”,”CO”],[“H2O”],[False]] Note that “False” is assigned when the code fails to get mdb because, for example, there are no transition lines for the specified condition.

database_root_path

database root path

db_dirs

database directories

mols_unique

the list of the unique molecules,

mols_num

the same shape as self.masked_molmulti but gives indices of mols_unique

multimdb()

return multiple mdb

multiopa_premodit()

return multiple opa for premodit

molmass()

return molecular mass list

derive_unique_molecules()

derive unique molecules in masked_molmulti and set self.mols_unique and self.mols_num

Notes

self.mols_unique is the list of the unique molecules, and self.mols_num has the same shape as self.masked_molmulti but gives indices of self.mols_unique

generate_database_directories()

generate database directory array

molmass()

return molecular mass list and H and He

Returns:

molecular mass list for self.mols_unique molmassH2: molecular mass for hydorogen molmassHe: molecular mass for helium

Return type:

molmass_list

multimdb(nu_grid_list, crit=0.0, Ttyp=1000.0)

select current multimols from wavenumber grid

Notes

multimdb() also generates self.masked_molmulti (masked molmulti), self.mols_unique (unique molecules), and self.mols_num (same shape as self.masked_molmulti but gives indices of self.mols_unique)

Parameters:
  • nu_grid_list (_type_) – _description_

  • crit (_type_, optional) – _description_. Defaults to 0..

  • Ttyp (_type_, optional) – _description_. Defaults to 1000..

Returns:

multi mdb

Return type:

lists of mdb

multiopa_premodit(multimdb, nu_grid_list, auto_trange, diffmode=2, dit_grid_resolution=0.2)

multiple opa for PreMODIT

Parameters:
  • () (nu_grid_list) – multimdb

  • () – wavenumber grid list

  • auto_trange (optional) – temperature range [Tl, Tu], in which line strength is within 1 % prescision. Defaults to None.

  • diffmode (int, optional) – _description_. Defaults to 2.

  • dit_grid_resolution (float, optional) – force to set broadening_parameter_resolution={mode:manual, value: dit_grid_resolution}), ignores broadening_parameter_resolution.

Returns:

_description_

Return type:

_type_

exojax.spec.multimol.database_path_exomol(simple_molecule_name)

default ExoMol path

Parameters:

simple_molecule_name (str) – simple molecule name “H2O”

Returns:

Exomol default data path

Return type:

str

exojax.spec.multimol.database_path_hitemp(simple_molname)

default HITEMP path based on https://hitran.org/hitemp/

Parameters:

simple_molecule_name (str) – simple molecule name “H2O”

Returns:

HITEMP default data path, such as “H2O/01_HITEMP2010” for “H2O”

Return type:

str

exojax.spec.multimol.database_path_hitran12(simple_molecule_name)

HITRAN12 default data path

Parameters:

simple_molecule_name (str) – simple molecule name “H2O”

Returns:

HITRAN12 default data path, such as “H2O/01_hit12.par” for “H2O”

Return type:

str

exojax.spec.nonair module

exojax.spec.nonair.gamma_nonair(m, coeff)

non air gamma (Lorentian width at reference)

Parameters:
  • m (int array) – m transition state

  • coeff (array) – nonair coefficient (a,b,a’,b’)

Returns:

nonair Lorentian width at reference (cm-1)

Return type:

float array

exojax.spec.nonair.nonair_polynomial(m, a_coeff, b_coeff)

nonair polynomial

Notes

value = ((a0 + a1 * x + a2 * x**2 + a3 * x**3) / (1 + b1 * x + b2 * x**2 + b3 * x**3 + b4 * x**4)) where x = m

Parameters:
  • m (int array) – m transition state

  • a_coeff (array) – nonair coefficient a

  • b_coeff (array) – nonair coefficient b

Returns:

nonair value

Return type:

float array

exojax.spec.nonair.temperature_exponent_nonair(m, coeff)

non air temperature exponent

Parameters:
  • m (int array) – m transition state

  • coeff (array) – nonair coefficient (a,b,a’,b’)

Returns:

nonair tempearure exponent

Return type:

float array

exojax.spec.opacalc module

opacity calculator class

Notes

Opa does not assume any T-P structure, no fixed T, P, mmr grids.

class exojax.spec.opacalc.OpaDirect(mdb, nu_grid, wavelength_order='descending')

Bases: OpaCalc

apply_params()
xsmatrix(Tarr, Parr)

cross section matrix

Notes

Currently Pself is regarded to be zero for HITEMP/HITRAN

Parameters:
  • () (Parr) – tempearture array in K

  • () – pressure array in bar

Raises:

ValueError – _description_

Returns:

cross section matrix (Nlayer, N_wavenumber)

Return type:

jnp.array

xsvector(T, P, Pself=0.0)

cross section vector

Parameters:
  • T (float) – temperature

  • P (float) – pressure in bar

  • Pself (float, optional) – self pressure for HITEMP/HITRAN. Defaults to 0.0.

Returns:

cross section in cm2

Return type:

1D array

class exojax.spec.opacalc.OpaModit(mdb, nu_grid, Tarr_list=None, Parr=None, Pself_ref=None, dit_grid_resolution=0.2, allow_32bit=False, wavelength_order='descending')

Bases: OpaCalc

Opacity Calculator Class for MODIT

opainfo

information set used in MODIT: cont_nu, index_nu, R, pmarray

apply_params()
setdgm(Tarr_list, Parr, Pself_ref=None)

_summary_

Parameters:
  • Tarr_list (1d or 2d array) – tempearture array to be tested such as [Tarr_1, Tarr_2, …, Tarr_n]

  • Parr (1d array) – pressure array in bar

  • Pself_ref (1d array, optional) – self pressure array in bar. Defaults to None. If None Pself = 0.0.

Returns:

dgm (DIT grid matrix) for gammaL

Return type:

_type_

xsmatrix(Tarr, Parr)

cross section matrix

Notes

Currently Pself is regarded to be zero for HITEMP/HITRAN

Parameters:
  • () (Parr) – tempearture array in K

  • () – pressure array in bar

Raises:

ValueError – _description_

Returns:

cross section matrix (Nlayer, N_wavenumber)

Return type:

jnp.array

xsvector(T, P, Pself=0.0)

cross section vector

Parameters:
  • T (float) – temperature

  • P (float) – pressure in bar

  • Pself (float, optional) – self pressure for HITEMP/HITRAN. Defaults to 0.0.

Returns:

cross section in cm2

Return type:

1D array

class exojax.spec.opacalc.OpaPremodit(mdb, nu_grid, diffmode=0, broadening_resolution={'mode': 'manual', 'value': 0.2}, auto_trange=None, manual_params=None, dit_grid_resolution=None, allow_32bit=False, wavelength_order='descending')

Bases: OpaCalc

Opacity Calculator Class for PreMODIT

opainfo

information set used in PreMODIT

apply_params()
auto_setting(Tl, Tu)
broadening_parameters_setting()
compute_gamma_ref_and_n_Texp(mdb)

convert gamma_ref to the regular formalization and noramlize it for Tref_braodening

Notes

gamma (T) = (gamma at Tref_original) * (Tref_original/Tref_broadening)**n * (T/Tref_broadening)**-n * (P/1bar)

Parameters:

mdb (_type_) – mdb instance

determine_broadening_parameter_resolution(broadening_parameter_resolution, dit_grid_resolution)
manual_setting(dE, Tref, Twt, Tmax=None, Tmin=None)

setting PreMODIT parameters by manual

Parameters:
  • dE (float) – E lower grid interval (cm-1)

  • Tref (float) – reference temperature (K)

  • Twt (float) – Temperature for weight (K)

  • Tmax (float/None) – max temperature (K) for braodening grid

  • Tmin (float/None) – min temperature (K) for braodening grid

plot_broadening_parameters(figname='broadpar_grid.png', crit=300000)

plot broadening parameters and grids

Parameters:
  • figname (str, optional) – output image file. Defaults to “broadpar_grid.png”.

  • crit (int, optional) – sampling criterion. Defaults to 300000. when the number of lines is huge and if it exceeded ~ crit, we sample the lines to reduce the computation.

set_Tref_broadening_to_midpoint()

Set self.Tref_broadening using log midpoint of Tmax and Tmin

set_nu_grid(x0, x1, unit, resolution=700000, Nx=None)
xsmatrix(Tarr, Parr)

cross section matrix

Parameters:
  • () (Parr) – tempearture array in K

  • () – pressure array in bar

Raises:

ValueError – _description_

Returns:

cross section matrix (Nlayer, N_wavenumber)

Return type:

jnp.array

xsvector(T, P)

exojax.spec.opachord module

exojax.spec.opachord.chord_geometric_matrix(height, radius_lower)

compute chord geometric matrix

Parameters:
  • height (1D array) – (normalized) height of the layers from top atmosphere, Nlayer

  • radius_lower (1D array) – (normalized) radius at the lower boundary from top to bottom (R0), (Nlayer)

Returns:

chord geometric matrix (Nlayer, Nlayer), lower triangle matrix

Return type:

2D array

Notes

Our definitions of the radius_lower and height (and radius_top, internally defined) are as follows: n=0,1,…,N-1 radius_lower[N-1] = radius_btm (i.e. R0) radius_lower[n-1] = radius_lower[n] + height[n] radius_top = radius_lower[0] + height[0]

exojax.spec.opachord.chord_optical_depth(chord_geometric_matrix, dtau)

chord optical depth vector from a chord geometric matrix and dtau

Parameters:
  • chord_geometric_matrix (jnp array) – chord geometric matrix (Nlayer, Nlayer), lower triangle matrix

  • dtau (jnp array) – layer optical depth matrix, dtau (Nlayer, N_wavenumber)

Returns: chord optical depth (tauchord) matrix (Nlayer, N_wavenumber)

exojax.spec.opacitytools module

Extract tau=1 height pressure at different wavelengths

exojax.spec.opacitytools.pressure_at_given_opacity(dtau, Parr, tauextracted=1.0)

Extract pressure of tau=1(or a given value) at different wavelengths

Parameters:
  • dtau – delta tau for each layer [N_layer x N_nu]

  • Parr – pressure at each layer [N_layer]

  • tauextracted – the tau value at which pressure is extracted

Returns:

[N_nu]

Return type:

P_tauone

Note

Return 0 if tau is too optically thin and does not reach tauextracted.

exojax.spec.opacont module

opacity continuum calculator class

Notes

Opa does not assume any T-P structure, no fixed T, P, mmr grids.

class exojax.spec.opacont.OpaCIA(cdb, nu_grid, wavelength_order='descending')

Bases: OpaCont

Opacity Continuum Calculator Class for CIA

logacia_matrix(temperature)
logacia_vector(T)
opainfo

exojax.spec.optgrid module

exojax.spec.optgrid.optelower(mdb, nu_grid, Tmax, Pmin, accuracy=0.01, dE=100.0, display=False)

look for the value of the optimal maximum Elower

Note

The memory use of PreModit depends on the maximum Elower of mdb. This function determine the optimal maximum Elower that does not change the cross section within the accuracy.

Parameters:
  • mdb (mdb) – molecular db

  • nu_grid (array) – wavenumber array cm-1

  • Tmax (float) – maximum temperature in your use (K)

  • Pmin (float) – minimum temperature in your use (bar)

  • accuracy (float, optional) – accuracy allowed. Defaults to 0.01.

  • dE (float, optional) – E grid to search for the optimal Elower. Defaults to 100.0.

  • display (bool, optional) – if you want to compare the cross section using Eopt w/ ground truth, set True. Defaults to False.

Returns:

optimal maximum Elower (Eopt) in cm-1

Return type:

float

exojax.spec.planck module

planck functions.

  • The units are nu [1/cm], f [1/s], wav [cm]. In this module, the input variable is always wavenumber [cm].

  • nu = f/c = 1/lambda.

  • Recall nu B_nu = lambda B_lambda = f B_f.

  • B_f (erg/s/cm2/Hz) = B_nu/c (erg/s/cm2/cm-1)

exojax.spec.planck.piBarr(T, nus)

pi B_nu (Planck Function)

Parameters:
  • T – temperature [K]

  • nus – wavenumber [cm-1]

Returns:

pi B_nu (erg/s/cm2/cm-1) [Nlayer x Nnu]

Note

hcperk = hc/k in cgs, fac = 2*h*c*c*pi in cgs

exojax.spec.premodit module

Line profile computation using PremoDIT = Precomputation of LSD version of MODIT

exojax.spec.premodit.broadpar_getix(ngamma_ref, ngamma_ref_grid, n_Texp, n_Texp_grid)

get indices and contribution of broadpar

Parameters:
  • ngamma_ref – normalized half-width at reference

  • ngamma_ref_grid – grid of normalized half-width at reference

  • n_Texp – temperature exponent (n_Texp, n_air, etc)

  • n_Texp_grid – grid of temperature exponent (n_Texp, n_air, etc)

Returns:

multi_index_lines multi_cont_lines uidx_lines neighbor_uidx multi_index_uniqgrid number of broadpar grid

Examples

>>> multi_index_lines, multi_cont_lines, uidx_lines, neighbor_uidx, multi_index_uniqgrid, Ng = broadpar_getix(
>>> ngamma_ref, ngamma_ref_grid, n_Texp, n_Texp_grid)
>>> iline_interest = 1 # we wanna investiget this line
>>> print(multi_index_lines[iline_interest]) # multi index from a line
>>> print(multi_cont_lines[iline_interest]) # multi contribution from a line
>>> print(uidx_lines[iline_interest]) # uniq index of a line
>>> print(multi_index_uniqgrid[uniq_index]) # multi index from uniq_index
>>> ui,uj,uk=neighbor_uidx[uniq_index, :] # neighbour uniq index
exojax.spec.premodit.compute_dElower(T, interval_contrast=0.1)

compute a grid interval of Elower given the grid interval of line strength

Parameters:
  • T – temperature in Kelvin

  • interval_contrast – putting c = grid_interval_line_strength, then, the contrast of line strength between the upper and lower of the grid becomes c-order of magnitude.

Returns:

Required dElower

exojax.spec.premodit.convert_to_jnplog(lbd_nth)

compute log and convert to jnp

Notes

This function is used to avoid an overflow when using FP32 in JAX

Parameters:

lbd_nth (ndarray) – n-th coefficient (non-log) LBD

Returns:

log form of n-th coefficient LBD

Return type:

jnp.array

exojax.spec.premodit.g_bias(nu_in, T, Tref)
Parameters:
  • nu_in – wavenumber in cm-1

  • T – temperature for unbiasing in Kelvin

  • Tref – reference temperature in Kelvin

Returns:

bias g function

exojax.spec.premodit.generate_lbd(line_strength_ref, nu_lines, nu_grid, ngamma_ref, ngamma_ref_grid, n_Texp, n_Texp_grid, elower, elower_grid, Twt, Tref=296.0, diffmode=0)

generate log-biased line shape density (LBD)

Parameters:
  • line_strength_ref – line strength at reference temperature 296K, Sij0

  • nu_lines (_type_) – _description_

  • nu_grid (_type_) – _description_

  • ngamma_ref (_type_) – _description_

  • ngamma_ref_grid (_type_) – normalized gamma at reference grid

  • n_Texp (_type_) –

  • n_Texp_grid (_type_) – normalized temperature exponent grid

  • elower (_type_) – _description_

  • elower_grid (_type_) – _description_

  • Twt – temperature used for the weight coefficient computation

  • Tref – reference temperature in Kelvin, default is 296.0 K

  • diffmode (int) – i-th Taylor expansion is used for the weight, default is 1.

Notes

When len(ngamma_ref_grid) = 1 and len(n_Texp_grid) = 1, the single broadening parameter mode is applied.

Returns:

the list of the n-th coeffs of line shape density (LBD) jnp.array: multi_index_uniqgrid (number of unique broadpar, 2)

Return type:

[jnp array]

Examples

>>> lbd_coeff, multi_index_uniqgrid = generate_lbd(mdb.Sij0, mdb.nu_lines, nu_grid, ngamma_ref,
>>>               ngamma_ref_grid, mdb.n_Texp, n_Texp_grid, mdb.elower,
>>>               elower_grid, Twp)
>>> ngamma_ref = ngamma_ref_grid[multi_index_uniqgrid[:,0]] # ngamma ref for the unique broad par
>>> n_Texp = n_Texp_grid[multi_index_uniqgrid[:,0]] # temperature exponent for the unique broad par
exojax.spec.premodit.logf_bias(elower_in, T, Tref)

logarithm f bias function

Parameters:
  • elower_in – Elower in cm-1

  • T – temperature for unbiasing in Kelvin

  • Tref – reference temperature in Kelvin

Returns:

logarithm of bias f function

exojax.spec.premodit.make_broadpar_grid(ngamma_ref, n_Texp, Tmax, Tmin, Tref_broadening, dit_grid_resolution=0.2, twod_factor=1.3333333333333333, adopt=True)

make grids of normalized half-width at reference and temperature exoponent

Parameters:
  • ngamma_ref (nd array) – n_Texp: temperature exponent (n_Texp, n_air, etc)

  • n_Texp (nd array) – temperature exponent (n_Texp, n_air, etc)

  • Tmax – maximum temperature in Kelvin (NOT weight temperature)

  • Tmin – minimum temperature in Kelvin (NOT weight temperature)

  • Tref_broadening – reference temperature for broadening in Kelvin

  • dit_grid_resolution (float, optional) – DIT grid resolution. Defaults to 0.2.

  • twod_factor – conversion factor of the grid resolution from 1D to 2D. default 3.0/4.0. See Issue #366.

  • adopt (bool, optional) – if True, min, max grid points are used at min and max values of x. In this case, the grid width does not need to be dit_grid_resolution exactly. Defaults to True.

Returns:

ngamma_ref_grid, grid of normalized half-width at reference nd array: n_Texp_grid, grid of temperature exponent (n_Texp, n_air, etc)

Return type:

nd array

exojax.spec.premodit.make_elower_grid(elower, dE)

compute E_lower grid given dE or interval_contrast of line strength

Parameters:
  • elower – E_lower

  • dE – elower interval in cm-1

Returns:

grid of E_lower given interval_contrast

exojax.spec.premodit.parallel_merge_grids(grid1, grid2)

Merge two different grids into one grid in parallel, in a C-contiguous RAM mapping.

Parameters:
  • grid1 – grid 1

  • grid2 – grid 2

Returns:

merged grid (len(grid1),2)

exojax.spec.premodit.reference_temperature_broadening_at_midpoint(Tmin, Tmax)

compute Tref_broadening at the logarithmic midpoint of Tmin and Tmax

Parameters:
  • Tmin (float) – minimum temperature

  • Tmax (float) – maximum temperature

Returns:

Tref_broadening at the logarithmic midpoint of Tmin and Tmax

Return type:

float

exojax.spec.premodit.unbiased_lsd_first(lbd_coeff, T, Tref, Twt, nu_grid, elower_grid, qt)

unbias the biased LSD, first order

Parameters:
  • lbd_coeff – the zeroth/first coeff of log-biased line shape density (LBD)

  • T – temperature for unbiasing in Kelvin

  • Tref – reference temperature in Kelvin

  • Twt – Temperature at the weight point

  • nu_grid – wavenumber grid in cm-1

  • elower_grid – Elower grid in cm-1

  • qt – partition function ratio Q(T)/Q(Tref)

Returns:

LSD, shape = (number_of_wavenumber_bin, number_of_broadening_parameters)

exojax.spec.premodit.unbiased_lsd_second(lbd_coeff, T, Tref, Twt, nu_grid, elower_grid, qt)

unbias the biased LSD, second order

Parameters:
  • lbd_coeff – the zeroth/first/second coeff of log-biased line shape density (LBD)

  • T – temperature for unbiasing in Kelvin

  • Tref – reference temperature in Kelvin

  • Twt – Temperature at the weight point

  • nu_grid – wavenumber grid in cm-1

  • elower_grid – Elower grid in cm-1

  • qt – partition function ratio Q(T)/Q(Tref)

Returns:

LSD, shape = (number_of_wavenumber_bin, number_of_broadening_parameters)

exojax.spec.premodit.unbiased_lsd_zeroth(lbd_zeroth, T, Tref, nu_grid, elower_grid, qt)

unbias the biased LSD

Parameters:
  • lbd_zeroth – the zeroth coeff of log-biased line shape density (LBD)

  • T – temperature for unbiasing in Kelvin

  • Tref – reference temperature in Kelvin

  • nu_grid – wavenumber grid in cm-1

  • elower_grid – Elower grid in cm-1

  • qt – partition function ratio Q(T)/Q(Tref)

Returns:

LSD (0th), shape = (number_of_wavenumber_bin, number_of_broadening_parameters)

exojax.spec.premodit.unbiased_ngamma_grid(T, P, ngamma_ref_grid, n_Texp_grid, multi_index_uniqgrid, Tref_broadening)

compute unbiased ngamma grid

Parameters:
  • T – temperature in Kelvin

  • P – pressure in bar

  • ngamma_ref_grid – pressure broadening half width at Tref_broadening

  • n_Texp_grid – temperature exponent at reference

  • multi_index_uniqgrid – multi index of unique broadening parameter

  • Tref_broadening – reference temperature in Kelvin for broadening

Returns:

pressure broadening half width at temperature T and pressure P

Notes

It should be noted that the gamma is not affected by changing Tref.

exojax.spec.premodit.xsmatrix_first(Tarr, Parr, Tref, Twt, R, pmarray, lbd_coeff, nu_grid, ngamma_ref_grid, n_Texp_grid, multi_index_uniqgrid, elower_grid, Mmol, qtarr, Tref_broadening)

compute cross section matrix given atmospheric layers, for diffmode=1, with scan+fft

Parameters:
  • Tarr (_type_) – temperature layers

  • Parr (_type_) – pressure layers

  • Tref – reference temperature in K

  • Twt – weight temperature in K

  • R (float) – spectral resolution

  • pmarray (_type_) – pmarray

  • lbd_coeff (_type_) – LBD coefficient

  • nu_grid (_type_) – wavenumber grid

  • ngamma_ref_grid (_type_) – normalized half-width grid

  • n_Texp_grid (_type_) – temperature exponent grid

  • multi_index_uniqgrid (_type_) – multi index for uniq broadpar grid

  • elower_grid (_type_) – Elower grid

  • Mmol (_type_) – molecular mass

  • qtarr (_type_) – partition function ratio layers

  • Tref_broadening – reference temperature for broadening in Kelvin

Returns:

cross section matrix (Nlayer, N_wavenumber)

Return type:

jnp.array

exojax.spec.premodit.xsmatrix_second(Tarr, Parr, Tref, Twt, R, pmarray, lbd_coeff, nu_grid, ngamma_ref_grid, n_Texp_grid, multi_index_uniqgrid, elower_grid, Mmol, qtarr, Tref_broadening)

compute cross section matrix given atmospheric layers, for diffmode=1, with scan+fft

Parameters:
  • Tarr (_type_) – temperature layers

  • Parr (_type_) – pressure layers

  • Tref – reference temperature in K

  • Twt – weight temperature in K

  • R (float) – spectral resolution

  • pmarray (_type_) – pmarray

  • lbd_coeff (_type_) – LBD coefficient

  • nu_grid (_type_) – wavenumber grid

  • ngamma_ref_grid (_type_) – normalized half-width grid

  • n_Texp_grid (_type_) – temperature exponent grid

  • multi_index_uniqgrid (_type_) – multi index for uniq broadpar grid

  • elower_grid (_type_) – Elower grid

  • Mmol (_type_) – molecular mass

  • qtarr (_type_) – partition function ratio layers

  • Tref_broadening – reference temperature for broadening in Kelvin

Returns:

cross section matrix (Nlayer, N_wavenumber)

Return type:

jnp.array

exojax.spec.premodit.xsmatrix_zeroth(Tarr, Parr, Tref, R, pmarray, lbd_coeff, nu_grid, ngamma_ref_grid, n_Texp_grid, multi_index_uniqgrid, elower_grid, Mmol, qtarr, Tref_broadening)

compute cross section matrix given atmospheric layers, for diffmode=0, with scan+fft

Parameters:
  • Tarr (_type_) – temperature layers

  • Parr (_type_) – pressure layers

  • Tref – reference temperature in K

  • R (float) – spectral resolution

  • pmarray (_type_) – pmarray

  • lbd_coeff (_type_) –

  • nu_grid (_type_) – wavenumber grid

  • ngamma_ref_grid (_type_) – normalized half-width grid

  • n_Texp_grid (_type_) – temperature exponent grid

  • multi_index_uniqgrid (_type_) – multi index for uniq broadpar grid

  • elower_grid (_type_) – Elower grid

  • Mmol (_type_) – molecular mass

  • qtarr (_type_) – partition function ratio layers

  • Tref_broadening – reference temperature for broadening in Kelvin

Returns:

cross section matrix (Nlayer, N_wavenumber)

Return type:

jnp.array

exojax.spec.premodit.xsvector_first(T, P, nsigmaD, lbd_coeff, Tref, Twt, R, pmarray, nu_grid, elower_grid, multi_index_uniqgrid, ngamma_ref_grid, n_Texp_grid, qt, Tref_broadening)

compute cross section vector, with scan+fft, using the first Taylor expansion

Parameters:
  • T (_type_) – temperature in Kelvin

  • P (_type_) – pressure in bar

  • nsigmaD – normalized doplar STD

  • lbd_zeroth (_type_) – log biased line shape density (LBD), zeroth coefficient

  • lbd_first (_type_) – log biased line shape density (LBD), first coefficient

  • Tref – reference temperature used to compute lbd_zeroth and lbd_first in Kelvin

  • Twt – temperature used in the weight point

  • R (_type_) – spectral resolution

  • nu_grid (_type_) – wavenumber grid

  • elower_grid (_type_) – E lower grid

  • multi_index_uniqgrid (_type_) – multi index of unique broadening parameter grid

  • ngamma_ref_grid (_type_) – normalized pressure broadening half-width

  • n_Texp_grid (_type_) – temperature exponent grid

  • qt (_type_) – partirion function ratio

  • Tref_broadening – reference temperature for broadening in Kelvin

Returns:

cross section in cgs vector

Return type:

jnp.array

exojax.spec.premodit.xsvector_second(T, P, nsigmaD, lbd_coeff, Tref, Twt, R, pmarray, nu_grid, elower_grid, multi_index_uniqgrid, ngamma_ref_grid, n_Texp_grid, qt, Tref_broadening)

compute cross section vector, with scan+fft, using the second Taylor expansion

Parameters:
  • T (_type_) – temperature in Kelvin

  • P (_type_) – pressure in bar

  • nsigmaD – normalized doplar STD

  • lbd_coeff (_type_) – log biased line shape density (LBD), coefficient

  • Tref – reference temperature used to compute lbd_zeroth and lbd_first in Kelvin

  • Twt – temperature used in the weight point

  • R (_type_) – spectral resolution

  • nu_grid (_type_) – wavenumber grid

  • elower_grid (_type_) – E lower grid

  • multi_index_uniqgrid (_type_) – multi index of unique broadening parameter grid

  • ngamma_ref_grid (_type_) – normalized pressure broadening half-width

  • n_Texp_grid (_type_) – temperature exponent grid

  • qt (_type_) – partirion function ratio

  • Tref_broadening – reference temperature for broadening in Kelvin

Returns:

cross section in cgs vector

Return type:

jnp.array

exojax.spec.premodit.xsvector_zeroth(T, P, nsigmaD, lbd_coeff, Tref, R, pmarray, nu_grid, elower_grid, multi_index_uniqgrid, ngamma_ref_grid, n_Texp_grid, qt, Tref_broadening)

compute cross section vector, with scan+fft, using the zero-th Taylor expansion

Parameters:
  • T (_type_) – temperature in Kelvin

  • P (_type_) – pressure in bar

  • nsigmaD – normalized doplar STD

  • lbd_coeff (_type_) – log biased line shape density (LBD) coefficient

  • Tref – reference temperature used to compute lbd_zeroth in Kelvin

  • R (_type_) – spectral resolution

  • nu_grid (_type_) – wavenumber grid

  • elower_grid (_type_) – E lower grid

  • multi_index_uniqgrid (_type_) – multi index of unique broadening parameter grid

  • ngamma_ref_grid (_type_) – normalized pressure broadening half-width

  • n_Texp_grid (_type_) – temperature exponent grid

  • qt (_type_) – partirion function ratio

  • Tref_broadening – reference temperature for broadening in Kelvin

Returns:

cross section in cgs vector

Return type:

jnp.array

exojax.spec.presolar module

PreSOLAR Precomputing Shape density and OverLap Add convolution Rxxxx

  • LBD -> hat(LBD)

  • shapefilter -> hat(shapefilter)

exojax.spec.presolar.lbd_olaform(lbd, ndiv, div_length, filter_length)

convert LBD to match the form of OLA, i.e. generate hat LBD

Parameters:
  • lbd (3D array) – line basis density (input length,:,:)

  • ndiv (int) – number of mini batches

  • div_length (int) – mini batch length

  • filter_length (int) – filter length

Returns:

hat(LBD) (ndiv, fft_length, :, :)

Return type:

4D array

exojax.spec.presolar.optimal_mini_batch(input_length, filter_length)

compute the optimal number and length of the mini batches array

Parameters:
  • input_length (int) – input length i.e. the length of the wavenumber bin

  • filter_length (int) – filter length

Returns:

the optimal number, length of the mini batches.

Return type:

int, int

exojax.spec.presolar.shapefilter_olaform(shapefilter, div_length, padding_value=0.0)

generate zero-padding shape filter

Parameters:
  • shapefilter (array) – shape filter

  • div_length (int) – mini batch length

  • padding_value – padding value (default = 0.0)

Returns:

zero-padding shape filter, hat(V)

exojax.spec.qstate module

exojax.spec.qstate.m_transition_state(jlower, branch)

compute m-value of the transition from rotational state

Parameters:
  • jlower (int) – lower rotational quantum state

  • branch (int) – jupper - jlower

Returns:

m

Return type:

int

Notes

m = Jlower + 1 for R-branch (branch=1) m = Jlower for P- and Q- branch (branch=-1 and 0)

exojax.spec.response module

response.

  • input nus/wav should be spaced evenly on a log scale (ESLOG).

  • response is a response operation for the wavenumber grid spaced evenly on a log scale.

  • ipgauss2 are faster than default when N >~ 10000, where N is the dimension of the wavenumber grid.

exojax.spec.response.ipgauss(F0, varr_kernel, beta)

Apply the Gaussian IP response to a spectrum F.

Parameters:
  • F0 – original spectrum (F0)

  • varr_kernel – velocity array for the rotational kernel

  • beta – STD of a Gaussian broadening (IP+microturbulence)

Returns:

response-applied spectrum (F)

exojax.spec.response.ipgauss_sampling(nusd, nus, F0, beta, RV, varr_kernel)

Apply the Gaussian IP response + sampling to a spectrum F.

Parameters:
  • nusd – sampling wavenumber

  • nus – input wavenumber, evenly log-spaced

  • F0 – original spectrum (F0)

  • beta – STD of a Gaussian broadening (IP+microturbulence)

  • RV – radial velocity (km/s)

  • varr_kernel – velocity array for the rotational kernel

Returns:

response-applied spectrum (F)

exojax.spec.response.ipgauss_variable_sampling(nusd, nus, F0, beta_variable, RV)

Apply the variable Gaussian IP response + sampling to a spectrum F.

Notes

STD is a function of nusd

Parameters:
  • nusd – sampling wavenumber

  • nus – input wavenumber, evenly log-spaced

  • F0 – original spectrum (F0)

  • beta_variable (1D array) – STD of a Gaussian broadening, shape=(len(nusd),)

  • RV – radial velocity (km/s)

Returns:

response-applied spectrum (F)

exojax.spec.response.sampling(nusd, nus, F, RV)

Sampling w/ RV.

Parameters:
  • nusd – sampling wavenumber

  • nus – input wavenumber

  • F – input spectrum

  • RV – radial velocity (km/s)

Returns:

sampled spectrum

exojax.spec.rtransfer module

radiative transfer

exojax.spec.rtransfer.dtauCIA(nus, Tarr, Parr, dParr, vmr1, vmr2, mmw, g, nucia, tcia, logac)
exojax.spec.rtransfer.dtauHminus(nus, Tarr, Parr, dParr, vmre, vmrh, mmw, g)
exojax.spec.rtransfer.dtauM(dParr, xsm, MR, mass, g)
exojax.spec.rtransfer.dtauVALD(dParr, xsm, VMR, mmw, g)
exojax.spec.rtransfer.pressure_layer(log_pressure_top=- 8.0, log_pressure_btm=2.0, NP=20, mode='ascending', reference_point=0.5, numpy=False)
exojax.spec.rtransfer.rtrun(dtau, S)
exojax.spec.rtransfer.rtrun_emis_pure_absorption(dtau, source_matrix)

Radiative Transfer using two-stream approximaion + 2E3 (Helios-R1 type)

Parameters:
  • dtau (2D array) – optical depth matrix, dtau (N_layer, N_nus)

  • source_matrix (2D array) – source matrix (N_layer, N_nus)

Returns:

flux in the unit of [erg/cm2/s/cm-1] if using piBarr as a source function.

exojax.spec.rtransfer.rtrun_emis_pure_absorption_direct(dtau, source_matrix)

Radiative Transfer using direct integration.

Note

Use dtau/mu instead of dtau when you want to use non-unity, where mu=cos(theta)

Parameters:
  • dtau (2D array) – optical depth matrix, dtau (N_layer, N_nus)

  • source_matrix (2D array) – source matrix (N_layer, N_nus)

Returns:

flux in the unit of [erg/cm2/s/cm-1] if using piBarr as a source function.

exojax.spec.rtransfer.rtrun_emis_pure_absorption_surface(dtau, source_matrix, source_surface)

Radiative Transfer using two-stream approximaion + 2E3 (Helios-R1 type) with a planetary surface.

Parameters:
  • dtau (2D array) – optical depth matrix, dtau (N_layer, N_nus)

  • source_matrix (2D array) – source matrix (N_layer, N_nus)

  • source_surface – source from the surface [N_nus]

Returns:

flux in the unit of [erg/cm2/s/cm-1] if using piBarr as a source function.

exojax.spec.rtransfer.rtrun_trans_pure_absorption(dtau_chord, radius_lower)

Radiative transfer assuming pure absorption

Parameters:
  • dtau_chord (2D array) – chord opacity (Nlayer, N_wavenumber)

  • radius_lower (1D array) – (normalized) radius at the lower boundary, underline(r) (Nlayer).

Notes

The n-th radius is defined as the lower boundary of the n-th layer. So, radius[0] corresponds to R0.

Returns:

transit squared radius normalized by radius_lower[-1], i.e. it returns (radius/radius_lower[-1])**2

Return type:

1D array

Notes

This function gives the sqaure of the transit radius. If you would like to obtain the transit radius, take sqaure root of the output. If you would like to compute the transit depth, devide the output by the square of stellar radius

exojax.spec.rtransfer.trans2E3(x)

transmission function 2E3 (two-stream approximation with no scattering) expressed by 2 E3(x)

Note

The exponetial integral of the third order E3(x) is computed using Abramowitz Stegun (1970) approximation of E1 (exojax.special.E1).

Parameters:

x – input variable

Returns:

Transmission function T=2 E3(x)

exojax.spec.set_ditgrid module

set DIT

  • This module provides functions to generate the grid used in DIT/MODIT/PreMODIT.

exojax.spec.set_ditgrid.ditgrid_linear_interval(input_variable, dit_grid_resolution=0.1, weight=None, adopt=True)

generate DIT GRID with constant interval in linear scale

Parameters:
  • input_variable – input array, e.g. n_Texp (temperature exponent) array (Nline)

  • dit_grid_resolution – grid resolution. dit_grid_resolution=0.1 (defaut) means a grid point per digit

  • weight – weight, e.g. np.abs(ln(T)-ln(Tref))

  • adopt – if True, min, max grid points are used at min and max values of x.

  • case (In this) –

  • exactly. (the grid width does not need to be dit_grid_resolution) –

Returns:

grid for DIT

exojax.spec.set_ditgrid.ditgrid_log_interval(input_variable, dit_grid_resolution=0.1, adopt=True)

generate DIT GRID with constant interval in logarithm scale

Parameters:
  • input_variable – simgaD or gammaL array (Nline)

  • dit_grid_resolution – grid resolution. dit_grid_resolution=0.1 (defaut) means a grid point per digit

  • adopt – if True, min, max grid points are used at min and max values of x.

  • case (In this) –

  • exactly. (the grid width does not need to be dit_grid_resolution) –

Returns:

grid for DIT

exojax.spec.set_ditgrid.ditgrid_matrix(x, res=0.1, adopt=True)

DIT GRID MATRIX.

Parameters:
  • x – simgaD or gammaL matrix (Nlayer x Nline)

  • res – grid resolution. res=0.1 (defaut) means a grid point per digit

  • adopt – if True, min, max grid points are used at min and max values of x. In this case, the grid width does not need to be res exactly.

Returns:

grid for DIT (Nlayer x NDITgrid)

exojax.spec.set_ditgrid.minmax_ditgrid_matrix(x, dit_grid_resolution=0.1, adopt=True)

compute MIN and MAX DIT GRID MATRIX.

Parameters:
  • x – gammaL matrix (Nlayer x Nline)

  • dit_grid_resolution – grid resolution. dit_grid_resolution=0.1 (defaut) means a grid point per digit

  • adopt – if True, min, max grid points are used at min and max values of x. In this case, the grid width does not need to be dit_grid_resolution exactly.

Returns:

minimum and maximum for DIT (dgm_minmax)

exojax.spec.set_ditgrid.precompute_modit_ditgrid_matrix(set_gm_minmax, dit_grid_resolution=0.1, adopt=True)

Precomputing MODIT GRID MATRIX for normalized GammaL.

Parameters:
  • set_gm_minmax – set of minmax of ditgrid matrix for different parameters [Nsample, Nlayers, 2], 2=min,max

  • dit_grid_resolution – grid resolution. dit_grid_resolution=0.1 (defaut) means a grid point per digit

  • adopt – if True, min, max grid points are used at min and max values of x. In this case, the grid width does not need to be dit_grid_resolution exactly.

Returns:

grid for DIT (Nlayer x NDITgrid)

exojax.spec.shapefilter module

(line) shape filters used in PreSOLAR algorithm

exojax.spec.shapefilter.check_filter_condition(shape_filter)

_summary_

Parameters:

shape_filter (_type_) – _description_

exojax.spec.shapefilter.compute_filter_length(wavenumber_halfwidth, representative_wavenumber, spectral_resolution)

compute the length of the FIR line shape filter

Parameters:
  • wavenumber_halfwidth (float) – half width at representative wavenumber (cm-1)

  • representative_wavenumber (float) – representative wavenumber (cm-1)

  • spectral_resolution (float) – spectral resolution R0

Returns:

filter length

Return type:

int

Examples

from exojax.utils.instfunc import resolution_eslog spectral_resolution = resolution_eslog(nu_grid) filter_length = compute_filter_length(50.0, 4000.0, spectral_resolution)

exojax.spec.shapefilter.generate_voigt_shape_filter(nsigmaD, ngammaL, filter_length)

generate a Voigt filter with a tail cut (naturally!)

Parameters:
  • nsigmaD (float) – normalized Dopper width

  • ngammaL (float) – normalized Lorenz half width

  • filter_length (int) – filter length

Returns:

_description_

Return type:

_type_

exojax.spec.specop module

Spectral Operators (Sop)

class exojax.spec.specop.SopCommon(nu_grid, resolution, vrmax)

Bases: object

Common Spectral Operator

generate_vrarray()
class exojax.spec.specop.SopInstProfile(nu_grid, resolution, vrmax=100.0)

Bases: SopCommon

Spectral operator on Instrumental profile and sampling

ipgauss(spectrum, standard_deviation)

Gaussian Instrumental Profile

Parameters:
  • spectrum (nd array) – 1D spectrum

  • standard_deviation (float) – standard deviation of Gaussian in km/s

Raises:

ValueError – _description_

Returns:

IP applied spectrum

Return type:

array

sampling(spectrum, radial_velocity, nu_grid_sampling)

sampling to instrumental wavenumber grid (not necessary ESLOG nor ESLIN)

Parameters:
  • spectrum (nd array) – 1D spectrum

  • radial_velocity (float) – radial velocity in km/s

  • nu_grid_sampling (array) – instrumental wavenumber grid

Returns:

inst sampled spectrum

Return type:

array

class exojax.spec.specop.SopRotation(nu_grid, resolution, vsini_max=100.0)

Bases: SopCommon

Spectral operator on rotation

rigid_rotation(spectrum, vsini, u1, u2)

apply a rigid rotation

Parameters:
  • spectrum (nd array) – 1D spectrum

  • vsini (float) – V sini in km/s

  • u1 (float) – Limb darkening parameter u1

  • u2 (float) – Limb darkening parameter u2

Raises:

ValueError – _description_

Returns:

rotatinoal broaden spectrum

Return type:

nd array

exojax.spec.spin_rotation module

exojax.spec.spin_rotation.convolve_rigid_rotation(F0, vr_array, vsini, u1=0.0, u2=0.0)

Apply the Rotation response to a spectrum F (No OLA and No cuDNN).

Parameters:
  • F0 – original spectrum (F0)

  • vr_array – fix-sized vr array for kernel, see utils.dvgrid_rigid_rotation

  • vsini – V sini for rotation (km/s)

  • RV – radial velocity

  • u1 – Limb-darkening coefficient 1

  • u2 – Limb-darkening coefficient 2

Returns:

response-applied spectrum (F)

exojax.spec.spin_rotation.rotkernel_jvp(primals, tangents)

exojax.spec.unitconvert module

unit conversion for spectrum.

exojax.spec.unitconvert.nu2wav(nus, wavelength_order, unit='AA')

wavenumber to wavelength (AA)

Parameters:
  • nus – wavenumber (cm-1)

  • order (wavlength) – wavelength order: “ascending” or “descending”

  • unit – unit of wavelength

Returns:

wavelength (AA)

exojax.spec.unitconvert.wav2nu(wav, unit)

wavelength to wavenumber.

Parameters:
  • wav – wavelength array in ascending/descending order

  • unit – unit of wavelength

Returns:

wavenumber (cm-1) in ascending order

Module contents