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], margin=0.0, crit=0.0, Ttyp=1000.0, bkgdatm='H2', broadf=True, gpu_transfer=True, inherit_dataframe=False, local_databases='./')¶
Bases:
radis.api.exomolapi.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
- A¶
- QT_interp(T)¶
interpolated partition function.
- Parameters
T – temperature
- Returns
Q(T) interpolated in jnp.array
- Sij0¶
- compute_load_mask(df)¶
- elower¶
- eupper¶
- 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.
- gupper¶
- instances_from_dataframes(df_load_mask)¶
generate instances from (usually masked) data farame
- Parameters
df_load_mask (DataFrame) – (masked) data frame
- Raises
ValueError – _description_
- jlower¶
- jupper¶
- logsij0¶
- nu_lines¶
- qr_interp(T)¶
interpolated partition function ratio.
- Parameters
T – temperature
- Returns
qr(T)=Q(T)/Q(Tref) interpolated in jnp.array
- class exojax.spec.api.MdbHitemp(path, nurange=[- inf, inf], margin=0.0, crit=0.0, Ttyp=1000.0, isotope=0, gpu_transfer=False, inherit_dataframe=False)¶
Bases:
radis.api.hitempapi.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
- QT_interp(isotope, T)¶
interpolated partition function.
- Parameters
isotope – HITRAN isotope number starting from 1
T – temperature
- Returns
Q(idx, T) interpolated in jnp.array
- compute_load_mask(df, qrtyp)¶
- exact_isotope_name(isotope)¶
exact isotope name
- Parameters
isotope (int) – isotope number starting from 1
- Returns
exact isotope name such as (12C)(16O)
- Return type
str
- 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_
- qr_interp(isotope, T)¶
interpolated partition function ratio.
- Parameters
isotope – HITRAN isotope number starting from 1
T – temperature
- Returns
qr(T)=Q(T)/Q(Tref) interpolated in jnp.array
- qr_interp_lines(T)¶
Partition Function ratio using HAPI partition data. (This function works for JAX environment.)
- Parameters
T – temperature (K)
- Returns
Qr_line, partition function ratio array for lines [Nlines]
Note
Nlines=len(self.nu_lines)
- class exojax.spec.api.MdbHitran(path, nurange=[- inf, inf], margin=0.0, crit=0.0, Ttyp=1000.0, isotope=0, gpu_transfer=False, inherit_dataframe=False)¶
Bases:
radis.api.hitranapi.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
- QT_interp(isotope, T)¶
interpolated partition function.
- Parameters
isotope – HITRAN isotope number starting from 1
T – temperature
- Returns
Q(idx, T) interpolated in jnp.array
- compute_load_mask(df, qrtyp)¶
- exact_isotope_name(isotope)¶
exact isotope name
- Parameters
isotope (int) – isotope number starting from 1
- Returns
exact isotope name such as (12C)(16O)
- Return type
str
- 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_
- qr_interp(isotope, T)¶
interpolated partition function ratio.
- Parameters
isotope – HITRAN isotope number starting from 1
T – temperature
- Returns
qr(T)=Q(T)/Q(Tref) interpolated in jnp.array
- qr_interp_lines(T)¶
Partition Function ratio using HAPI partition data. (This function works for JAX environment.)
- Parameters
T – temperature (K)
- Returns
Qr_line, partition function ratio array for lines [Nlines]
Note
Nlines=len(self.nu_lines)
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]
Reference of van der Waals damping constant (pressure/collision gamma):
Kurucz+1981: https://ui.adsabs.harvard.edu/abs/1981SAOSR.391…..K
Barklem+1998: https://ui.adsabs.harvard.edu/abs/1998MNRAS.300..863B
Barklem+2000: https://ui.adsabs.harvard.edu/abs/2000A&AS..142..467B
Gray+2005: https://ui.adsabs.harvard.edu/abs/2005oasp.book…..G
- 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]
Reference of van der Waals damping constant (pressure/collision gamma):
Kurucz+1981: https://ui.adsabs.harvard.edu/abs/1981SAOSR.391…..K
Barklem+1998: https://ui.adsabs.harvard.edu/abs/1998MNRAS.300..863B
Barklem+2000: https://ui.adsabs.harvard.edu/abs/2000A&AS..142..467B
Gray+2005: https://ui.adsabs.harvard.edu/abs/2005oasp.book…..G
- 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]
Reference of van der Waals damping constant (pressure/collision gamma):
Kurucz+1981: https://ui.adsabs.harvard.edu/abs/1981SAOSR.391…..K
Barklem+1998: https://ui.adsabs.harvard.edu/abs/1998MNRAS.300..863B
Barklem+2000: https://ui.adsabs.harvard.edu/abs/2000A&AS..142..467B
Gray+2005: https://ui.adsabs.harvard.edu/abs/2005oasp.book…..G
- 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]
Reference of van der Waals damping constant (pressure/collision gamma):
Unsöld1955: https://ui.adsabs.harvard.edu/abs/1955psmb.book…..U
Kurucz+1981: https://ui.adsabs.harvard.edu/abs/1981SAOSR.391…..K
Barklem+1998: https://ui.adsabs.harvard.edu/abs/1998MNRAS.300..863B
Barklem+2000: https://ui.adsabs.harvard.edu/abs/2000A&AS..142..467B
Gray+2005: https://ui.adsabs.harvard.edu/abs/2005oasp.book…..G
- 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]
Reference of van der Waals damping constant (pressure/collision gamma):
Unsöld1955: https://ui.adsabs.harvard.edu/abs/1955psmb.book…..U
Kurucz+1981: https://ui.adsabs.harvard.edu/abs/1981SAOSR.391…..K
Barklem+1998: https://ui.adsabs.harvard.edu/abs/1998MNRAS.300..863B
Barklem+2000: https://ui.adsabs.harvard.edu/abs/2000A&AS..142..467B
Gray+2005: https://ui.adsabs.harvard.edu/abs/2005oasp.book…..G
- exojax.spec.atomll.get_VMR_uspecies(uspecies, mods_ID=DeviceArray([[0, 0]], dtype=int32), mods=DeviceArray([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=DeviceArray([[0, 0]], dtype=int32), mods=DeviceArray([0], dtype=int32), mods_id_trans=DeviceArray([], 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.
See Table 8 of Barklem & Collet (2016); https://doi.org/10.1051/0004-6361/201526961
- 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.autospec module¶
Automatic Opacity and Spectrum Generator.
- class exojax.spec.autospec.AutoRT(nus, gravity, mmw, Tarr, Parr, dParr=None, databasedir='.database', xsmode='auto', autogridconv=True)¶
Bases:
object
exojax auto radiative transfer.
- addcia(interaction, mmr1, mmr2)¶
- Parameters
interaction – e.g. H2-H2, H2-He
mmr1 – mass mixing ratio for molecule 1
mmr2 – mass mixing ratio for molecule 2
- addmol(database, molecules, mmr, crit=0.0)¶
- Parameters
database – database= HITRAN, HITEMP, ExoMol
molecules – molecule name
mmr – mass mixing ratio (float or ndarray for the layer)
crit – line strength criterion, ignore lines whose line strength are below crit
- rtrun()¶
running radiative transfer.
- Returns
spectrum (F0) in the unit of erg/s/cm2/cm-1
Note
If you want to use the unit of erg/cm2/s/Hz, divide the output by the speed of light in cgs as Fx0=Fx0/ccgs, where ccgs=29979245800.0. See #84
- spectrum(nuobs, Rinst, vsini, RV, u1=0.0, u2=0.0, zeta=0.0, betamic=0.0)¶
generating spectrum.
- Parameters
nuobs – observation wavenumber array
Rinst – instrumental resolving power
vsini – vsini for a stellar/planet rotation
RV – radial velocity (km/s)
u1 – Limb-darkening coefficient 1
u2 – Limb-darkening coefficient 2
zeta – macroturbulence distrubunce (km/s) in the radial-tangential model (Gray2005)
betamic – microturbulence beta (STD, km/s)
- Returns
spectrum (F)
- class exojax.spec.autospec.AutoXS(nus, database, molecules, databasedir='.database', memory_size=30, broadf=True, crit=0.0, xsmode='auto', autogridconv=True, pdit=1.5)¶
Bases:
object
exojax auto cross section generator.
- autonus(checknus, tag='ESLOG')¶
- init_database()¶
- linest(T)¶
line strength.
- Parameters
T – temperature (K)
- Returns
line strength (cm)
- nonnegative_xsm(xsm)¶
check negative value of xsm.
- Parameters
xsm – xs matrix
- Returns
xsm negative eliminated
- select_xsmode(Nline)¶
- xsection(T, P)¶
cross section.
- Parameters
T – temperature (K)
P – pressure (bar)
- Returns
cross section (cm2)
- xsmatrix(Tarr, Parr)¶
cross section matrix.
- Parameters
Tarr – temperature layer (K)
Parr – pressure layer (bar)
- Returns
cross section (cm2)
exojax.spec.defcia module¶
Definition of Default cia dataset for autospec.
- exojax.spec.defcia.ciafile(interaction)¶
provide ciafile from interaction.
- Parameters
interaction – e.g. H2-H2
- Returns
cia file name
- exojax.spec.defcia.interaction2mols(interaction)¶
provide 2 molecules from interaction.
- Parameters
interaction – e.g. H2-H2
- Returns
mol1, mol2
Examples:
>>> from exojax.spec.defcia import interaction2mols >>> print(interaction2mols("H2-CH4 (equilibrium)")) >>> ('H2', 'CH4') >>> print(interaction2mols("CH4-He")) >>> ('CH4', 'He')
exojax.spec.defmol module¶
Definition of Default dataset for autospec.
- exojax.spec.defmol.search_molfile(database, molecules)¶
name identifier of molecular databases.
- Parameters
database – molecular database (HITRAN,HITEMP,ExoMol)
molecules – molecular name such as (CO, 12C-16O)
- Returns
identifier
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.
Fourier kernels for the Voigt are given in this module
For coarsed wavenumber grids, folded one is needed to avoid negative values, See discussion by Dirk van den Bekerom at https://github.com/radis/radis/issues/186#issuecomment-764465580 for details.
- 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.evalline module¶
Evaluation of molecular lines (center)
This module evaluates the contibution of molecular lines to an emission spectrum.
This module only consider the line center to reduces computation complexity.
- exojax.spec.evalline.contfunc(dtau, nu, Parr, dParr, Tarr)¶
contribution function.
- Parameters
dtau – delta tau array [N_layer, N_lines]
nu – wavenumber array [N_lines]
Parr – pressure array [N_layer]
dParr – delta pressure array [N_layer]
Tarr – temperature array [N_layer]
- Returns
contribution function
- exojax.spec.evalline.mask_weakline(mdb_mol, Parr, dParr, Tarr, SijM, gammaLM, sigmaDM, MMR_mol, molmass_mol, mmw, g, vmrH2, cdbH2H2, margin=2, mask=None, Nlim=1000)¶
masking weak lines compared to CIA H2-H2 continuum.
- Parameters
mdb_mol – mdb
Parr – pressure layer (bar)
dParr – delta pressure layer (bar)
Tarr – temperature layer (K)
SijM – Sij matrix
gammaLM – gamma coefficient matrix
sigmaDM – Doppler broadening matrix
MMR_mol – Mass Mixing Ratio of the molecule
molmass_mol – molecualr mass of the molecule
mmw – mean molecular weight of the atmosphere
gravity – gravity (cm/s2)
vmrH2 – volume mixing ratio of H2
cdbH2H2 – cdb
- Returns
mask (weak line mask), maxcf (P at max contribution function for the molecule), maxcia (P at max contribution function for CIA)
- exojax.spec.evalline.reduceline_exomol(mdb, Parr, dParr, mmw, gravity, vmrH2, cdb, maxMMR, molmass, Tmodel, *Tparams)¶
Reduce lines for Exomol.
- Parameters
mdb – mdb (exomol)
Parr – pressure layer (bar)
dParr – delta pressure layer (bar)
mmw – mean molecular weight of the atmosphere
gravity – gravity (cm/s2)
vmrH2 – volume mixing ratio of H2
cdb – cdb for continuum
maxMMR – max Mass Mixing Ratio
molmass_mol – molecualr mass of the molecule
Tmodel – Tmodel function
*Tparams – parameter sets
- Returns
mask for exomol mdb maxcf: max contribution function,but for the last value of parameter set. maxcia: max cia level but for the last value of parameter set.
- Return type
mask
- exojax.spec.evalline.voigt0(sigmaD, gammaL)¶
Voigt-Hjerting function at nu=nu0.
- Parameters
nu – wavenumber
sigmaD – sigma parameter in Doppler profile
gammaL – broadening coefficient in Lorentz profile
- Returns
Voigt profile at nu=nu0
- Return type
v
- exojax.spec.evalline.xsmatrix0(sigmaDM, gammaLM, SijM)¶
cross section matrix at nu=nu0.
- Parameters
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.evalline.xsvector0(sigmaD, gammaL, Sij)¶
cross section at nu=nu0.
- Parameters
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.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.exomolapi module¶
API for Exomol molecular database.
- exojax.spec.exomolapi.check_bdat(bdat)¶
cheking codes in .broad.
- Parameters
bdat – exomol .broad data given by exomolapi.read_broad
- Returns
None, a0, a1, other codes unavailable currently,
- Return type
code level
- exojax.spec.exomolapi.make_j2b(bdat, alpha_ref_default=0.07, n_Texp_default=0.5, jlower_max=None)¶
compute j2b (code a0, map from jlower to alpha_ref)
- Parameters
bdat – exomol .broad data given by exomolapi.read_broad
alpha_ref_default – default value
n_Texp_default – default value
jlower_max – maximum number of jlower
- Returns
j2alpha_ref[jlower] provides alpha_ref for jlower j2n_Texp[jlower] provides nT_exp for jlower
- exojax.spec.exomolapi.make_jj2b(bdat, j2alpha_ref_def, j2n_Texp_def, jupper_max=None)¶
compute jj2b (code a1, map from (jlower, jupper) to alpha_ref and n_Texp)
- Parameters
bdat – exomol .broad data given by exomolapi.read_broad
j2alpha_ref_def – default value from a0
j2n_Texp_def – default value from a0
jupper_max – maximum number of jupper
- Returns
jj2alpha_ref[jlower,jupper] provides alpha_ref for (jlower, jupper) jj2n_Texp[jlower,jupper] provides nT_exp for (jlower, jupper)
Note
The pair of (jlower, jupper) for which broadening parameters are not given, jj2XXX contains None.
- exojax.spec.exomolapi.make_numtag(numinf, maxnu)¶
making numtag from numinf.
- Parameters
numinf – nu minimum for trans
maxnu – maximum nu
- Returns
tag for wavelength range
- Return type
numtag
- exojax.spec.exomolapi.pickup_gE(ndstates, ndtrans, trans_file, trans_lines=False)¶
extract g_upper (gup), E_lower (elower), and J_lower and J_upper from states DataFrame and insert them to transition DataFrame.
- Parameters
ndstates – states numpy array
ndtrans – transition numpy array
trans_file – name of the transition file
trans_lines – By default (False) we use nu_lines computed using the state file, i.e. E_upper - E_lower. If trans_nuline=True, we use the nu_lines in the transition file. Note that some trans files do not this info.
- Returns
A, nu_lines, elower, gup, jlower, jupper
Note
We first convert pandas DataFrame to ndarray. The state counting numbers in states DataFrame is used as indices of the new array for states (newstates). We remove the state count numbers as the column of newstate, i.e. newstates[:,k] k=0: E, 1: g, 2: J. Then, we can directly use the state counting numbers as mask.
- exojax.spec.exomolapi.pickup_gEslow(states, trans)¶
Slow version to extract g_upper (gup) and E_lower (elower) from states DataFrame and insert them to transition DataFrame.
- Parameters
states – states pandas DataFrame
trans – transition pandas DataFrame
- Returns
A, nu_lines, elower, gup
Warning
This code is the (thousands times) slower version of pickup_gE. However, we did not remove this one just because this version is much easier to understand.
- exojax.spec.exomolapi.read_broad(broadf)¶
Reading braodening file (.broad)
- Parameters
broadf – .broad file
- Returns
broadening info in bdat form (pandas), defined by this instance.
Note
See Table 16 in https://arxiv.org/pdf/1603.05890.pdf
- exojax.spec.exomolapi.read_def(deff)¶
Exomol IO for a definition file.
- Parameters
deff – definition file
- Returns
temperature exponent n_Texp broadening parameter alpha_ref molecular mass numinf: nu minimum for trans numtag: tag for wavelength range
Note
For some molecules, ExoMol provides multiple trans files. numinf and numtag are the ranges and identifiers for the multiple trans files.
- exojax.spec.exomolapi.read_pf(pff)¶
Exomol IO for partition file.
- Parameters
pff – partition file
- Returns
partition data in pandas DataFrame
Note
T=temperature QT=partition function
- exojax.spec.exomolapi.read_states(statesf)¶
Exomol IO for a state file.
- Parameters
statesf – state file
- Returns
states data in pandas DataFrame
Note
i=state counting number E=state energy g=state degeneracy J=total angular momentum See Table 11 in https://arxiv.org/pdf/1603.05890.pdf
- exojax.spec.exomolapi.read_trans(transf)¶
Exomol IO for a transition file.
- Parameters
transf – transition file
- Returns
transition data in vaex DataFrame
Note
i_upper=Upper state counting number i_lower=Lower state counting number A=Einstein coefficient in s-1 nu_lines=transition wavenumber in cm-1 See Table 12 in https://arxiv.org/pdf/1603.05890.pdf
exojax.spec.hitran module¶
- exojax.spec.hitran.SijT(T, logsij0, nu_lines, elower, qT)¶
(alias, deprecated) use hitran.line_strength, will be removed.
- 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
- 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)¶
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)
- 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.extract_hitemp(parbz2, nurange, margin, tag)¶
extract .par between nurange[0] and nurange[-1]
- Parameters
parbz2 – .par.bz2 HITRAN/HITEMP file (str)
nurange – wavenumber range list (cm-1) [min,max] or wavenumber grid
margin – margin for nurange (cm-1)
tag – tag for directory and output file
- Returns
path of output file (pathlib)
- exojax.spec.hitranapi.get_pf(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.make_numtag(numinf, maxnu)¶
making numtag from numinf.
- Parameters
numinf – nu minimum for multiple file cases of HITEMP (H2O and CO2)
maxnu – maximum nu
- Returns
tag for wavelength range
- Return type
numtag
- exojax.spec.hitranapi.read_path(path)¶
HITRAN IO for a HITRAN/HITEMP par file.
- Parameters
path – HITRAN/HITEMP par file
- Returns
nu minimum for multiple file cases of HITEMP (H2O and CO2) numtag: tag for wavelength range
- Return type
numinf
Note
For H2O and CO2, HITEMP provides multiple par files. numinf and numtag are the ranges and identifiers for the multiple par files.
- exojax.spec.hitranapi.search_molecid(molec)¶
molec id from Hitran/Hitemp filename or molecule name or moleid 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.logacia(Tarr, nus, nucia, tcia, logac)¶
interpolated function of log10(alpha_CIA)
- Parameters
Tarr – temperature array
nus – wavenumber array
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)) >>> logacia(Tarr,nus,nucia,tcia,logac)
- 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.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, Ttyp, interval_contrast=0.1, dit_grid_resolution=0.2, warning=False)¶
Initialization for PreMODIT. 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)
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 temperature 296K, Sij0
Ttyp – typical 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.
dit_grid_resolution – DIT grid resolution
- 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_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.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)¶
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
- Returns
lineshape density a(nx,ny,nz)
- exojax.spec.lsd.npadd3D_multi_index(a, w, cx, ix, cz, iz, uidx, multi_cont_lines, neighbor_uidx)¶
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
- Returns
lineshape density a(nx,ny,nz)
- 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.lsd.npgetix_exp(x, xv, Ttyp, conversion_dtype=<class 'numpy.float64'>)¶
numpy version of getix weigthed by exp(-hc/kT).
- Parameters
x – x array
xv – x grid
Ttyp – typical temperature for the temperature correction
converted_dtype – data type for conversion. Needs enough large because this code uses exp.
- 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.
MODIT is Modified version of the Discrete Integral Transform for rapid spectral synthesis, originally proposed by D.C.M van den Bekerom and E.Pannier. See Section 2.1.2 in Paper I.
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.
See also DIT for non evenly-spaced linear grid by D.C.M van den Bekerom, as a reference of this code.
- 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
- 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)
- 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)
- 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)¶
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)
- class exojax.spec.moldb.MdbExomol(path, nurange=[- inf, inf], margin=0.0, crit=0.0, Ttyp=1000.0, bkgdatm='H2', broadf=True, gpu_transfer=True, inherit_dataframe=False, local_databases='./')¶
Bases:
radis.api.exomolapi.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
- A¶
- QT_interp(T)¶
interpolated partition function.
- Parameters
T – temperature
- Returns
Q(T) interpolated in jnp.array
- Sij0¶
- compute_load_mask(df)¶
- elower¶
- eupper¶
- 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.
- gupper¶
- instances_from_dataframes(df_load_mask)¶
generate instances from (usually masked) data farame
- Parameters
df_load_mask (DataFrame) – (masked) data frame
- Raises
ValueError – _description_
- jlower¶
- jupper¶
- logsij0¶
- nu_lines¶
- qr_interp(T)¶
interpolated partition function ratio.
- Parameters
T – temperature
- Returns
qr(T)=Q(T)/Q(Tref) interpolated in jnp.array
- exojax.spec.moldb.MdbHit¶
alias of
exojax.spec.api.MdbHitemp
exojax.spec.molinfo module¶
- exojax.spec.molinfo.molmass(molecule, db_HIT=False)¶
provide molecular mass from the 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 molmass >>> print(molmass("H2")) >>> 2.01588 >>> print(molmass("CO2")) >>> 44.0095 >>> print(molmass("He")) >>> 4.002602 >>> print(molmass("air")) >>> 28.97
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.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.plg module¶
Pseudo line generator
- exojax.spec.plg.MdbExomol_plg(path_database, nus, Tgue, errTgue=500.0, Nelower=7, assess_width=1.0, threshold_persist_freezing=10000.0, crit=0.0, coefTgue=0.0)¶
Obtain molecular database (mdb) from the Exomol while reducing the number of weak lines by plg. (This function summarizes the plg procedure.)
- Parameters
path_database – path for Exomol data directory/tag. For instance, “/home/CO/12C-16O/Li2015”
nus – wavenumber grid for model
Tgue – rough guess on the typical atmospheric temperature
errTgue – expected one-sided error of Tgue
Nelower – The number of elower grid
assess_width – To save computation time, let us use only this wavelength width in the middle of the whole range to optimize coefTgue. (Note that too narrow might cause a ValueError.)
threshold_persist_freezing – How weak lines compared to the deepest one will you persist freezing (not retaken)?
crit – line strength lower limit for extraction in exojax.spec.moldb.MdbExomol
coefTgue – coefficient for Tgue to optimize elower_grid
- Returns
molecular database instance cnu: contribution of wavenumber for LSD indexnu: nu index
- Return type
mdb
- exojax.spec.plg.diff_frozen_vs_pseudo(coefTgue_init, Tgue, errTgue, Mgue, Rgue, MMRgue, nus, mdb_orig, molmass, Nelower, verbose=False)¶
Evaluate difference between pseudo lines and the original lines
- Parameters
coefTgue_init – initial value of coefTgue (list/array with length=1)
Tgue – rough guess on the typical atmospheric temperature
errTgue – expected one-sided error of Tgue
Mgue – rough guess on the mass
Rgue – rough guess on the radius
MMRgue – rough guess on the MMR of the molecule
nus – wavenumber grid for model
mdb_orig – original molecular database before compression (instance made by the MdbExomol/MdbHit class in moldb.py)
molmass – mass of the molecule (amu)
Nelower – # of elower grid
verbose – vervose printing or not
- Returns
abs(np.mean(mu_pseudo - mu_orig))
- exojax.spec.plg.gather_lines(mdb, Na, Nnugrid, Nelower, nu_grid, cnu, indexnu, qlogsij0, qcnu, elower_grid, alpha_ref_grid, n_Texp_grid, frozen_mask, nonzeropl_mask)¶
gather pseudo lines and unfrozen lines into lines for exomol
- Parameters
mdb – molecular database (instance made by the MdbExomol/MdbHit class in moldb.py)
Na – the number of the additional condition grid (gammaL set for Exomol)
Nnugrid – # of nu_grid
Nelower – # of elower grid
nu_grid – nu grid
cnu – contribution of wavenumber for LSD
indexnu – index nu
qlogsij0 – log line strength
qcnu – cnu for pseudo line (contribution of wavenumber for LSD)
elower_grid – elower_grid
alpha_ref_grid – grid of alpha_ref
n_Texp_grid – grid of n_Texp
frozen_mask – mask for frozen lines into pseudo lines
nonzeropl_mask – mask for pseudo-lines w/ non-zero
- Returns
mdb for the gathered lines cnu for the gathered lines indexnu for the gathered lines
- exojax.spec.plg.get_qlogsij0(cnu, indexnu, Nnugrid, logsij0, expme, expme_grid, Nelower=10, Ncrit=0)¶
gather (freeze) lines
- Parameters
cnu – contribution of wavenumber for LSD
indexnu – index of wavenumber
logsij0 – log line strength
expme – exp(-elower/kT0)
expme_grid – exp(-elower/kT0)_grid
Nelower – # of division of elower between min to max values
- exojax.spec.plg.get_qlogsij0_addcon(indexa, Na, cnu, indexnu, Nnugrid, mdb, expme, expme_grid, Ncrit=0, Tuplim=1000.0, Tmargin=0.0, threshold_persist_freezing=10000.0)¶
gather (freeze) lines w/ additional indexing
- Parameters
indexa – the indexing of the additional condition
Na – the number of the additional condition grid
cnu – contribution of wavenumber for LSD
indexnu – index of wavenumber
Nnugrid – number of nu grid
mdb – molecular database (instance made by the MdbExomol/MdbHit class in moldb.py)
expme – array of exponentials of functions of elower: exp(- hcperk*(elower/Tuplimc - elower/Tref) - preov)
expme_grid – grid of expme
Ncrit – frozen line number per bin
Tuplim – rough guess on the typical atmospheric temperature
Tmargin – margin even above Tuplim to prevent freeze of lines that become strong enough as temperature rises slightly. (more needed for cooler objects)
threshold_persist_freezing – How weak lines compared to the deepest one will you persist freezing (not retaken)?
- Returns
log line strength qcnu: cnu for pseudo line (contribution of wavenumber for LSD) num_unique: number of the lines in each bin of grid frozen_mask: mask for frozen lines into pseudo lines
- Return type
qlogsij0
- exojax.spec.plg.make_gamma_grid_exomol(mdb)¶
Make grids of parameters for Lorentzian width and an associated index.
- Parameters
mdb – molecular database (instance made by the MdbExomol/MdbHit class in moldb.py)
- Returns
grid of alpha_ref (gamma0) n_Texp_grid: grid of temperature exponent of gamma index_gamma: grid-index of the parameters above for each original line
- Return type
alpha_ref_grid
- exojax.spec.plg.optimize_coefTgue(Tgue, nus, mdb, molmass, Nelower, errTgue=500.0, Mgue=41.0, Rgue=1.0, MMRgue=0.001)¶
Optimize coefTgue for adjusting elower_grid
- Parameters
Tgue – rough guess on the typical atmospheric temperature
nus – wavenumber grid for model
mdb – molecular database (instance made by the MdbExomol/MdbHit class in moldb.py)
molmass – mass of the molecule (amu)
Nelower – # of elower grid
errTgue – expected one-sided error of Tgue
Mgue – rough guess on the mass
Rgue – rough guess on the radius
MMRgue – rough guess on the MMR of the molecule
- Returns
optimized coefTgue
- exojax.spec.plg.plg_elower(cnu, indexnu, Nnugrid, logsij0, elower, elower_grid=None, Nelower=10, Ncrit=0, reshape=True)¶
Pseudo Line Grid for elower
- Parameters
cnu – contribution of wavenumber for LSD
indexnu – index of wavenumber
Nnugrid – number of Ngrid
logsij0 – log line strength
elower – elower
elower_grid – elower_grid (optional)
Nelower – # of division of elower between min to max values when elower_grid is not given
Ncrit – frozen line number per bin
- Returns
qlogsij0 qcnu num_unique elower_grid
- exojax.spec.plg.plg_elower_addcon(indexa, Na, cnu, indexnu, nu_grid, mdb, Tgue, errTgue=500.0, elower_grid=None, Nelower=10, Ncrit=0, reshape=False, weedout=False, Tmargin=0.0, coefTgue=1.0, verbose=True, threshold_persist_freezing=10000.0)¶
Pseudo Line Grid for elower w/ an additional condition
- Parameters
indexa – the indexing of the additional condition
Na – the number of the additional condition grid
cnu – contribution of wavenumber for LSD
indexnu – nu index
wavenumber_grid – nu grid
mdb – molecular database (instance made by the MdbExomol/MdbHit class in moldb.py)
Tgue – rough guess on the typical atmospheric temperature
errTgue – expected one-sided error of Tgue
elower_grid – elower_grid (optional)
Nelower – # of division of elower between min to max values (when elower_grid is not given)
Ncrit – frozen line number per bin
reshape – reshaping output arrays
weedout – Is it ok to remove weakest lines or not?
Tmargin – margin even above Tuplim to prevent freeze of lines that become strong enough as temperature rises slightly. (more needed for cooler objects)
coefTgue – coefficient for Tgue to optimize elower_grid
verbose – vervose printing or not
threshold_persist_freezing – How weak lines compared to the deepest one will you persist freezing (not retaken)?
- Returns
pseudo logsij0 qcnu: pseudo cnu num_unique: number of the lines in each bin of grid elower_grid: elower of pl frozen_mask: mask for frozen lines into pseudo lines nonzeropl_mask: mask for pseudo-lines w/ non-zero
- Return type
qlogsij0
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 gird
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.g_bias(nu_in, T)¶
- Parameters
nu_in – wavenumber in cm-1
T – txbemperature for unbiasing 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, Ttyp)¶
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_) – _description_
n_Texp (_type_) – _description_
n_Texp_grid (_type_) – _description_
elower (_type_) – _description_
elower_grid (_type_) – _description_
Ttyp (_type_) – _description_
- Returns
log-biased line shape density (LBD) jnp.array: multi_index_uniqgrid (number of unique broadpar, 2)
- Return type
jnp array
Examples
>>> lbd, 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, Ttyp) >>> 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)¶
logarithm f bias function
- Parameters
elower_in – Elower in cm-1
T – temperature for unbiasing in Kelvin
- Returns
logarithm of bias f function
- exojax.spec.premodit.make_broadpar_grid(ngamma_ref, n_Texp, Ttyp, dit_grid_resolution=0.2, 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)
Ttyp – typical or maximum temperature
dit_grid_resolution (float, optional) – DIT grid resolution. Defaults to 0.2.
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(Tmax, elower, interval_contrast)¶
compute E_lower grid given interval_contrast of line strength
- Parameters
Tmax – max temperature in Kelvin
elower – E_lower
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
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.unbiased_lsd(lbd, T, nu_grid, elower_grid, qt)¶
unbias the biased LSD
- Parameters
lbd_biased – log biased LSD
T – temperature for unbiasing 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, 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)¶
compute unbiased ngamma grid
- Parameters
T – temperature in Kelvin
P – pressure in bar
ngamma_ref_grid – pressure broadening half width at reference
n_Texp_grid – temperature exponent at reference
multi_index_uniqgrid – multi index of unique broadening parameter
- Returns
pressure broadening half width at temperature T and pressure P
- exojax.spec.premodit.xsmatrix(Tarr, Parr, R, pmarray, lbd, nu_grid, ngamma_ref_grid, n_Texp_grid, multi_index_uniqgrid, elower_grid, Mmol, qtarr)¶
compute cross section matrix given atmospheric layers, with scan+fft
- Parameters
Tarr (_type_) – temperature layers
Parr (_type_) – pressure layers
R (float) – spectral resolution
pmarray (_type_) – pmarray
lbd (_type_) – log biased line shape density
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
- Returns
cross section matrix (Nlayer, N_wavenumber)
- Return type
jnp.array
- exojax.spec.premodit.xsvector(T, P, nsigmaD, lbd, R, pmarray, nu_grid, elower_grid, multi_index_uniqgrid, ngamma_ref_grid, n_Texp_grid, qt)¶
compute cross section vector, with scan+fft
- Parameters
T (_type_) – temperature in Kelvin
P (_type_) – pressure in bar
nsigmaD – normalized doplar STD
lbd (_type_) – log biased line shape density (LBD)
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
- 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.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.ipgauss2(nus, F0, varr_kernel, beta)¶
Apply the Gaussian IP response to a spectrum F.
- Parameters
nus – input wavenumber, evenly log-spaced
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)¶
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)
- Returns
response-applied spectrum (F)
- exojax.spec.response.rigidrot(nus, F0, vsini, u1, u2, vsinimax=100.0)¶
(deprecated) rigid rotation. This will be removed.
- 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 module used in exospectral analysis.
- exojax.spec.rtransfer.dtauCIA(nus, Tarr, Parr, dParr, vmr1, vmr2, mmw, g, nucia, tcia, logac)¶
dtau of the CIA continuum.
- 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
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.rtransfer.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.rtransfer.dtauHminus(nus, Tarr, Parr, dParr, vmre, vmrh, mmw, g)¶
dtau of the H- continuum.
- 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
g – gravity (cm2/s)
- Returns
optical depth matrix [N_layer, N_nus]
- exojax.spec.rtransfer.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.rtransfer.dtauM(dParr, xsm, MR, mass, g)¶
dtau of the molecular cross section.
Note
fac=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
g – gravity (cm/s2)
- Returns
optical depth matrix [N_layer, N_nus]
- exojax.spec.rtransfer.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
fac=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.rtransfer.dtauVALD(dParr, xsm, VMR, mmw, g)¶
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]
mmw – mean molecular weight [N_layer]
g – gravity (cm/s2)
- Returns
optical depth matrix [N_layer x N_nus]
- Return type
dtau
- exojax.spec.rtransfer.pressure_layer(logPtop=- 8.0, logPbtm=2.0, NP=20, mode='ascending')¶
generating the pressure layer.
- Parameters
logPtop – log10(P[bar]) at the top layer
logPbtm – log10(P[bar]) at the bottom layer
NP – the number of the layers
- Returns
pressure layer dParr: delta pressure layer k: k-factor, P[i-1] = k*P[i]
- Return type
Parr
Note
dParr[i] = Parr[i] - Parr[i-1], dParr[0] = (1-k) Parr[0] for ascending mode
- exojax.spec.rtransfer.rtrun(dtau, S)¶
Radiative Transfer using two-stream approximaion + 2E3 (Helios-R1 type)
- Parameters
dtau – opacity matrix
S – 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_direct(dtau, S)¶
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 – opacity matrix
S – 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_surface(dtau, S, Sb)¶
Radiative Transfer using two-stream approximaion + 2E3 (Helios-R1 type) with a planetary surface.
- Parameters
dtau – opacity matrix
S – source matrix [N_layer, N_nus]
Sb – 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.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.rtransfer.wavenumber_grid(x0, x1, N, unit='cm-1', xsmode='lpf')¶
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.
this case (In) –
grid width does not need to be dit_grid_resolution exactly. (the) –
- 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.
this case (In) –
grid width does not need to be dit_grid_resolution exactly. (the) –
- 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.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, unit='AA')¶
wavenumber to wavelength (AA)
- Parameters
nus – wavenumber (cm-1)
unit – unit of wavelength
- Returns
wavelength (AA)
- exojax.spec.unitconvert.wav2nu(wav, unit)¶
wavelength to wavenumber.
- Parameters
wav – wavelength
unit – unit of wavelength
- Returns
wavenumber (cm-1)