exojax.utils package¶
Submodules¶
exojax.utils.astrofunc module¶
Astronomical messy functions.
Astronomy is the oldest science in the world.
That’s why we need this module.
- exojax.utils.astrofunc.getjov_gravity(Rp, Mp)¶
gravity in cgs from radius and mass in the Jovian unit.
- Parameters
Rp – radius in the unit of Jovian radius
Mp – radius in the unit of Jovian mass
- Returns
gravity (cm/s2)
Note
Mpcgs=Mp*const.MJ, Rpcgs=Rp*const.RJ then gravity is given by (const.G*Mpcgs/Rpcgs**2)
- exojax.utils.astrofunc.getjov_logg(Rp, Mp)¶
logg from radius and mass in the Jovian unit.
- Parameters
Rp – radius in the unit of Jovian radius
Mp – radius in the unit of Jovian mass
- Returns
logg
Note
Mpcgs=Mp*const.MJ, Rpcgs=Rp*const.RJ, then logg is given by log10(const.G*Mpcgs/Rpcgs**2)
exojax.utils.chopstacks module¶
- exojax.utils.chopstacks.buildwall(x, edge='half')¶
building conventional walls.
- Parameters
x – input bins
edge – how to define the edge. half=cutting a half bin at the edges. full=extending a half bin at the edge
- Returns
walls
exojax.utils.constants module¶
constants.
constants in cgs or km/s
logm_ucgs=np.log10(m_u*1.e3) where m_u = scipy.constants.m_u.
Tref: reference temperature used in exojax.spec
exojax.utils.gpkernel module¶
Kernels used in Gaussian process.
- exojax.utils.gpkernel.gpkernel_RBF(t, tau, a, err)¶
RBF kernel with diagnoal error.
- Parameters
t – variable vector (N)
tau – scale parameter (scalar)
a – amplitude (scalar)
err – diagnonal error vector (N)
- Returns
kernel
exojax.utils.grids module¶
generate various grids
- exojax.utils.grids.check_eslog_wavenumber_grid(nus, crit1=1e-05, crit2=1e-14, gridmode='ESLOG')¶
checking if wavenumber_grid is evenly spaced in a logarithm scale (ESLOG) or a liner scale (ESLIN)
- Parameters
nus – wavenumber grid
crit1 – criterion for the maximum deviation of log10(nu)/median(log10(nu)) from ESLOG
crit2 – criterion for the maximum deviation of log10(nu) from ESLOG
gridmode – ESLOG or ESLIN
- Returns
True (wavenumber grid is ESLOG) or False (not)
- exojax.utils.grids.check_scale_xsmode(xsmode)¶
checking if the scale of xsmode assumes ESLOG(log) or ESLIN(linear)
- Parameters
xsmode – xsmode
- Returns
ESLOG/ESLIN/UNKNOWN
- exojax.utils.grids.delta_velocity_from_resolution(resolution)¶
delta velocity from spectral resolution R
- Parameters
resolution – spectral resolution
Note
See also [#294](https://github.com/HajimeKawahara/exojax/issues/294) and exojax/tests/figures/functions/delta_velocity_comp.py
- Returns
delta velocity
- exojax.utils.grids.velocity_grid(resolution, vmax)¶
generate velocity grid for a rigid rotation
- Parameters
resolution – spectral resolution
vmax – maximum velocity (or Vsini) allowed (km/s)
- Returns
delta velocity grid
- Return type
1D array
- exojax.utils.grids.warn_resolution(resolution, crit=700000.0)¶
warning poor resolution.
- Parameters
resolution – spectral resolution
crit – critical resolution
- exojax.utils.grids.wavenumber_grid(x0, x1, N, unit='cm-1', xsmode='lpf')¶
generating the recommended wavenumber grid based on the cross section computation mode.
- Parameters
x0 – start wavenumber (cm-1) or wavelength (nm) or (AA)
x1 – end wavenumber (cm-1) or wavelength (nm) or (AA)
N – the number of the wavenumber grid (even number)
unit – unit of the input grid
xsmode – cross section computation mode (lpf, dit, modit, premodit)
Note
The wavenumber (nus) and wavelength (wav) grids are in ascending orders. Therefore, wav[-1] corresponds to the wavelength of nus[0]. ESLIN sets evenly-spaced linear grid in wavenumber space while ESLOG sets evenly-spaced log grid both in wavenumber and wavelength spaces.
- Returns
wavenumber grid evenly spaced in log space in ascending order (nus) corresponding wavelength grid (AA) in ascending order (wav). wav[-1] corresponds to nus[0] spectral resolution
exojax.utils.indexing module¶
- exojax.utils.indexing.find_or_add_index(new_index, index_array)¶
find a position of a new index in index_array, if not exisited add the new index in index_array
- Parameters
new_index – new index investigated
index_array – index array
- Returns
position, index_array updated
- exojax.utils.indexing.uniqidx(input_array)¶
compute indices based on uniq values of the input M-dimensional array.
- Parameters
input_array – input array (N,M), will use unique M-dim vectors
- Returns
unique index, unique value
Examples
>>> a=np.array([[4,1],[7,1],[7,2],[7,1],[8,0],[4,1]]) >>> uidx, uval=uniqidx(a) #->[0,1,2,1,3,0], [[4,1],[7,1],[7,2],[8,0]]
- exojax.utils.indexing.uniqidx_neibouring(index_array)¶
compute indices based on uniq values of the input index array and input index + one vector
- Parameters
index_array – input index array (N,M), will use unique M-dim vectors
- Returns
unique index (udix) neibouring index (nidx) for udix [N_uidx, 3] multi index as a function of nidx
- exojax.utils.indexing.unique_rows(x)¶
memory saved version of np.unique(,axis=0)
Notes
Originally from a snippet/Answer #4 (https://discuss.dizzycoding.com/find-unique-rows-in-numpy-array/?amp=1)
- Parameters
x (2D array) – 2D array (N x M), need to be C-contiguous
- Returns
unique 2D array (N’ x M), where N’ <= N, removed duplicated M vector.
- Return type
2D array
exojax.utils.instfunc module¶
Utility Functions about Instruments.
- exojax.utils.instfunc.R2STD(resolution)¶
- exojax.utils.instfunc.resolution_eslin(nu)¶
min max spectral resolution for ESLIN.
- Parameters
nu – wavenumber bin
- Returns
min, approximate, max of the resolution
- exojax.utils.instfunc.resolution_eslog(nu)¶
spectral resolution for ESLOG.
- Parameters
nu – wavenumber bin
- Returns
resolution
- exojax.utils.instfunc.resolution_to_gaussian_std(resolution)¶
compute Standard deveiation of Gaussian velocity distribution from spectral resolution.
- Parameters
resolution – spectral resolution R
- Returns
standard deviation of Gaussian velocity distribution (km/s)
exojax.utils.isodata module¶
Mass number and abundance list.
- exojax.utils.isodata.read_mnlist()¶
loading mass number list.
Note
this code reads data/atom/iso_mn.txt, taken from https://www.chem.ualberta.ca/~massspec/atomic_mass_abund.pdf The isotopic mass data is from G. Audi, A. H. Wapstra Nucl. Phys A. 1993, 565, 1-65 and G. Audi, A. H. Wapstra Nucl. Phys A. 1995, 595, 409-480. The percent natural abundance data is from the 1997 report of the IUPAC Subcommittee for Isotopic Abundance Measurements by K.J.R. Rosman, P.D.P. Taylor Pure Appl. Chem. 1999, 71, 1593-1607.
- Returns
dictionary of mass number, keys=”isotope”,”mass_number”,”abundance”
exojax.utils.isotopes module¶
- exojax.utils.isotopes.exact_isotope_name_from_isotope(simple_molecule_name, isotope)¶
exact isotope name from isotope (number)
- Parameters
simple_molecular_name (str) – simple molecular name such as CO
isotope (int) – isotope number starting from 1
- Returns
exact isotope name such as (12C)(16O)
- Return type
str
- exojax.utils.isotopes.get_isotope(atom, isolist)¶
get isotope info.
- Parameters
atom – simple atomic symbol, such as “H”, “Fe”
isolist – isotope list
- Returns
isotope list, such as “1H”, “2H” mass_number: mass_number list abundance: abundance list
- Return type
iso
- exojax.utils.isotopes.get_stable_isotope(atom, isolist)¶
get isotope info.
- Parameters
atom – simple atomic symbol, such as “H”, “Fe”
isolist – isotope list
- Returns
stabel isotope such as “1H”, “2H” mass_number: mass_number abundance: abundance
- Return type
iso
exojax.utils.molname module¶
- exojax.utils.molname.e2s(molname_exact)¶
convert the exact molname (used in ExoMol) to the simple molname.
- Parameters
molname_exact – the exact molname
- Returns
simple molname
Examples
>>> print(e2s("12C-1H4")) >>> CH4 >>> print(e2s("23Na-16O-1H")) >>> NaOH >>> print(e2s("HeH_p")) >>> HeH_p >>> print(e2s("trans-31P2-1H-2H")) #not working >>> Warning: Exact molname trans-31P2-1H-2H cannot be converted to simple molname >>> trans-31P2-1H-2H
- exojax.utils.molname.s2e_stable(molname_simple)¶
convert the simple molname to the exact molname (used in ExoMol) using stable isotopes.
- Parameters
molname_simple – simple molname
- Returns
exact molname
- exojax.utils.molname.split_simple(molname_simple)¶
split simple molname.
- Parameters
molname_simple – simple molname
- Returns
atom list number list
Example
>>> split_simple("Fe2O3") >>> (['Fe', 'O'], ['2', '3'])
exojax.utils.recexomol module¶
Get Recommendation from ExoMol.
- exojax.utils.recexomol.get_exomol_database_list(molecule, isotope_full_name)¶
Parse ExoMol website and return list of available databases, and recommended database.
- Parameters
molecule – str
isotope_full_name – str, isotope full name (ex.
12C-1H4
for CH4,1). Get it from
- Returns
database list database recomendation
Example
databases, recommended = get_exomol_database_list(“CH4”, “12C-1H4”) >>> [‘xsec-YT10to10’, ‘YT10to10’, ‘YT34to10’], ‘YT34to10’
Note
This function is borrowed from radis (https://github.com/radis/radis by @erwanp). See https://github.com/radis/radis/issues/319 in detail.
exojax.utils.url module¶
url.
This module contains various url for downloading. Because url can be changed by the orner of the site, you might need to change it. Or, if you notice the change, it would be great if you send a pull-request.
- exojax.utils.url.url_ExoMol()¶
return URL for ExoMol.
- Returns
URL for ExoMol db
- exojax.utils.url.url_Exomol_iso(molecule, isotope_full_name)¶
return URL for ExoMol for isotope.
- Returns
URL for ExoMol for isotope
- exojax.utils.url.url_HITEMP()¶
return URL for HITEMP bz2 parfile.
- Returns
URL for HITEMP bz2 file
- exojax.utils.url.url_HITEMP10()¶
return URL for HITEMP2010.
- Returns
URL for HITEMP2010 db
- exojax.utils.url.url_HITRAN12()¶
return URL for HITRAN 12 parfile.
- Returns
URL for HITRAN 12 parfile
- exojax.utils.url.url_HITRANCIA()¶
return URL for HITRAN CIA ciafile.
- Returns
URL for HITRAN CIA file
- exojax.utils.url.url_developer_data()¶
return URL for data in exojax.
- Returns
URL for ExoJAX
exojax.utils.zsol module¶
solar abundance.
Solar abundance data
AAG21 = Asplund, M., Amarsi, A. M., & Grevesse, N. 2021, arXiv:2105.01661
- exojax.utils.zsol.nsol(database='AAG21')¶
provide solar abundance dictionary.
- Parameters
database – name of database.
- Returns
number ratio of solar abundance
Example
>>> nsun=nsol() >>> print(nsun["Fe"]) >>> 2.6602622265852853e-05