petitRADTRANS.chemistry.utils#
Attributes#
Functions#
|
Calculate the ratio over the hydrogen elemental abundance of other elements. |
|
Calculate the metal to non-metal abundances from elemental abundances. |
|
Calculate the mean molecular weight in each layer. |
|
Fill an atmosphere with filling species, so that the sum of the mass fractions in all layers is 1. |
|
Fill an atmospheric layer with filling species, so that the sum of the mass fractions is 1. |
|
This function takes in the cloud base pressures for each cloud, |
|
Parse the solar elemental abundances string. |
|
Convert mass fractions to volume mixing ratios. |
|
Calculate the metallicity and element-over-hydrogen abundance ratios. |
|
|
|
Convert mass fractions to volume mixing ratios. |
|
Calculate the metallicity and element-over-hydrogen abundance ratios. |
Module Contents#
- petitRADTRANS.chemistry.utils._solar_elemental_abundances = Multiline-String#
Show Value
""" 1 12.00 0.00 2 10.924 0.02 3 3.27 0.03 4 1.31 0.04 5 2.77 0.03 6 8.47 0.06 7 7.85 0.12 8 8.73 0.07 9 4.61 0.09 10 8.15 0.10 11 6.27 0.03 12 7.52 0.02 13 6.42 0.03 14 7.51 0.01 15 5.43 0.03 16 7.15 0.03 17 5.23 0.06 18 6.50 0.10 19 5.07 0.02 20 6.27 0.03 21 3.04 0.03 22 4.90 0.03 23 3.95 0.03 24 5.63 0.02 25 5.47 0.03 26 7.45 0.02 27 4.86 0.02 28 6.20 0.03 29 4.24 0.04 30 4.61 0.60 31 3.07 0.02 32 3.59 0.03 33 2.29 0.03 34 3.34 0.03 35 2.60 0.09 36 3.22 0.08 37 2.36 0.03 38 2.88 0.02 39 2.15 0.02 40 2.55 0.04 41 1.4 0.04 42 1.92 0.04 44 1.77 0.01 45 1.04 0.02 46 1.65 0.02 47 1.21 0.02 48 1.71 0.02 49 0.76 0.02 50 2.07 0.03 51 1.06 0.05 52 2.18 0.02 53 1.71 0.15 54 2.25 0.08 55 1.08 0.02 56 2.17 0.02 57 1.17 0.02 58 1.58 0.02 59 0.75 0.01 60 1.45 0.01 62 0.94 0.02 63 0.51 0.02 64 1.05 0.02 65 0.31 0.02 66 1.12 0.02 67 0.46 0.02 68 0.92 0.02 69 0.11 0.02 70 0.91 0.02 71 0.09 0.02 72 0.70 0.03 73 -0.16 0.02 74 0.67 0.04 75 0.23 0.03 76 1.33 0.03 77 1.31 0.02 78 1.60 0.03 79 0.80 0.03 80 1.08 0.15 81 0.76 0.04 82 2.03 0.03 83 0.66 0.03 90 0.04 0.02 92 -0.54 0.03 """
- petitRADTRANS.chemistry.utils._compute_h_ratios(elemental_abundances: dict[int, float]) dict[int, float] #
Calculate the ratio over the hydrogen elemental abundance of other elements.
- petitRADTRANS.chemistry.utils._compute_z_ratios(elemental_abundances: dict[int, float], sort: bool = True, neglect_he: bool = False) float #
Calculate the metal to non-metal abundances from elemental abundances.
- petitRADTRANS.chemistry.utils.compute_mean_molar_masses(abundances)#
Calculate the mean molecular weight in each layer.
- Args:
- abundancesdict
dictionary of abundance arrays, each array must have the shape of the pressure array used in pRT, and contain the abundance at each layer in the atmosphere.
- petitRADTRANS.chemistry.utils.fill_atmosphere(mass_fractions: dict[str, numpy.typing.NDArray[float]], filling_species: dict, fill_layer: int = 'all') dict[str, numpy.typing.NDArray[float]] #
Fill an atmosphere with filling species, so that the sum of the mass fractions in all layers is 1.
See fill_atmospheric_layer for more details.
- Args:
- mass_fractions:
Dictionary with the species as keys and the mass fraction in all layers as values.
- filling_species:
Dictionary with the filling species as keys and the weights of the mass fractions as values. Unweighted filling species are represented with None.
- fill_layer:
If ‘all’, fill all layers and return the filled mass fractions at every layer. If it is an integer, fill only the corresponding layer and return the mass fractions at that layer only.
- Returns:
A dictionary of the mass fractions with the filling species. The sum of the mass fractions is 1.
- petitRADTRANS.chemistry.utils.fill_atmospheric_layer(mass_fractions: dict[str, float], filling_species: dict, sanity_check: bool = False) dict[str, float] #
Fill an atmospheric layer with filling species, so that the sum of the mass fractions is 1. The filling species values are weights that are used to fill the atmospheric layer following:
X_i = w_i / sum(w) * X_f,
where X_i is the mass fraction of filling species i, w_i is the weight of species i, and X_f is the amount of mass fraction missing to get a sum of 1.
- The value X_f is calculated from:
X_f = 1 - sum(X_nf),
where X_nf is the sum of mass fractions that are not filling species.
The filling species can be “weighted” (if the weights are all floats) or “unweighted” (if the weights are all None). In weighted mode, w corresponds to the values of filling_species. In unweighted mode, the mass fractions are used to calculate the weights. All the filling species must be in the mass fractions. Mixing weighted and unweighted filling species raises a ValueError.
- Args:
- mass_fractions:
Dictionary with the species as keys and the mass fraction in one layer as values.
- filling_species:
Dictionary with the filling species as keys and the weights of the mass fractions as values. Unweighted filling species are represented with None.
- sanity_check:
If True, make a sanity check to ensure that the filling was consistently done.
- Returns:
A dictionary of the mass fractions with the filling species. The sum of the mass fractions is 1.
- petitRADTRANS.chemistry.utils.fixed_length_amr(p_clouds, pressures, scaling=10, width=3)#
This function takes in the cloud base pressures for each cloud, and returns an array of pressures with a high resolution mesh in the region where the clouds are located.
Author: Francois Rozet.
- The output length is always
len(pressures[::scaling]) + len(p_clouds) * width * (scaling - 1)
- Args:
- p_cloudsnumpy.ndarray
The cloud base pressures in bar
- pressuresnp.ndarray
The high resolution pressure array.
- scalingint
The factor by which the low resolution pressure array is scaled
- widthint
The number of low resolution bins to be replaced for each cloud layer.
- petitRADTRANS.chemistry.utils.get_solar_elemental_abundances(keep_list: list[int] = None) dict[int, float] #
Parse the solar elemental abundances string. Args:
- keep_list:
List of atomic numbers to keep in the returned dictionary. If None, all atomic numbers are kept.
- petitRADTRANS.chemistry.utils.mass_fractions2volume_mixing_ratios(mass_fractions, mean_molar_masses=None)#
Convert mass fractions to volume mixing ratios.
- Args:
- mass_fractionsdict
A dictionary of mass fractions
- mean_molar_massesnumpy.ndarray
An array containing all mass fractions at each pressure level
- petitRADTRANS.chemistry.utils.mass_fractions2metallicity(mass_fractions: dict[str, numpy.typing.NDArray[float]], mean_molar_masses: numpy.typing.NDArray[float], neglect_he: bool = False, only_atmospheric_species_for_solar_metallicity: bool = False)#
Calculate the metallicity and element-over-hydrogen abundance ratios.
- Args:
- mass_fractions:
Dictionary of mass fractions for all atmospheric species. Dictionary keys are the species names. Values are the mass fractions of each species at each layer.
- mean_molar_masses:
The atmospheric mean molecular weight in amu, at each atmospheric layer.
- neglect_he:
If True, helium will be neglected as a non-metal in the metallicity calculation, such that everything is defined with respect to hydrogen.
- only_atmospheric_species_for_solar_metallicity:
If True, only the species also present in the planet atmosphere will be used to calculate the solar metallicity. If False, all species present in the sun will be used to calculate the solar metallicity.
- Returns:
The atmospheric metallicity and a dictionary containing element-over-hydrogen abundance ratios. The dictionary keys are the elements atomic numbers. Values are dictionaries containing the plain-text H ratio, the atmospheric H ratio (‘local’ key), and its value relative to the solar H ratio (‘relative to solar’ key)
- petitRADTRANS.chemistry.utils.simplify_species_list(species_list: list) list #
- petitRADTRANS.chemistry.utils.volume_mixing_ratios2mass_fractions(volume_mixing_ratios, mean_molar_masses=None)#
Convert mass fractions to volume mixing ratios.
- Args:
- volume_mixing_ratiosdict
A dictionary of volume mixing ratios
- mean_molar_massesnumpy.ndarray
An array containing all mass fractions at each pressure level
- petitRADTRANS.chemistry.utils.volume_mixing_ratios2metallicity(volume_mixing_ratios: dict[str, numpy.ndarray[float]], neglect_he: bool = False, only_atmospheric_species_for_solar_metallicity: bool = False)#
Calculate the metallicity and element-over-hydrogen abundance ratios.
- Args:
- volume_mixing_ratios:
Dictionary of volume mixing ratios for all atmospheric species. Dictionary keys are the species names. Values are the VMR of each species at each layer.
- neglect_he:
If True, helium will be neglected as a non-metal in the metallicity calculation, such that everything is defined with respect to hydrogen.
- only_atmospheric_species_for_solar_metallicity:
If True, only the species also present in the planet atmosphere will be used to calculate the solar metallicity. If False, all species present in the sun will be used to calculate the solar metallicity.
- Returns:
The atmospheric metallicity and a dictionary containing element-over-hydrogen abundance ratios. The dictionary keys are the elements atomic numbers. Values are dictionaries containing the plain-text H ratio, the atmospheric H ratio (‘local’ key), and its value relative to the solar H ratio (‘relative to solar’ key)