Skip to main content

Python Wrapper for FastChem chemical scheme

Project description

TauREx-FastChem plugin

A Python wrapper built using the TauREx is available. The wrapper also installs all available datafiles included with FastChem

Installation

You can install one of the prebuilt binary wheels for Windows, macOS and manylinux through pip:

pip install taurex_fastchem

Installing from source

To install from source a valid C/C++ compiler must be present. You can compile it by doing:

git clone https://github.com/ucl-exoplanets/FastChem.git
cd FastChem
pip install .

Running in TauREx

Once installed you can select the chemical model through the chemistry_type keyword under Chemistry.

[Chemistry]
chemistry_type = fastchem
metallicity = 1.0
selected_elements = H, He, C, N, O, Ti, V, S, K
ratio_elements = C, N, Ti
ratios_to_O = 0.5,0.001, 1e-4
with_ions = True

[Fitting]
Ti_O_ratio:fit = True
Ti_O_ratio:prior = "LogUniform(bounds=(-6,2))"
S_O_ratio:fit = True
S_O_ratio:prior = "LogUniform(bounds=(-6,2))"
metallicity:fit = True
metallicity:prior = "LogUniform(bounds=(-6,2))"

Input arguments:

These arguments apply to both the TauREx input file and python interface.

Argument Description Type Default Required
H_He_ratio He/H ratio float 0.083
selected_elements List of elements to include in model list of string All elements in FastChem
ratio_elements List of elements to set the ratio list of string
ratios_to_O ratio of each 'ratio_element' relative to oxygen array
elements_abundance_file Path to file that defines initial abundances (in dex) string Builtin (solar)
metallicity Metallicity relative to initial abundance float 1.0
elements_datafile Path to file containing elements and their masses string Built-in (chemical_abundances.dat)
species_datafile Path to file containing species and thermochemical data string Built-in (logK.dat)
chem_accuracy
with_ions Include ions bool False
pressure_accuracy
newton_error
max_chem_iter
max_press_iter
max_nedler_iter
longdouble Use 80 bit floats for faster convergence bool False

Retrieval Parameters:

Fitting Parameter Description
metallicity Metallicity relative to solar

The wrapper will generate oxygen retrieval parameters for all metallic elements within the chemical model. If Ti is present (either by default or specifing in selected_elements) then a Ti_O_ratio retrieval parameter will be available. Using the default selected_parameters will give access to:

Fitting Parameter Description
Al_O_ratio Al/O ratio
Ar_O_ratio Ar/O ratio
C_O_ratio C/O ratio
Ca_O_ratio Ca/O ratio
Cl_O_ratio Cl/O ratio
Co_O_ratio Co/O ratio
Cr_O_ratio Cr/O ratio
Cu_O_ratio Cu/O ratio
F_O_ratio F/O ratio
Fe_O_ratio Fe/O ratio
Ge_O_ratio Ge/O ratio
K_O_ratio K/O ratio
Mg_O_ratio Mg/O ratio
Mn_O_ratio Mn/O ratio
N_O_ratio N/O ratio
Na_O_ratio Na/O ratio
Ne_O_ratio Ne/O ratio
Ni_O_ratio Ni/O ratio
P_O_ratio P/O ratio
S_O_ratio S/O ratio
Si_O_ratio Si/O ratio
Ti_O_ratio Ti/O ratio
V_O_ratio V/O ratio
Zn_O_ratio Zn/O ratio

Running in Python

You can import the chemistry scheme in Python pretty easily

>>> from taurex_fastchem import FastChem
>>> fc = FastChem(selected_elements=['H','He','C','O','N','K','e-'], 
                  with_ions=True, metallicity=1.0)

You can either pass it into a TauREx forward model like so:

>>> tm = TransmissionModel(chemistry=fc)

Or use it independently to compute volume mixing ratios by passing in temperature and pressure ( Pascal ) arrays:

>>> nlayers = 10
>>> temperature = np.linspace(300,100,nlayers)
>>> pressure = np.logspace(5,-3, nlayers) # Pa
>>> fc.initialize_chemistry(nlayers,temperature,pressure)
>>> fc.gases
['H', 'He', 'O', 'C', 'K', 'N', 'e-', ..., 'O+', 'O-', 'O2+', 'O2-']
>>> fc.mixProfile
array([[3.87435866e-036, 9.95149979e-039, 7.62616463e-042,
        1.23490910e-045, 2.58839801e-050, 3.41640407e-056,
        9.40930967e-064, 9.08433703e-074, 1.41255491e-087,
        1.38065040e-167],
        ...,
       [1.42400626e-001, 1.42400626e-001, 1.42400626e-001,
        1.42400626e-001, 1.42400626e-001, 1.42400791e-001,
        1.42398731e-001, 1.42398284e-001, 1.42367067e-001,
        9.96186945e-001]])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

taurex_fastchem-1.0.0.dev0.tar.gz (2.6 MB view hashes)

Uploaded Source

Built Distributions

taurex_fastchem-1.0.0.dev0-cp39-cp39-win_amd64.whl (168.5 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

taurex_fastchem-1.0.0.dev0-cp39-cp39-manylinux2010_i686.whl (2.1 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ i686

taurex_fastchem-1.0.0.dev0-cp39-cp39-macosx_10_9_x86_64.whl (193.2 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

taurex_fastchem-1.0.0.dev0-cp38-cp38-win_amd64.whl (169.8 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

taurex_fastchem-1.0.0.dev0-cp38-cp38-manylinux2010_i686.whl (2.1 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

taurex_fastchem-1.0.0.dev0-cp38-cp38-macosx_10_9_x86_64.whl (192.9 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

taurex_fastchem-1.0.0.dev0-cp37-cp37m-win_amd64.whl (168.4 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

taurex_fastchem-1.0.0.dev0-cp37-cp37m-manylinux2010_i686.whl (2.1 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

taurex_fastchem-1.0.0.dev0-cp37-cp37m-macosx_10_9_x86_64.whl (192.3 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

taurex_fastchem-1.0.0.dev0-cp36-cp36m-win_amd64.whl (168.6 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

taurex_fastchem-1.0.0.dev0-cp36-cp36m-manylinux2010_i686.whl (2.1 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ i686

taurex_fastchem-1.0.0.dev0-cp36-cp36m-macosx_10_9_x86_64.whl (192.3 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page