Functions Reference¶
All functions are accessible from the top-level pyexocross namespace:
import pyexocross as px
Every function accepts either:
An
.inpfile path viainp_filepath, orKeyword arguments (
**kwargs), orBoth (keyword arguments override
.inpfile values).
Common CPU/GPU Compute Kwargs¶
PyExoCross uses CPU by default. You can explicitly select compute mode with:
Kwarg |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
|
|
|
|
GPU backend policy: |
|
|
|
GPU line-batch size for memory control |
|
|
|
GPU grid-batch size for memory control |
GPU acceleration is available for:
px.cooling_functionspx.stick_spectrapx.cross_sectionspx.stick_spectra_cross_section
CPU formulas are used for:
px.conversionpx.partition_functionspx.specific_heatspx.lifetimespx.oscillator_strengths
If run_mode='GPU' but no compatible backend is available, PyExoCross falls
back to CPU formulas.
# Default CPU mode
px.cross_sections(..., run_mode='CPU')
# GPU mode (auto backend)
px.cross_sections(
...,
run_mode='GPU',
gpu_backend='AUTO',
gpu_batch_lines=8192,
gpu_batch_grid=256,
)
# CUDA policy: PyTorch-CUDA -> CuPy-CUDA -> MPS -> CPU fallback
px.cross_sections(..., run_mode='GPU', gpu_backend='CUDA')
# Force PyTorch CUDA only
px.cross_sections(..., run_mode='GPU', gpu_backend='PyTorch-CUDA')
# Force CuPy CUDA only
px.cross_sections(..., run_mode='GPU', gpu_backend='CuPy-CUDA')
# Force PyTorch MPS only
px.cross_sections(..., run_mode='GPU', gpu_backend='MPS')
px.run¶
px.run(inp_filepath, force_reload=False)
Run all enabled functions from an .inp configuration file. This is the
programmatic equivalent of running python3 run.py -p <inp_filepath> from the
command line.
Parameters
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
Path to the |
|
|
No |
Force re-parse of |
:::{note}
If you edit the same .inp file repeatedly in a long-lived session (e.g. Jupyter),
use force_reload=True to avoid reusing stale cached parameters.
:::
Example
px.run('/path/to/MgH_ExoMol.inp')
# Re-read updated .inp content in the same session
px.run('/path/to/MgH_ExoMol.inp', force_reload=True)
px.conversion¶
px.conversion(inp_filepath=None, **kwargs)
Convert between ExoMol/ExoAtom and HITRAN line-list formats.
Parameters
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Path to |
|
|
|
|
|
|
|
Molecule name (e.g. |
|
|
|
Atom name for ExoAtom (e.g. |
|
|
|
Isotopologue (e.g. |
|
|
|
Dataset name (e.g. |
|
|
|
Species identifier (e.g. |
|
|
|
Path to input database |
|
|
|
Path for output files |
|
|
|
Log file path |
|
|
|
|
|
|
|
Minimum frequency in cm⁻¹ |
|
|
|
Maximum frequency in cm⁻¹ |
|
|
|
Uncertainty filter (cm⁻¹); |
|
|
|
Intensity threshold (cm/molecule); |
|
|
|
Global quantum number labels for HITRAN output |
|
|
|
Global QN format specifiers (total 15 chars in HITRAN2004) |
|
|
|
Local quantum number labels for HITRAN output |
|
|
|
Local QN format specifiers (total 15 chars in HITRAN2004) |
|
|
|
Quantum number labels from |
|
|
|
Quantum number format specifiers |
|
|
|
CPU cores for processing transitions |
|
|
|
Files processed simultaneously |
|
|
|
Chunk size for transitions |
Legacy Aliases
px.convert_exomol_to_hitran(...) # Sets conversion_format='HITRAN'
px.convert_exomolhr_to_hitran(...) # Sets conversion_format='HITRAN'
px.convert_exoatom_to_hitran(...) # Sets conversion_format='HITRAN'
px.convert_hitran_to_exomol(...) # Sets conversion_format='ExoMol'
Example
px.conversion(
database='ExoMol',
molecule='MgH',
isotopologue='24Mg-1H',
dataset='XAB',
species_id=501,
read_path='/path/to/ExoMol/',
save_path='/path/to/output/',
conversion_format='HITRAN',
global_qn_label_list=['ElecState', 'v', 'Omega'],
global_qn_format_list=['%9s', '%2d', '%4s'],
local_qn_label_list=['J', 'e/f'],
local_qn_format_list=['%5.1f', '%2s'],
)
px.partition_functions¶
px.partition_functions(inp_filepath=None, **kwargs)
Calculate partition functions \(Q(T) = \sum_n g_n^{\text{tot}} \exp(-c_2 \tilde{E}_n / T)\).
Parameters
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Path to |
|
|
|
Database name |
|
|
|
Molecule name |
|
|
|
Atom name (ExoAtom) |
|
|
|
Isotopologue |
|
|
|
Dataset name |
|
|
|
Species identifier |
|
|
|
Input database path |
|
|
|
Output path |
|
|
|
Log file path |
|
|
|
Temperature step in K |
|
|
|
Maximum temperature in K |
|
|
|
CPU cores for transitions |
|
|
|
Files processed simultaneously |
|
|
|
Chunk size |
Legacy Alias: px.partition_function
Example
px.partition_functions(
database='ExoMol',
molecule='MgH',
isotopologue='24Mg-1H',
dataset='XAB',
species_id=501,
read_path='/path/to/ExoMol/',
save_path='/path/to/output/',
ntemp=1,
tmax=5000,
)
px.specific_heats¶
px.specific_heats(inp_filepath=None, **kwargs)
Calculate specific heat capacities \(C_p(T)\) using partition function derivatives.
Parameters: Same as px.partition_functions.
Legacy Alias: px.specific_heat
Example
px.specific_heats(
database='ExoMol',
molecule='MgH',
isotopologue='24Mg-1H',
dataset='XAB',
species_id=501,
read_path='/path/to/ExoMol/',
save_path='/path/to/output/',
ntemp=1,
tmax=5000,
)
px.cooling_functions¶
px.cooling_functions(inp_filepath=None, **kwargs)
Calculate cooling functions:
Parameters
Same as px.partition_functions, plus optional
compute backend kwargs:
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
GPU line-batch size (memory control) |
|
|
|
GPU grid-batch size (memory control) |
Legacy Alias: px.cooling_function
Example
px.cooling_functions(
database='ExoMol',
molecule='MgH',
isotopologue='24Mg-1H',
dataset='XAB',
species_id=501,
read_path='/path/to/ExoMol/',
save_path='/path/to/output/',
ntemp=1,
tmax=5000,
run_mode='CPU',
)
px.lifetimes¶
px.lifetimes(inp_filepath=None, **kwargs)
Calculate radiative lifetimes: $\(\tau_i = 1 / \sum_f A_{fi}\)$
Parameters
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Path to |
|
|
|
Database name |
|
|
|
Molecule name |
|
|
|
Atom name (ExoAtom) |
|
|
|
Isotopologue |
|
|
|
Dataset name |
|
|
|
Species identifier |
|
|
|
Input database path |
|
|
|
Output path |
|
|
|
Log file path |
|
|
|
|
|
|
|
CPU cores for transitions |
|
|
|
Files processed simultaneously |
|
|
|
Chunk size |
Legacy Alias: px.lifetime
Example
px.lifetimes(
database='ExoMol',
molecule='MgH',
isotopologue='24Mg-1H',
dataset='XAB',
species_id=501,
read_path='/path/to/ExoMol/',
save_path='/path/to/output/',
compress=False,
)
px.oscillator_strengths¶
px.oscillator_strengths(inp_filepath=None, **kwargs)
Calculate oscillator strengths: weighted \(gf = g_{\text{tot}}' A_{fi} / (c \tilde{\nu}_{fi})^2\) or unweighted \(f\)-values.
Parameters
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Path to |
|
|
|
Database name |
|
|
|
Molecule name |
|
|
|
Atom name (ExoAtom) |
|
|
|
Isotopologue |
|
|
|
Dataset name |
|
|
|
Species identifier |
|
|
|
Input database path |
|
|
|
Output path |
|
|
|
Log file path |
|
|
|
|
|
|
|
CPU cores for transitions |
|
|
|
Files processed simultaneously |
|
|
|
Chunk size |
|
|
|
Whether to generate a plot |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Lower limit for y-axis |
Legacy Alias: px.oscillator_strength
Example
px.oscillator_strengths(
database='ExoMol',
molecule='MgH',
isotopologue='24Mg-1H',
dataset='XAB',
species_id=501,
read_path='/path/to/ExoMol/',
save_path='/path/to/output/',
gf_or_f='f',
plot=True,
plot_method='log',
plot_wn_wl='WN',
plot_unit='cm-1',
limit_yaxis=1e-30,
)
px.stick_spectra¶
px.stick_spectra(inp_filepath=None, **kwargs)
Calculate LTE or Non-LTE stick spectra (absorption or emission).
Parameters
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Path to |
Species |
|||
|
|
|
|
|
|
|
Molecule name |
|
|
|
Atom name (ExoAtom) |
|
|
|
Isotopologue |
|
|
|
Dataset name |
|
|
|
Species identifier |
Paths |
|||
|
|
|
Input database path |
|
|
|
Output path |
|
|
|
Log file path |
Physical conditions |
|||
|
|
|
Temperature(s) in K |
|
|
|
|
|
|
|
|
|
|
|
Minimum range value (in |
|
|
|
Maximum range value (in |
|
|
|
|
Non-LTE |
|||
|
|
|
|
|
|
|
Vibrational temperatures for method |
|
|
|
Rotational temperatures for method |
|
|
|
Vibrational QN labels for method |
|
|
|
Rotational QN labels for method |
|
|
|
Path to NLTE data file (methods |
Filters |
|||
|
|
|
Intensity threshold (cm/molecule); |
|
|
|
Uncertainty filter (cm⁻¹); |
|
|
|
Quantum number filter (see below) |
Quantum numbers |
|||
|
|
|
QN labels from |
|
|
|
QN format specifiers |
Computing |
|||
|
|
|
CPU cores for transitions |
|
|
|
Files processed simultaneously |
|
|
|
Chunk size |
|
|
|
|
|
|
|
|
|
|
|
GPU line-batch size (memory control) |
|
|
|
GPU grid-batch size (memory control) |
Plotting |
|||
|
|
|
Whether to generate a plot |
|
|
|
|
|
|
|
X-axis: |
|
|
|
|
|
|
|
Lower limit for y-axis (cm/molecule) |
Quantum Number Filter (qns_filter)¶
The qns_filter parameter accepts a dictionary where keys are quantum number
labels and values are lists of accepted value patterns. Use an empty list
[] to accept all values for that label.
qns_filter={
'+/-': [], # accept all parities
'v': ['0,', '1,', '2,'], # only v' = 0, 1, 2
'ElecState': [], # accept all electronic states
}
Example
px.stick_spectra(
database='ExoMol',
molecule='MgH',
isotopologue='24Mg-1H',
dataset='XAB',
species_id=501,
read_path='/path/to/ExoMol/',
save_path='/path/to/output/',
temperatures=[1000, 2000],
wn_wl='WN',
wn_wl_unit='cm-1',
min_range=0,
max_range=30000,
abs_emi='Ab',
run_mode='CPU',
)
px.cross_sections¶
px.cross_sections(inp_filepath=None, **kwargs)
Calculate LTE or Non-LTE cross sections with a choice of line profiles.
Parameters
All parameters from px.stick_spectra, plus:
Parameter |
Type |
Default |
Description |
|---|---|---|---|
Grid |
|||
|
|
|
Pressure(s) in bar |
|
|
|
Bin size (in |
|
|
|
Number of grid points; mutually exclusive with |
Line profile |
|||
|
|
|
Line profile (see table below) |
|
|
|
Wing cutoff in cm⁻¹; |
|
|
|
Use predissociation lifetimes for Voigt width |
Broadening |
|||
|
|
|
Broadening species |
|
|
|
Broadener mixing ratios (must sum to 1.0) |
|
|
|
Constant Doppler HWHM; |
|
|
|
Constant Lorentzian HWHM; |
Plotting |
|||
|
|
|
Whether to generate a plot |
|
|
|
|
|
|
|
X-axis: |
|
|
|
|
|
|
|
Lower limit for y-axis (cm\(^2\)/molecule) |
Available Line Profiles¶
Profile Name |
Description |
|---|---|
|
Pure Doppler profile |
|
Gaussian profile |
|
Lorentzian profile |
|
Voigt via SciPy |
|
Voigt via SciPy |
|
Humlicek algorithm for Voigt |
|
Generic pseudo-Voigt |
|
Thompson pseudo-Voigt approximation |
|
Kielkopf pseudo-Voigt approximation |
|
Olivero pseudo-Voigt approximation |
|
Liu-Lin pseudo-Voigt approximation |
|
Rocco pseudo-Voigt approximation |
|
Binned Doppler profile |
|
Binned Gaussian profile |
|
Binned Lorentzian profile |
|
Binned Voigt profile |
Available Broadeners¶
Broadener |
Description |
|---|---|
|
Default broadening parameters |
|
Air broadening (N\(_2\) + O\(_2\)) |
|
Self broadening |
|
Hydrogen broadening |
|
Helium broadening |
|
CO\(_2\) broadening |
|
Water broadening |
Legacy Alias: px.cross_section
Example
px.cross_sections(
database='ExoMol',
molecule='MgH',
isotopologue='24Mg-1H',
dataset='XAB',
species_id=501,
read_path='/path/to/ExoMol/',
save_path='/path/to/output/',
temperatures=[1000, 2000],
pressures=[1.0],
wn_wl='WN',
wn_wl_unit='cm-1',
min_range=0,
max_range=30000,
bin_size=0.1,
profile='SciPyVoigt',
run_mode='GPU',
gpu_backend='AUTO',
gpu_batch_lines=8192,
gpu_batch_grid=256,
broadeners=['Default'],
ratios=[1.0],
cutoff=25.0,
plot=True,
plot_method='log',
)
px.stick_spectra_cross_section¶
px.stick_spectra_cross_section(inp_filepath=None, **kwargs)
Calculate LTE or Non-LTE stick spectra and cross sections simultaneously.
Parameters
All parameters from px.stick_spectra and px.cross_sections.
Example
px.stick_spectra_cross_section(
database='ExoMol',
molecule='MgH',
isotopologue='24Mg-1H',
dataset='XAB',
species_id=501,
read_path='/path/to/ExoMol/',
save_path='/path/to/output/',
temperatures=[1000, 2000],
pressures=[1.0],
wn_wl='WN',
wn_wl_unit='cm-1',
min_range=0,
max_range=30000,
bin_size=0.1,
profile='SciPyVoigt',
run_mode='GPU',
gpu_backend='AUTO',
gpu_batch_lines=8192,
gpu_batch_grid=256,
plot=True,
)