petitRADTRANS.opacities.opacities

Contents

petitRADTRANS.opacities.opacities#

Manage the opacity files.

Attributes#

Classes#

Opacity

Generic class for opacity files.

CIAOpacity

Class for collision-induced opacity files.

CloudOpacity

Class for cloud opacity files.

CorrelatedKOpacity

Class for correlated-k opacity files.

LineByLineOpacity

Class for line-by-line opacity files.

Module Contents#

petitRADTRANS.opacities.opacities.comm = None#
petitRADTRANS.opacities.opacities.rank = 0#
petitRADTRANS.opacities.opacities.comm#
class petitRADTRANS.opacities.opacities.Opacity(species_list: list[str], natural_abundance: bool = False, charge: int = 0, source: str = 'unknown', spectral_sampling_type: str = 'R', spectral_sampling: int | float = 0.0, wavelength_min: float = 0.0, wavelength_max: float = 0.0, matter_state: str = _gas_matter_state, solid_structure: str = None, solid_structure_id: str = None, path_input_data: str = None, category: str = _default_category, species_full_name: str = None, species_cloud_info: str = None, species_base_name: str = None, species_isotopologue_name: str = None, extension: str = _default_extension, full_extension: str = None, file_name: str = None, sub_path: str = None, directory: str = None, absolute_path: str = None)#

Generic class for opacity files.

Opacity files are HDF5 files named by joining information tokens with specific separators. The naming pattern is an extension on the ExoMol https://www.exomol.com/ naming pattern.

Species names are formed by joining the atomic element symbols with isotopic information as follows:

<mass number><element symbol><number of atoms>-<mass number><element symbol><number of atoms>-


Below is an example for CH3D, monodeuterated methane:

12C-1H3-2H

Opacity files ends with the following extensions:

<opacity type>.<opacity file generator software>.h5

The naming pattern contains the opacity sampling information (“OSI”) as follows:

<opacity sampling type><opacity sampling value>_<wavelength min (um)>-<wavelength max (um)>mu

Neutral species in the gas phase are named with the following pattern (e.g., for CH3D(g)):

12C-1H3-2H__<line list source>.<OSI>.<file extensions>

Charge information can be added for ions as follows: (e.g., for [CH3D]2+(g)):

12C-1H3-2H_2+__<line list source>.<OSI>.<file extensions>

Species in the liquid phase are named with the following pattern (e.g., for CH3D(l)):

12C-1H3-2H(l)__<line list source>.<OSI>.<file extensions>

Species in the solid phase are named with the following pattern (e.g., for CH3D(s)):

12C-1H3-2H(s)_<solid structure>_<solid structure_id>__<line list source>.<OSI>.<file extensions>

Opacities containing a mix of isotopologues following the Earth’s “natural” abundances does not display isotopic information and are flagged with the string “NatAbund” (e.g., for CH4):

C-H4-NatAbund__<line list source>.<OSI>.<file extensions>

Opacities originating from multiple species (e.g., collision-induced absorptions, CIAs) are named with this pattern (e.g., for H2-He CIA with the Earth’s isotopologue ratios):

H2–He-NatAbund__<line list source>.<OSI>.<file extensions>

Args:
species_list: list of str

The list of species contributing to the opacity. For single-species opacities, use [species_name]. Examples: [1H2-17O], [N2, CO2]

natural_abundance: bool, optional

If True, the species is considered following the Earth’s isotopic ratios. Default is False.

charge: int, optional

The charge of the species (for single-species opacities only). A value of 0 is used for neutral species. Default is 0.

source: str, optional

The source (i.e., where or how the opacity were obtained) of the opacity. Default is “unknown”.

spectral_sampling_type: {‘DeltaWavelength’, ‘DeltaWavenumber’, ‘R’}, optional
The opacity spectral sampling type. Default is ‘R’.
  • ‘DeltaWavelength’: sampling with a constant wavelength step.

  • ‘DeltaWavenumber’: sampling with a constant wavenumber step.

  • ‘R’: sampling with a constant resolving power (wavelength / wavelength step).

spectral_sampling: int or float, optional
The opacity spectral sampling value. Default is 0. Units depends on spectral_sampling_type:
  • ‘DeltaWavelength’: um

  • ‘DeltaWavenumber’: cm-1

  • ‘R’: no units

Example:

To indicate a spectral sampling with a constant resolving power of 1000. >>> spectral_sampling_type=’R’ >>> spectral_sampling=1000

wavelength_min: float, optional

(um) Lower wavelength bounds of the opacity data. Default is 0.

wavelength_max: float, optional

(um) Upper wavelength bounds of the opacity data. Default is 0.

matter_state: {‘(g)’, ‘(l)’, ‘(s)’}, optional
The species matter state. Default is ‘(g)’.
  • ‘(g)’: gas phase.

  • ‘(l)’: liquid phase.

  • ‘(s)’: solid phase.

solid_structure: {‘amorphous’, ‘crystalline’, ‘structureUnclear’}, optional
If the species is in solid phase, indicate the solid structure of the species. Default is None.
  • ‘amorphous’: the solid has an amorphous internal structure.

  • ‘crystalline’: the solid is in a crystal form.

  • ‘structureUnclear’: internal structure was not provided by the source.

solid_structure_id: str, optional

Solid structure identifier. For crystals, this corresponds to the 3-digits space group. See https://en.wikipedia.org/wiki/List_of_space_groups An unknown space group is indicated as ‘000’.

path_input_data: str, optional

Absolute path to petitRadtrans’ “input_data” directory, where the opacity files are stored. By default, use the path provided in petitRadtrans’ config file.

category: {‘cia_opacities’, ‘clouds_opacities’, ‘correlated_k_opacities’, ‘line_by_line_opacities’}, optional
The opacity category. Indicates the input_data subpath. Default is ‘unknown’.
  • ‘cia_opacities’: for collision-induced absorptions.

  • ‘clouds_opacities’: for cloud opacities.

  • ‘correlated_k_opacities’: for correlated-k opacities.

  • ‘line_by_line_opacities’: for line-by-line opacities.

species_full_name: str, optional

Override the species full name. The species full name is composed of the species isotopic information, the natural abundance flag (if relevant), and the charge.

species_cloud_info: str, optional

Override the species cloud information. The species cloud information is composed of the species matter state, and of its solid structure and structure id (if relevant).

species_base_name: str, optional

Override the species base name. The species base name is the species chemical formula without isotopic information. It may contain cloud information and charge. Examples: “H2O”, “H2O(l)”, “H2O_+(s)_crystalline_000”.

species_isotopologue_name: str, optional

Override the species isotopologue name. The species isotopologue name is the species name with isotopic information. It may contain cloud information and charge. Examples: “1H2-16O”, “H2O-NatAbund(l)”, “1H2-18O_+(s)_crystalline_000”.

extension: str, optional

The opacity file type extension. Default is “unknown”. Use “petitRADTRANS” for files generated with petitRADTRANS.

full_extension: str, optional

Override the opacity file full extension. The opacity file full extension is composed of the opacity file type extension, the opacity file generator software extension, and of the file format extension.

file_name: str, optional

Override the opacity file name. By default, it is generated from the instanciation arguments.

sub_path: str, optional

Override the opacity sub path. By default, it depends on the selected category.

directory: str, optional

Override the opacity directory. By default, it is generated from the species full name and from the other path information.

absolute_path: str, optional

Override the absolute path of the opacity file. By default, it is genrated from the other path information.

_default_category: str = 'unknown_opacities'#
_temperature_grid_types: set[str]#
_minus_char: str = 'm'#
_plus_char: str = 'p'#
_minus_symbol: str = '-'#
_plus_symbol: str = '+'#
_charges: dict[str, str]#
_charge_symbols: set[str]#
_charge_chars: set[str]#
_gas_matter_state: str = '(g)'#
_liquid_matter_state: str = '(l)'#
_solid_matter_state: str = '(s)'#
_condensed_matter_states: set[str]#
_matter_states#
_amorphous_structure: str = 'amorphous'#
_crystalline_structure: str = 'crystalline'#
_unclear_structure: str = 'structureUnclear'#
_solid_structures: set[str]#
_constant_delta_wavelength: str = 'DeltaWavelength'#
_constant_delta_wavenumber: str = 'DeltaWavenumber'#
_constant_resolving_power: str = 'R'#
_spectral_sampling_types: set[str]#
_wavelength_units: str = 'mu'#
_charge_separator: str = '_'#
_default_extension: str = 'unknown'#
_extension_opacity: str = 'petitRADTRANS.h5'#
_isotope_separator: str = '-'#
_colliding_species_separator: str = '--'#
_natural_abundance_string: str = 'NatAbund'#
_solid_structure_separator: str = '_'#
_spectral_information_separator: str = '.'#
_source_separator: str = '__'#
_wavelength_range_separator: str = '_'#
_wavelength_separator: str = '-'#
__sl: str = '\\'#
_amorphous_structure_id_pattern: re.Pattern#
_charge_pattern: re.Pattern#
_isotope_pattern: re.Pattern#
_space_group_pattern: re.Pattern#
_spectral_sampling_pattern: re.Pattern#
_wavelength_range_pattern: re.Pattern#
_name_pattern#
_default_cia_resolving_power: float = 831.0#
_default_cloud_resolving_power: float = 39.0#
_default_correlated_k_resolving_power: int = 1000#
_default_line_by_line_resolving_power: float = 1000000.0#
_default_resolving_power: int = 1000#
species_list: list[str]#
natural_abundance: bool = False#
charge: int = 0#
source: str = 'unknown'#
spectral_sampling_type: str = 'R'#
spectral_sampling: int | float = 0.0#
wavelength_min: float = 0.0#
wavelength_max: float = 0.0#
matter_state: str = '(g)'#
solid_structure: str = None#
solid_structure_id: str = None#
category: str = 'unknown_opacities'#
extension: str = 'unknown'#
path_input_data: str = None#
full_extension: str = None#
species_full_name: str = None#
species_cloud_info: str = None#
species_base_name: str = None#
species_isotopologue_name: str = None#
file_name: str = None#
sub_path: str = None#
absolute_path: str = None#
property has_colliding_species: bool#
static __modify_isotope_string(isotope: str, mode: str, isotope_pattern: str) list[str]#

Add, remove, or transform isotopic information.

classmethod __recursive_merge_contiguous_isotopes(isotope_groups: list[list[str | int]], i: int, index_merge: int | None = None) list[list[str | int]]#

Merge contiguous elements in list of isotope strings. Numbers of contiguous isotopes are converted to int, merged groups numbers are set to 0. Example:

>>> [["12C", "2"], ["1H", "2"], ["1H", "2"]]
>>> [["12C", 2], ["1H", 4], ["1H", 0]]
classmethod _before_write(temperature_grid_type: str, molar_mass: float, species_name: str | tuple[str, Ellipsis], date_id: str) tuple[float | numpy.typing.NDArray[numpy.floating], str]#

Perform operations always done to write an opacity file.

classmethod _init_species_name_elements(name: str, species: str, natural_abundance: str, charge: str) tuple[str, bool, int]#

Return the species istopologue name, natural abundance flag, and charge.

static _get_sub_path(category: str) str#

Get the subpath of the opacity file.

static _has_isotope(string: str) bool#

Return True if the string matches an isotopologue name pattern.

classmethod _join_spectral_information(spectral_sampling: str, wavelength_range: str) str#

Join the spectral sampling information with the wavelength range.

classmethod _match_function(path_input_data: str, sub_path: str, files: str | None = None, filename: str | None = None, expect_default_file_exists: bool = True, find_all: bool = False, display_other_files: bool = False) str | list[str]#

Return the file matching the given file name.

If no file name is given, behave as follows depending on the sub path directory content:

  • 1 file is present: return the found file name.

  • several files are present: return the default file set in the config file if it is present.

Args:
path_input_data: str

Absolute path to petitRadtrans “input_data” directory, where the opacity files are stored.

sub_path: str

Sub path to search the files in.

files: str, optional

Files to be matched with. By default, use te files in the sub path directory.

filename: str, optional

File name to be matched.

expect_default_file_exists: bool, optional

If True, raise an error if the default file is not found when looking for it. If False, return the default file even if it was not found. Default is True.

find_all: bool, optional

If True, return all the files matching with filename rather than only the first one. Default is False.

display_other_files: bool, optional

If True, print the available files if no matching file are found.

Returns:
file: str

The name of the matched file.

classmethod _merge_contiguous_isotopes(species: str, isotope_separator: str)#

Merge contiguous matches containing the same element, whether they are of the same isotope or not.

classmethod check_name(opacity_name: str)#

Check opacity name, based on the ExoMol format.

The name, in this order:
  • must begin with a number (up to 3 digits) or an uppercase letter

  • must contains a “valid” chemical formula (N1237He15 is considered valid)

  • can have isotopes, that should be separated with ‘-’ (e.g. H218O works, but corresponds to 1H218-16O)

  • can contains ‘-NatAbund’ to signal a mix of isotopes (incompatible with providing isotopic information)

  • can contains ‘+’, ‘-’, ‘p’ or ‘m’, (optionally starting with ‘_’ and a up to 3 digits number) to

    signal a ion

  • can contains ‘(l)’ for clouds of liquid particles

  • can contains ‘(s)’ for clouds of solid particles
    • must contains ‘crystalline’ or ‘amorphous’ for clouds with solid particles
      • ‘crystalline’ can be followed by a 3 digit number referring to the crystal space group number

      • ‘amorphous’ can be followed by up to 5 characters referring to the amorphous state name

  • can contains a source or method, starting with ‘__’

  • can contains spectral information, starting with ‘.’
    • spectral information must start with ‘R’, ‘DeltaWavenumber’ or ‘DeltaWavelength’, indicating

      respectively opacities evenly spectrally spaced in resolving power, wavenumber or wavelength

    • spectral spacing must end with a number (integers with or without an exponent format)

    • can contains the spectral range in micron in the format ‘_<float>-<float>mu’, following spectral

      spacing

Valid examples:
  • ‘H’ (simplest)

  • ‘H2O’

  • ‘2H2O’ (D2O)

  • ‘1H2-16O’

  • ‘1H-18O-2H+’

  • ‘H2O_m’

  • ‘H2O__HITEMP’

  • ‘H2O.R120’

  • ‘H2O(l)__Mie’

  • ‘H2O(s)_amorphous__Mie’

  • ‘H2O-NatAbund(s)_crystalline_194__DHS.R39_0.1-250mu’

  • ‘24Mg2-28Si-16O4(s)_crystalline_068__DHS.R39_0.1-250mu’ (most complex)

Args:

opacity_name:

Returns:

classmethod find(species: str, category: str = None, path_input_data: str = None, find_all: bool = False, search_online: bool = True) str#

Return the absolute filename of a species opacity. The validity of the given species name is checked.

Automatically infer the species base and isotopologue directories from the species name. Then, try to match the species name with the files in the folder. If only one file is matched, it is returned. If multiple files match, the configured default file is used if it exists. If not, ask the user to configure a default file.

Information given in the species name are decomposed for the match. For example:
  • “H2O.R120” will match e.g. the file “1H2-16O__HITEMP.R120_0.1-250mu.ktable.petitRADTRANS.h5”

  • “H2O__POKAZATEL” will match e.g. the file “1H2-16O__POKAZATEL.R1000_0.1-250mu.ktable.petitRADTRANS.h5”

If no information on the resolution is given, the default resolution for corr.-k or line-by-line is assumed. If no or partial isotopic information is given:

  • for line opacities: the main isotope is assumed

  • for continuum opacities: “NatAbund” (a standard mix of all isotopes) is assumed

Args:
path_input_data:

Path to the input data directory

category:

Input data category

species:

Species to get the opacity filename. The species name must be valid.

find_all:

If True, return all the matched files. If False, raise an error if no file is found, and only one file is returned.

search_online:

If True, search online for the opacity file

Returns:

The absolute opacity filename of the species

classmethod find_spectral_information(filename: str) tuple[str, str]#

Extract the spectral sampling and wavelength range information from a file name.

Args:
filename: str

The file name to extract information from.

Returns:
filename_sampling: str

The spectral sampling information contained in the file name. This consists in the spectral sampling type key followed by its value.

filename_range: str

The file wavelength range extracted from the file name. This is the min and max wavelengths of the opacity data, in microns.

classmethod from_species(species: str, spectral_sampling_type: str = 'R', spectral_sampling: int | float = 0.0, wavelength_min: float = 0.0, wavelength_max: float = 0.0, path_input_data: str = None) Opacity#

Instantiate an Opacity object from a species name and from spectral sampling information.

Args:
species: str

The species name, containing the species isotopic information, the natural abundance flag (if relevant), and the charge.

spectral_sampling_type: {‘DeltaWavelength’, ‘DeltaWavenumber’, ‘R’}, optional
The opacity spectral sampling type. Default is ‘R’.
  • ‘DeltaWavelength’: sampling with a constant wavelength step.

  • ‘DeltaWavenumber’: sampling with a constant wavenumber step.

  • ‘R’: sampling with a constant resolving power (wavelength / wavelength step).

spectral_sampling: int or float, optional
The opacity spectral sampling value. Default is 0. Units depends on spectral_sampling_type:
  • ‘DeltaWavelength’: um

  • ‘DeltaWavenumber’: cm-1

  • ‘R’: no units

wavelength_min: float, optional

(um) Lower wavelength bounds of the opacity data. Default is 0.

wavelength_max: float, optional

(um) Upper wavelength bounds of the opacity data. Default is 0.

path_input_data: str, optional

Absolute path to petitRADTRANS “input_data” directory, where the opacity files are stored. By default, use the path provided in petitRADTRANS config file.

Returns:
new_opacity: Opacity

A new instance of an Opacity object.

classmethod from_species_fullname(species_fullname: str, path_input_data: str = None, category: str = _default_category)#

Instantiate an Opacity object from a species full name and from spectral sampling information.

Args:
species_fullname: str

The species full name, containing the species isotopic information. May contain the natural abundance flag if relevant and the charge. Absolute path to petitRadtrans’ “input_data” directory, where the opacity files are stored. By default, use the path provided in petitRadtrans’ config file.

category: {‘cia_opacities’, ‘clouds_opacities’, ‘correlated_k_opacities’, ‘line_by_line_opacities’},

optional

The opacity category. Indicates the input_data subpath. Default is ‘unknown’.
  • ‘cia_opacities’: for collision-induced absorptions.

  • ‘clouds_opacities’: for cloud opacities.

  • ‘correlated_k_opacities’: for correlated-k opacities.

  • ‘line_by_line_opacities’: for line-by-line opacities.

path_input_data: str, optional

Absolute path to petitRADTRANS “input_data” directory, where the opacity files are stored. By default, use the path provided in petitRADTRANS config file.

Returns:
new_opacity: Opacity

A new instance of an Opacity object.

get_absolute_path() str#

Return the absolute path of this Opacity object.

get_base_name(join: bool = False) str#

Return the base name of this Opacity object.

The species base name is the species chemical formula without isotopic information. It may contain cloud information and charge.

Example:
>>> Opacity.from_species_fullname("24Mg2-28Si-16O4(s)_crystalline_000__DHS")
>>> Opacity.get_base_name()
>>> "Mg2SiO4"
Args:
join: bool # TODO remove in 4.0.0

Has no effect here.

Returns:
species_base_name: str

The species base name.

get_cloud_info() str#

Return the cloud information of this Opacity object.

Cloud information consists in the species matter state, and, if relevant, its solid internal structure and internal structure ID.

Example:
>>> Opacity.from_species_fullname("24Mg2-28Si-16O4(s)_crystalline_000__DHS")
>>> Opacity.get_cloud_info()
>>> "(s)_crystalline_000"
Returns:

The Opacity object cloud information.

get_charge_string(replace_symbol_with_char=True) str#

Return the charge of the Opacity object species in string format.

Example:
>>> Opacity.from_species_fullname("24Mg2-28Si-16O4_2+(s)_crystalline_000__DHS")
>>> Opacity.get_charge_string()
>>> "2p"
>>> Opacity.get_charge_string(replace_symbol_with_char=False)
>>> "2+"
Args:
replace_symbol_with_char: bool, optional # TODO replace with “replace_charge_symbol_with_char” in 4.0.0.

If True, replace the “+” or “-” of the charge string with “p” or “m”, respectively. Default is True.

Returns:
charge_string: str

The charge of the Opacity object species.

classmethod get_default_category() str#

Return the Opacity object default category. Used to obtain the Opacity file sub path.

classmethod get_default_extension() str#

Return the Opacity object file default extension.

classmethod get_default_resolving_power()#

Return the Opacity object species default resolving power.

get_directory() str#

Return the Opacity object file directory.

get_file_name() str#

Return the Opacity object file name.

classmethod get_file_name_elements(isotope_separator: str = None, isotope_pattern: str = None, natural_abundance_string: str = None, colliding_species_separator: str = None) tuple[str, str, str, str]#

Return the isotope separator, isotope pattern, natural abundance string, and colliding species separator of Opacity objects.

Args:
isotope_separator: str, optional

Override the default isotope separator (“-“).

isotope_pattern: str, optional

Override the default isotope regex pattern.

natural_abundance_string: str, optional

Override the default natural abundance string (“NatAbund”).

colliding_species_separator: str, optional

Override the default colliding species separator (”–“).

Returns:
isotope_separator: str

The isotope separator.

isotope_pattern: str

The isotope regex pattern.

natural_abundance_string: str

The natural abundance string.

colliding_species_separator: str

The colliding species separator.

get_full_extension() str#

Return this Opacity object file full extension, i.e. the opacity type and the generator software.

get_full_name() str#

Return this Opacity object species full name, containing the species isotopic information, the natural abundance flag (if relevant), and the charge.

Example:
>>> Opacity.from_species_fullname("24Mg2-28Si-16O4_2+(s)_crystalline_000__DHS")
>>> Opacity.get_full_name()
>>> "24Mg2-28Si-16O4_2p"
get_isotopologue_name(join: bool = False) str#

Return this Opacity object species isotopologye name, containing the species isotopic information, the natural abundance flag (if relevant), and the charge.

Args:
join: bool, optional # TODO remove in 4.0.0

If True, add the charge information to the isotopologue_name. Default is False.

Example:
>>> Opacity.from_species_fullname("24Mg2-28Si-16O4_2+(s)_crystalline_000__DHS")
>>> Opacity.get_isotopologue_name()
>>> "24Mg2-28Si-16O4"
>>> Opacity.get_isotopologue_name(join=False)
>>> "24Mg2-28Si-16O4_2p"
classmethod get_resolving_power_from_string(string: str) int#

Return resolving power information from a string following the petitRADTRANS Opacity format.

Args:
string: str

The string to extract resolving power information from.

Returns:
resolving_power: str

The resolving power information.

classmethod get_resolving_power_string(resolving_power: int | float | str) str#

Return resolving power in the petitRADTRANS Opacity format from a number.

Args:
resolving_power: int, float, or str

The resolving power to convert into string.

Returns:
resolving_power: str

The resolving power in petitRADTRANS Opacity format.

classmethod get_species_base_name(species_full_name: str, join: bool = False) str#

Return the base name of a species.

The species base name is the species chemical formula without isotopic information. It may contain cloud information and charge.

Example:
>>> Opacity.get_species_base_name("24Mg2-28Si-16O4(s)_crystalline_000__DHS")
>>> "Mg2SiO4"
Args:
species_full_name: str

The species full name, containing the species isotopic information. May contain the natural abundance flag if relevant and the charge.

join: bool, optional

If True, add the species charge, matter state, and solid structure information (if relevant) to the base name. Default is False.

Returns:
species_base_name: str

The species base name.

classmethod get_species_directory(species: str, category: str = None, path_input_data: str = None, base_name: str = None, isotopologue_name: str = None, sub_path: str = None) str#

Return the petitRADTRANS absolute path for the given species.

Args:
species: str

The species name. May contain the species isotopic information, the natural abundance flag if relevant and the charge.

category: {‘cia_opacities’, ‘clouds_opacities’, ‘correlated_k_opacities’, ‘line_by_line_opacities’},

optional

The opacity category. Indicates the input_data subpath. Default is ‘unknown’.
  • ‘cia_opacities’: for collision-induced absorptions.

  • ‘clouds_opacities’: for cloud opacities.

  • ‘correlated_k_opacities’: for correlated-k opacities.

  • ‘line_by_line_opacities’: for line-by-line opacities.

path_input_data: str, optional

Absolute path to petitRADTRANS “input_data” directory, where the opacity files are stored. By default, use the path provided in petitRADTRANS config file.

base_name: str, optional

Override the species base name. By default, it is extracted from the value of the “species” argument.

isotopologue_name: str, optional

Override the species isotopologue name. By default, it is extracted from the value of the “species” argument.

sub_path: str, optional

Override the species sub path. By default, it is extracted from the value of the “species” argument.

Returns:
species_directory: str

The absolute path of the Opacity object species.

classmethod get_species_isotopologue_name(species_name: str, join: bool = False) str#

Return the isotopologue name of a species.

The species isotopologue name is the species chemical formula with separated isotopes. It may contain cloud information and charge.

Example:
>>> Opacity.get_species_isotopologue_name("24Mg2-28Si-16O4(s)_crystalline_000__DHS")
>>> "24Mg2-28Si-16O4"
>>> Opacity.get_species_isotopologue_name("24Mg2-28Si-16O4(s)_crystalline_000__DHS", join=True)
>>> "24Mg2-28Si-16O4_2+(s)_crystalline_000"
Args:
species_name: str

The species name. May contain the species isotopic information, the natural abundance flag if relevant and the charge.

join: bool, optional

If True, add the species charge, matter state, and solid structure information (if relevant) to the base name. Default is False.

Returns:
species_base_name: str

The species base name.

classmethod get_species_scientific_name(species: str) str#

Return the name of a species in LaTeX format.

The species scientific name is the species chemical full formula with isotopes. It does not contain charges.

Example:
>>> Opacity.get_species_scientific_name("24Mg2-28Si-16O4(s)_crystalline_000__DHS")
>>> "24Mg2-28Si-16O4"
>>> Opacity.get_species_isotopologue_name("24Mg2-28Si-16O4(s)_crystalline_000__DHS", join=True)
>>> "24Mg2-28Si-16O4_2+(s)_crystalline_000"
Args:
species: str

The species name. May contain the species isotopic information, the natural abundance flag if relevant and the charge.

Returns:
species_base_name: str

The species base name.

get_spectral_info() str#

Return this Opacity object spectral information.

Spectral information contains the opacity spectral sampling type, its value, and the opacity wavelength range boundaries in microns.

Example:
>>> Opacity.from_species_fullname("24Mg2-28Si-16O4_2+(s)_crystalline_000__DHS.R39_0.1-250mu")
>>> Opacity.get_spectral_info()
>>> "R39_0.1-250"
classmethod join_species_all_info(species_name: str, natural_abundance: str = '', charge: str = '', cloud_info: str = '', source: str = '', spectral_info: str = '', spectral_sampling: str = None, wavelength_range: str = None) str#

Join together species information, using the petitRADTRANS Opacity separators.

The results may not be a valid petitRADTRANS Opacity name.

Args:
species_name: str

The species chemical formula.

natural_abundance: str, optional

The natural abundance flag. Empty by default.

charge: str, optional

The charge in string format. Empty by default.

cloud_info: str, optional

The matter state, solid structure and solid structure ID. Empty by default.

source: str, optional

The opacity source. Empty by default.

spectral_info: str, optional

The opacity sampling type, its value, and the opacity wavenumber boundaries in microns. Empty by default.

spectral_sampling: str, optional

The opacity sampling type and its value. Activated if “spectral_info” is empty.

wavelength_range: str, optional

The opacity wavenumber boundaries in microns. Activated if “spectral_info” is empty.

Returns:
species_name: str

The species name, using the petitRADTRANS Opacity separators.

load(file: str)#
classmethod modify_isotope_numbers(species: str, mode: str, isotope_separator: str = None, isotope_pattern: str = None, natural_abundance_string: str = None, colliding_species_separator: str = None) str#

Add or remove isotope numbers from a species. Note that using improper isotope separation can lead to incorrect results (e.g. H218O -> 1H218-16O).

Args:
species:

Species name. Can also be a species collision (e.g. H2–He).

mode:

Can be ‘add’, ‘remove’, or ‘scientific’. In ‘add’ mode, add the isotope number of each of the species will be added to the species name, and each isotope is separated with a ‘-’. By default, the main isotope number is used. If partial isotope information is provided (e.g. 13C2H2, H2-18O, 
), use the main isotope number on the isotopes for which no information is given (e.g. 13C2-1H2, 1H2-18O, 
). In ‘remove’ mode, remove all isotope numbers (e.g. 13C2-1H2 -> C2H2). In ‘scientific’ mode, convert the species into scientific notation using LaTeX formatting.

isotope_separator:

Isotope separator. If None, use the default value.

isotope_pattern:

Regex pattern string to detect isotopes in a species name. If None, use the default value.

natural_abundance_string:

Natural abundance string. If None, use the default value.

colliding_species_separator:

Colliding species separator. If None, use the default value.

Returns:

The species name with added or removed isotope information.

save(file: str)#
classmethod split_cloud_info(cloud_info: str) tuple[str, str, str]#

Split the matter state, solid structure and solid structure ID from a string in petitRADTRANS format.

Example:
>>> Opacity.split_cloud_info("(s)_crystalline_000")
>>>  ('(s)', 'crystalline', '000')
Args:
cloud_info: str

A string in petitRADTRANS format.

Returns:
matter_state: str

The matter state.

solid_structure: str

The solid structure.

solid_structure_id: str

The solid structure ID.

classmethod split_species_all_info(species: str, replace_charge_symbol_with_char: bool = False, full: bool = False) tuple[str, Ellipsis]#

Split a species name in the petitRADTRANS Opacity format into its components.

Examples:
>>> Opacity.split_species_all_info("24Mg2-28Si-16O4_2+(s)_crystalline_000__DHS.R39_0.1-250mu")
>>> ('24Mg2-28Si-16O4', '', '2+', '(s)_crystalline_000', 'DHS', 'R39_0.1-250mu')
>>> Opacity.split_species_all_info("H-NatAbund_2-__X.R100_0.1-250mu", replace_charge_symbol_with_char=True)
>>> ('H_2-', 'NatAbund', '2m', '', 'X', 'R100_0.1-250mu')
>>> Opacity.split_species_all_info("24Mg2-28Si-16O4_2+(s)_crystalline_000__DHS.R39_0.1-250mu", full=True)
>>> ('24Mg2-28Si-16O4', '', '2+', '(s)', 'crystalline', '000', 'DHS', 'R', '39', '0.1', '250')
Args:
species: str

The species name, in the petitRADTRANS Opacity format.

replace_charge_symbol_with_char: bool, optional

If True, replace the “+” or “-” of the charge string with “p” or “m”, respectively. Default is False.

full: bool, optional

If True, return the complete decomposition of the species name. Default is False.

Returns:
name: str

The species name.

natural_abundance: str

The natural abundance flag.

charge: str

The charge in string format.

cloud_info: str

If full is False only. The matter state, solid structure, and solid structure ID.

matter_state: str

If full is True only.

solid_structure: str

If full is True only.

solid_structure_id: str

If full is True only.

source: str

The source.

spectral_info: str

If full is False only. The spectral sampling type, its value, and the opacity wavelength boundaries.

spectral_sampling_type: str

If full is True only.

spectral_sampling_value: str

If full is True only.

wavelength_min: str

If full is True only.

wavelength_max: str

If full is True only.

classmethod split_species_charge(species: str, replace_symbol_with_char: bool = False) tuple[str, str]#

Separate the charge from a species name in the petitRADTRANS Opacity format.

Examples:
>>> Opacity.split_species_charge("24Mg2-28Si-16O4_2+")
>>> ('24Mg2-28Si-16O4', '2+')
>>> Opacity.split_species_charge("24Mg2-28Si-16O4_2+", replace_symbol_with_char=True)
>>> ('24Mg2-28Si-16O4', '2p')
Args:
species: str

The species name, containing only the spectral formula and the charge.

replace_symbol_with_char: # TODO replace with “replace_charge_symbol_with_char” in 4.0.0.

If True, replace the “+” or “-” of the charge string with “p” or “m”, respectively. Default is True.

Returns:
name: str

The species chemical formula.

charge: str

The species charge in string format.

static split_species_cloud_info(species: str) tuple[str, str]#

Separate the cloud information from a species name in the petitRADTRANS Opacity format.

Example:
>>> Opacity.split_species_cloud_info("24Mg2-28Si-16O4_2+(s)_crystalline_000")
>>> ('24Mg2-28Si-16O4_2+', '(s)_crystalline_000')
Args:
species: str

The species name, containing the cloud information.

Returns:
name: str

The species name, minus the cloud information.

cloud_info: str

The species cloud information.

classmethod split_species_source(species: str) tuple[str, str]#

Separate the species source from a species name in the petitRADTRANS Opacity format.

Example:
>>> Opacity.split_species_source("24Mg2-28Si-16O4_2+(s)_crystalline_000__DHS")
>>> ('24Mg2-28Si-16O4_2+(s)_crystalline_000', 'DHS')
Args:
species: str

The species name, containing the source.

Returns:
name: str

The species name, minus the source.

source: str

The species opacity source.

classmethod split_species_spectral_info(species: str) tuple[str, str]#

Separate the spectral information from a species name in the petitRADTRANS Opacity format.

Example:
>>> Opacity.split_species_spectral_info("24Mg2-28Si-16O4_2+(s)_crystalline_000__DHS.R39_0.1-250mu")
>>> ('24Mg2-28Si-16O4_2+(s)_crystalline_000__DHS', 'R39_0.1-250mu')
Args:
species: str

The species name, containing the spectral information.

Returns:
name: str

The species name, minus the spectral information.

cloud_info: str

The species spectral information.

classmethod split_spectral_sampling_info(spectral_sampling_info: str) tuple[str, str]#

Split spectral sampling information into its sampling type and its value.

Example:
>>> Opacity.split_spectral_sampling_info("R39")
>>> ('R', '39')
Args:
spectral_sampling_info: str

The spectral sampling information to split, containing the sampling type and its value.

Returns:
spectral_sampling_type: str

The spectral sampling type.

spectral_sampling_value: str

The spectral sampling value.

classmethod split_spectral_info(spectral_info: str) tuple[str, str]#

Split spectral information into the spectral sampling information and the opacity wavelength boundaries.

Example:
>>> Opacity.split_spectral_sampling_info("R39_0.1-250mu")
>>> ('R39', '0.1-250mu')
Args:
spectral_info: str

The spectral information to split, containing only the spectral sampling information and the opacity wavelength boundaries.

Returns:
spectral_sampling_info: str

The spectral type information.

wavelength_range_info: str

The opacity wavelength boundaries.

classmethod split_wavelength_range_info(wavelength_range_info: str) tuple[str, str]#

Split wavelenght range information into the opacity lower and upper boundaries.

Example:
>>> Opacity.split_spectral_sampling_info("0.1-250mu")
>>> ('0.1', '250')
Args:
wavelength_range_info: str

The wavelength range to split.

Returns:
wavelength_min: str

The lower opacity wavelength boundary.

wavelength_max: str

The upper opacity wavelength boundary.

static write(**kwargs)#
class petitRADTRANS.opacities.opacities.CIAOpacity(species_list, natural_abundance: bool = True, charge: int = 0, source: str = 'unknown', spectral_sampling_type: str = 'R', spectral_sampling: int | float = 830, wavelength_min: float = _default_wavelength_range[0], wavelength_max: float = _default_wavelength_range[1], path_input_data: str = None, species_full_name: str = None, species_base_name: str = None, species_isotopologue_name: str = None, full_extension: str = None, file_name: str = None, sub_path: str = None, absolute_path: str = None)#

Bases: Opacity

Class for collision-induced opacity files.

Args:
species_list: list of str

The list of species contributing to the opacity.

natural_abundance: bool, optional

If True, the species is considered following the Earth’s isotopic ratios. Default is True.

charge: int, optional

The charge of the species (for single-species opacities only). A value of 0 is used for neutral species. Default is 0.

source: str, optional

The source (i.e., where or how the opacity were obtained) of the opacity. Default is “unknown”.

spectral_sampling_type: {‘DeltaWavelength’, ‘DeltaWavenumber’, ‘R’}, optional
The opacity spectral sampling type. Default is ‘R’.
  • ‘DeltaWavelength’: sampling with a constant wavelength step.

  • ‘DeltaWavenumber’: sampling with a constant wavenumber step.

  • ‘R’: sampling with a constant resolving power (wavelength / wavelength step).

spectral_sampling: int or float, optional
The opacity spectral sampling value. Default is 830. Units depends on spectral_sampling_type:
  • ‘DeltaWavelength’: um

  • ‘DeltaWavenumber’: cm-1

  • ‘R’: no units

Example:

To indicate a spectral sampling with a constant resolving power of 1000. >>> spectral_sampling_type=’R’ >>> spectral_sampling=1000

wavelength_min: float, optional

(um) Lower wavelength bounds of the opacity data. Default is 0.1.

wavelength_max: float, optional

(um) Upper wavelength bounds of the opacity data. Default is 250.

path_input_data: str, optional

Absolute path to petitRadtrans “input_data” directory, where the opacity files are stored. By default, use the path provided in petitRadtrans config file.

species_full_name: str, optional

Override the species full name. The species full name is composed of the species isotopic information, the natural abundance flag (if relevant), and the charge.

species_cloud_info: str, optional

Override the species cloud information. The species cloud information is composed of the species matter state, and of its solid structure and structure id (if relevant).

species_base_name: str, optional

Override the species base name. The species base name is the species chemical formula without isotopic information. It may contain cloud information and charge. Examples: “H2O”, “H2O(l)”, “H2O_+(s)_crystalline_000”.

species_isotopologue_name: str, optional

Override the species isotopologue name. The species isotopologue name is the species name with isotopic information. It may contain cloud information and charge. Examples: “1H2-16O”, “H2O-NatAbund(l)”, “1H2-18O_+(s)_crystalline_000”.

extension: str, optional

The opacity file type extension. Default is “unknown”. Use “petitRADTRANS” for files generated with petitRADTRANS.

full_extension: str, optional

Override the opacity file full extension. The opacity file full extension is composed of the opacity file type extension, the opacity file generator software extension, and of the file format extension.

file_name: str, optional

Override the opacity file name. By default, it is generated from the instanciation arguments.

sub_path: str, optional

Override the opacity sub path. By default, it depends on the selected category.

directory: str, optional

Override the opacity directory. By default, it is generated from the species full name and from the other path information.

absolute_path: str, optional

Override the absolute path of the opacity file. By default, it is genrated from the other path information.

_default_category: str = 'cia_opacities'#
_default_extension: str = 'ciatable'#
_default_wavelength_range: tuple[float, float] = (0.1, 250.0)#
_default_resolving_power: float = 831.0#
classmethod find(species: str, category: str = None, path_input_data: str = None, find_all: bool = False, search_online: bool = True) str#

Return the absolute filename of a species opacity. The validity of the given species name is checked.

Automatically infer the species base and isotopologue directories from the species name. Then, try to match the species name with the files in the folder. If only one file is matched, it is returned. If multiple files match, the configured default file is used if it exists. If not, ask the user to configure a default file.

Information given in the species name are decomposed for the match. For example:
  • “H2O.R120” will match e.g. the file “1H2-16O__HITEMP.R120_0.1-250mu.ktable.petitRADTRANS.h5”

  • “H2O__POKAZATEL” will match e.g. the file “1H2-16O__POKAZATEL.R1000_0.1-250mu.ktable.petitRADTRANS.h5”

If no information on the resolution is given, the default resolution for corr.-k or line-by-line is assumed. If no or partial isotopic information is given:

  • for line opacities: the main isotope is assumed

  • for continuum opacities: “NatAbund” (a standard mix of all isotopes) is assumed

Args:
path_input_data:

Path to the input data directory

category:

Input data category

species:

Species to get the opacity filename. The species name must be valid.

find_all:

If True, return all the matched files. If False, raise an error if no file is found, and only one file is returned.

search_online:

If True, search online for the opacity file

Returns:

The absolute opacity filename of the species

classmethod from_species(species: str, spectral_sampling_type: str = 'R', spectral_sampling: int | float = Opacity._default_line_by_line_resolving_power, wavelength_min: float = _default_wavelength_range[0], wavelength_max: float = _default_wavelength_range[1], path_input_data: str = None, category: str = _default_category)#

Instantiate an Opacity object from a species name and from spectral sampling information.

Args:
species: str

The species name, containing the species isotopic information, the natural abundance flag (if relevant), and the charge.

spectral_sampling_type: {‘DeltaWavelength’, ‘DeltaWavenumber’, ‘R’}, optional
The opacity spectral sampling type. Default is ‘R’.
  • ‘DeltaWavelength’: sampling with a constant wavelength step.

  • ‘DeltaWavenumber’: sampling with a constant wavenumber step.

  • ‘R’: sampling with a constant resolving power (wavelength / wavelength step).

spectral_sampling: int or float, optional
The opacity spectral sampling value. Default is 0. Units depends on spectral_sampling_type:
  • ‘DeltaWavelength’: um

  • ‘DeltaWavenumber’: cm-1

  • ‘R’: no units

wavelength_min: float, optional

(um) Lower wavelength bounds of the opacity data. Default is 0.

wavelength_max: float, optional

(um) Upper wavelength bounds of the opacity data. Default is 0.

path_input_data: str, optional

Absolute path to petitRADTRANS “input_data” directory, where the opacity files are stored. By default, use the path provided in petitRADTRANS config file.

Returns:
new_opacity: Opacity

A new instance of an Opacity object.

classmethod from_species_fullname(species_fullname: str, path_input_data: str = None, category: str = _default_category)#

Instantiate an Opacity object from a species full name and from spectral sampling information.

Args:
species_fullname: str

The species full name, containing the species isotopic information. May contain the natural abundance flag if relevant and the charge. Absolute path to petitRadtrans’ “input_data” directory, where the opacity files are stored. By default, use the path provided in petitRadtrans’ config file.

category: {‘cia_opacities’, ‘clouds_opacities’, ‘correlated_k_opacities’, ‘line_by_line_opacities’},

optional

The opacity category. Indicates the input_data subpath. Default is ‘unknown’.
  • ‘cia_opacities’: for collision-induced absorptions.

  • ‘clouds_opacities’: for cloud opacities.

  • ‘correlated_k_opacities’: for correlated-k opacities.

  • ‘line_by_line_opacities’: for line-by-line opacities.

path_input_data: str, optional

Absolute path to petitRADTRANS “input_data” directory, where the opacity files are stored. By default, use the path provided in petitRADTRANS config file.

Returns:
new_opacity: Opacity

A new instance of an Opacity object.

classmethod write(file: str, colliding_species: tuple[str, Ellipsis], alphas: numpy.typing.NDArray[numpy.floating], wavenumbers: numpy.typing.NDArray[numpy.floating], pressures: numpy.typing.NDArray[numpy.floating], temperatures: numpy.typing.NDArray[numpy.floating], molar_mass: float = None, doi: str = '', contributor: str = '', description: str = '', date_id: str = None, n_g: int = None, wavelength_range: tuple[float] = None)#
class petitRADTRANS.opacities.opacities.CloudOpacity(species_list, natural_abundance: bool = True, charge: int = 0, source: str = 'unknown', spectral_sampling_type: str = 'R', spectral_sampling: int | float = Opacity._default_cloud_resolving_power, wavelength_min: float = _default_wavelength_range[0], wavelength_max: float = _default_wavelength_range[1], matter_state: str = Opacity._solid_matter_state, solid_structure: str = 'crystalline', solid_structure_id: str = '000', path_input_data: str = None, species_full_name: str = None, species_cloud_info: str = None, species_base_name: str = None, species_isotopologue_name: str = None, full_extension: str = None, file_name: str = None, sub_path: str = None, absolute_path: str = None)#

Bases: Opacity

Class for cloud opacity files.

Args:
species_list: list of str

The list of species contributing to the opacity. For single-species opacities, use [species_name]. Examples: [1H2-17O], [N2, CO2]

natural_abundance: bool, optional

If True, the species is considered following the Earth’s isotopic ratios. Default is True.

charge: int, optional

The charge of the species (for single-species opacities only). A value of 0 is used for neutral species. Default is 0.

source: str, optional

The source (i.e., where or how the opacity were obtained) of the opacity. Default is “unknown”.

spectral_sampling_type: {‘DeltaWavelength’, ‘DeltaWavenumber’, ‘R’}, optional
The opacity spectral sampling type. Default is ‘R’.
  • ‘DeltaWavelength’: sampling with a constant wavelength step.

  • ‘DeltaWavenumber’: sampling with a constant wavenumber step.

  • ‘R’: sampling with a constant resolving power (wavelength / wavelength step).

spectral_sampling: int or float, optional
The opacity spectral sampling value. Default is 39. Units depends on spectral_sampling_type:
  • ‘DeltaWavelength’: um

  • ‘DeltaWavenumber’: cm-1

  • ‘R’: no units

Example:

To indicate a spectral sampling with a constant resolving power of 1000. >>> spectral_sampling_type=’R’ >>> spectral_sampling=1000

wavelength_min: float, optional

(um) Lower wavelength bounds of the opacity data. Default is 0.

wavelength_max: float, optional

(um) Upper wavelength bounds of the opacity data. Default is 0.

matter_state: {‘(g)’, ‘(l)’, ‘(s)’}, optional
The species matter state. Default is ‘(g)’.
  • ‘(g)’: gas phase.

  • ‘(l)’: liquid phase.

  • ‘(s)’: solid phase.

solid_structure: {‘amorphous’, ‘crystalline’, ‘structureUnclear’}, optional
If the species is in solid phase, indicate the solid structure of the species. Default is None.
  • ‘amorphous’: the solid has an amorphous internal structure.

  • ‘crystalline’: the solid is in a crystal form.

  • ‘structureUnclear’: internal structure was not provided by the source.

solid_structure_id: str, optional

Solid structure identifier. For crystals, this corresponds to the 3-digits space group. See https://en.wikipedia.org/wiki/List_of_space_groups An unknown space group is indicated as ‘000’.

path_input_data: str, optional

Absolute path to petitRadtrans’ “input_data” directory, where the opacity files are stored. By default, use the path provided in petitRadtrans config file.

species_full_name: str, optional

Override the species full name. The species full name is composed of the species isotopic information, the natural abundance flag (if relevant), and the charge.

species_cloud_info: str, optional

Override the species cloud information. The species cloud information is composed of the species matter state, and of its solid structure and structure id (if relevant).

species_base_name: str, optional

Override the species base name. The species base name is the species chemical formula without isotopic information. It may contain cloud information and charge. Examples: “H2O”, “H2O(l)”, “H2O_+(s)_crystalline_000”.

species_isotopologue_name: str, optional

Override the species isotopologue name. The species isotopologue name is the species name with isotopic information. It may contain cloud information and charge. Examples: “1H2-16O”, “H2O-NatAbund(l)”, “1H2-18O_+(s)_crystalline_000”.

extension: str, optional

The opacity file type extension. Default is “unknown”. Use “petitRADTRANS” for files generated with petitRADTRANS.

full_extension: str, optional

Override the opacity file full extension. The opacity file full extension is composed of the opacity file type extension, the opacity file generator software extension, and of the file format extension.

file_name: str, optional

Override the opacity file name. By default, it is generated from the instanciation arguments.

sub_path: str, optional

Override the opacity sub path. By default, it depends on the selected category.

directory: str, optional

Override the opacity directory. By default, it is generated from the species full name and from the other path information.

absolute_path: str, optional

Override the absolute path of the opacity file. By default, it is genrated from the other path information.

_default_category: str = 'clouds_opacities'#
_default_extension: str = 'cotable'#
_default_resolving_power: float = 39.0#
_default_wavelength_range: tuple[float, float] = (0.1, 250.0)#
_default_file_names: petitRADTRANS.utils.LockedDict#
classmethod find(species: str, category: str = None, path_input_data: str = None, find_all: bool = False, search_online: bool = True) str#

Return the absolute filename of a species opacity. The validity of the given species name is checked.

Automatically infer the species base and isotopologue directories from the species name. Then, try to match the species name with the files in the folder. If only one file is matched, it is returned. If multiple files match, the configured default file is used if it exists. If not, ask the user to configure a default file.

Information given in the species name are decomposed for the match. For example:
  • “H2O.R120” will match e.g. the file “1H2-16O__HITEMP.R120_0.1-250mu.ktable.petitRADTRANS.h5”

  • “H2O__POKAZATEL” will match e.g. the file “1H2-16O__POKAZATEL.R1000_0.1-250mu.ktable.petitRADTRANS.h5”

If no information on the resolution is given, the default resolution for corr.-k or line-by-line is assumed. If no or partial isotopic information is given:

  • for line opacities: the main isotope is assumed

  • for continuum opacities: “NatAbund” (a standard mix of all isotopes) is assumed

Args:
path_input_data:

Path to the input data directory

category:

Input data category

species:

Species to get the opacity filename. The species name must be valid.

find_all:

If True, return all the matched files. If False, raise an error if no file is found, and only one file is returned.

search_online:

If True, search online for the opacity file

Returns:

The absolute opacity filename of the species

classmethod from_species(species: str, spectral_sampling_type: str = 'R', spectral_sampling: int | float = Opacity._default_cloud_resolving_power, wavelength_min: float = _default_wavelength_range[0], wavelength_max: float = _default_wavelength_range[1], path_input_data: str = None, category: str = _default_category)#

Instantiate an Opacity object from a species name and from spectral sampling information.

Args:
species: str

The species name, containing the species isotopic information, the natural abundance flag (if relevant), and the charge.

spectral_sampling_type: {‘DeltaWavelength’, ‘DeltaWavenumber’, ‘R’}, optional
The opacity spectral sampling type. Default is ‘R’.
  • ‘DeltaWavelength’: sampling with a constant wavelength step.

  • ‘DeltaWavenumber’: sampling with a constant wavenumber step.

  • ‘R’: sampling with a constant resolving power (wavelength / wavelength step).

spectral_sampling: int or float, optional
The opacity spectral sampling value. Default is 0. Units depends on spectral_sampling_type:
  • ‘DeltaWavelength’: um

  • ‘DeltaWavenumber’: cm-1

  • ‘R’: no units

wavelength_min: float, optional

(um) Lower wavelength bounds of the opacity data. Default is 0.

wavelength_max: float, optional

(um) Upper wavelength bounds of the opacity data. Default is 0.

path_input_data: str, optional

Absolute path to petitRADTRANS “input_data” directory, where the opacity files are stored. By default, use the path provided in petitRADTRANS config file.

Returns:
new_opacity: Opacity

A new instance of an Opacity object.

classmethod from_species_fullname(species_fullname: str, path_input_data: str = None, category: str = _default_category)#

Instantiate an Opacity object from a species full name and from spectral sampling information.

Args:
species_fullname: str

The species full name, containing the species isotopic information. May contain the natural abundance flag if relevant and the charge. Absolute path to petitRadtrans’ “input_data” directory, where the opacity files are stored. By default, use the path provided in petitRadtrans’ config file.

category: {‘cia_opacities’, ‘clouds_opacities’, ‘correlated_k_opacities’, ‘line_by_line_opacities’},

optional

The opacity category. Indicates the input_data subpath. Default is ‘unknown’.
  • ‘cia_opacities’: for collision-induced absorptions.

  • ‘clouds_opacities’: for cloud opacities.

  • ‘correlated_k_opacities’: for correlated-k opacities.

  • ‘line_by_line_opacities’: for line-by-line opacities.

path_input_data: str, optional

Absolute path to petitRADTRANS “input_data” directory, where the opacity files are stored. By default, use the path provided in petitRADTRANS config file.

Returns:
new_opacity: Opacity

A new instance of an Opacity object.

classmethod get_aliases(name: str) str#
classmethod write(file: str, species_name: str, absorption_opacities: numpy.typing.NDArray[numpy.floating], scattering_opacities: numpy.typing.NDArray[numpy.floating], asymmetry_parameters: numpy.typing.NDArray[numpy.floating], particles_densities: numpy.typing.NDArray[numpy.floating], particles_radius_bin_centers: numpy.typing.NDArray[numpy.floating], particles_radius_bin_edges: numpy.typing.NDArray[numpy.floating], wavenumbers: numpy.typing.NDArray[numpy.floating], doi: str = '', contributor: str = '', description: str = '', date_id: str = None, wavelength_range: tuple[float] = None)#
class petitRADTRANS.opacities.opacities.CorrelatedKOpacity(species_list, natural_abundance: bool = False, charge: int = 0, source: str = 'unknown', spectral_sampling_type: str = 'R', spectral_sampling: int | float = Opacity._default_correlated_k_resolving_power, wavelength_min: float = _default_wavelength_range[0], wavelength_max: float = _default_wavelength_range[1], path_input_data: str = None, species_full_name: str = None, species_base_name: str = None, species_isotopologue_name: str = None, full_extension: str = None, file_name: str = None, sub_path: str = None, absolute_path: str = None)#

Bases: Opacity

Class for correlated-k opacity files.

Args:
species_list: list of str

The list of species contributing to the opacity. For single-species opacities, use [species_name]. Examples: [1H2-17O], [N2, CO2]

natural_abundance: bool, optional

If True, the species is considered following the Earth’s isotopic ratios. Default is False.

charge: int, optional

The charge of the species (for single-species opacities only). A value of 0 is used for neutral species. Default is 0.

source: str, optional

The source (i.e., where or how the opacity were obtained) of the opacity. Default is “unknown”.

spectral_sampling_type: {‘DeltaWavelength’, ‘DeltaWavenumber’, ‘R’}, optional
The opacity spectral sampling type. Default is ‘R’.
  • ‘DeltaWavelength’: sampling with a constant wavelength step.

  • ‘DeltaWavenumber’: sampling with a constant wavenumber step.

  • ‘R’: sampling with a constant resolving power (wavelength / wavelength step).

spectral_sampling: int or float, optional
The opacity spectral sampling value. Default is 1000. Units depends on spectral_sampling_type:
  • ‘DeltaWavelength’: um

  • ‘DeltaWavenumber’: cm-1

  • ‘R’: no units

Example:

To indicate a spectral sampling with a constant resolving power of 1000. >>> spectral_sampling_type=’R’ >>> spectral_sampling=1000

wavelength_min: float, optional

(um) Lower wavelength bounds of the opacity data. Default is 0.1.

wavelength_max: float, optional

(um) Upper wavelength bounds of the opacity data. Default is 250.

species_full_name: str, optional

Override the species full name. The species full name is composed of the species isotopic information, the natural abundance flag (if relevant), and the charge.

species_cloud_info: str, optional

Override the species cloud information. The species cloud information is composed of the species matter state, and of its solid structure and structure id (if relevant).

species_base_name: str, optional

Override the species base name. The species base name is the species chemical formula without isotopic information. It may contain cloud information and charge. Examples: “H2O”, “H2O(l)”, “H2O_+(s)_crystalline_000”.

species_isotopologue_name: str, optional

Override the species isotopologue name. The species isotopologue name is the species name with isotopic information. It may contain cloud information and charge. Examples: “1H2-16O”, “H2O-NatAbund(l)”, “1H2-18O_+(s)_crystalline_000”.

extension: str, optional

The opacity file type extension. Default is “unknown”. Use “petitRADTRANS” for files generated with petitRADTRANS.

full_extension: str, optional

Override the opacity file full extension. The opacity file full extension is composed of the opacity file type extension, the opacity file generator software extension, and of the file format extension.

file_name: str, optional

Override the opacity file name. By default, it is generated from the instanciation arguments.

sub_path: str, optional

Override the opacity sub path. By default, it depends on the selected category.

directory: str, optional

Override the opacity directory. By default, it is generated from the species full name and from the other path information.

absolute_path: str, optional

Override the absolute path of the opacity file. By default, it is genrated from the other path information.

_default_category: str = 'correlated_k_opacities'#
_default_extension: str = 'ktable'#
_default_rebinning_wavelength_range: tuple[float, float] = (0.1, 251.0)#
_default_resolving_power: int = 1000#
_default_wavelength_range: tuple[float, float] = (0.1, 250.0)#
classmethod _get_default_rebinning_wavenumber_grid(resolving_power: float) numpy.typing.NDArray[numpy.floating]#

Return the default rebinning wavenumber grid, an equally log-spaced grid from 0.1 to 250 microns.

Args:
resolving_power: float

The resolving power of the grid.

Returns:
grid: numpy.NDArray

The default grid at the given resolving power.

classmethod exo_k_multiple_rebin_from_species(species: list[str], resolving_power: float, rewrite: bool = False)#

This function uses exo-k to bin the c-k table of a multiple species to a desired (lower) spectral resolution.

Args:
speciesstring

The name of the species

resolving_powerint

The desired spectral resolving power.

rewritebool

If True, rewrite the rebinned files even if they already exist.

classmethod exo_k_multiple_rebin(input_files: list[str], resolving_power: float, rewrite=False)#
classmethod exo_k_rebin(input_file: str, resolving_power: float, wavenumber_grid: numpy.typing.NDArray[numpy.floating] = None, rewrite: bool = False) int#
classmethod from_species(species: str, spectral_sampling_type: str = 'R', spectral_sampling: int | float = Opacity._default_correlated_k_resolving_power, wavelength_min: float = _default_wavelength_range[0], wavelength_max: float = _default_wavelength_range[1], path_input_data: str = None, category: str = _default_category)#

Instantiate an Opacity object from a species name and from spectral sampling information.

Args:
species: str

The species name, containing the species isotopic information, the natural abundance flag (if relevant), and the charge.

spectral_sampling_type: {‘DeltaWavelength’, ‘DeltaWavenumber’, ‘R’}, optional
The opacity spectral sampling type. Default is ‘R’.
  • ‘DeltaWavelength’: sampling with a constant wavelength step.

  • ‘DeltaWavenumber’: sampling with a constant wavenumber step.

  • ‘R’: sampling with a constant resolving power (wavelength / wavelength step).

spectral_sampling: int or float, optional
The opacity spectral sampling value. Default is 0. Units depends on spectral_sampling_type:
  • ‘DeltaWavelength’: um

  • ‘DeltaWavenumber’: cm-1

  • ‘R’: no units

wavelength_min: float, optional

(um) Lower wavelength bounds of the opacity data. Default is 0.

wavelength_max: float, optional

(um) Upper wavelength bounds of the opacity data. Default is 0.

path_input_data: str, optional

Absolute path to petitRADTRANS “input_data” directory, where the opacity files are stored. By default, use the path provided in petitRADTRANS config file.

Returns:
new_opacity: Opacity

A new instance of an Opacity object.

classmethod from_species_fullname(species_fullname: str, path_input_data: str = None, category: str = _default_category)#

Instantiate an Opacity object from a species full name and from spectral sampling information.

Args:
species_fullname: str

The species full name, containing the species isotopic information. May contain the natural abundance flag if relevant and the charge. Absolute path to petitRadtrans’ “input_data” directory, where the opacity files are stored. By default, use the path provided in petitRadtrans’ config file.

category: {‘cia_opacities’, ‘clouds_opacities’, ‘correlated_k_opacities’, ‘line_by_line_opacities’},

optional

The opacity category. Indicates the input_data subpath. Default is ‘unknown’.
  • ‘cia_opacities’: for collision-induced absorptions.

  • ‘clouds_opacities’: for cloud opacities.

  • ‘correlated_k_opacities’: for correlated-k opacities.

  • ‘line_by_line_opacities’: for line-by-line opacities.

path_input_data: str, optional

Absolute path to petitRADTRANS “input_data” directory, where the opacity files are stored. By default, use the path provided in petitRADTRANS config file.

Returns:
new_opacity: Opacity

A new instance of an Opacity object.

classmethod get_default_resolving_power() int#

Return the Opacity object species default resolving power.

classmethod write(file: str, species_name: str, k_coefficients: numpy.typing.NDArray[numpy.floating], wavenumber_bin_centers: numpy.typing.NDArray[numpy.floating], wavenumber_bin_edges: numpy.typing.NDArray[numpy.floating], pressures: numpy.typing.NDArray[numpy.floating], temperatures: numpy.typing.NDArray[numpy.floating], temperature_grid_type: str, g_weights: numpy.typing.NDArray[numpy.floating], g_samples: numpy.typing.NDArray[numpy.floating], molar_mass: float = None, doi: str = '', contributor: str = '', description: str = '', date_id: str = None, wavelength_range: tuple[float] = None)#
class petitRADTRANS.opacities.opacities.LineByLineOpacity(species_list, natural_abundance: bool = False, charge: int = 0, source: str = 'unknown', spectral_sampling_type: str = 'R', spectral_sampling: int | float = Opacity._default_line_by_line_resolving_power, wavelength_min: float = _default_wavelength_range[0], wavelength_max: float = _default_wavelength_range[1], path_input_data: str = None, species_full_name: str = None, species_base_name: str = None, species_isotopologue_name: str = None, full_extension: str = None, file_name: str = None, sub_path: str = None, absolute_path: str = None)#

Bases: Opacity

Class for line-by-line opacity files.

Args:
species_list: list of str

The list of species contributing to the opacity. For single-species opacities, use [species_name]. Examples: [1H2-17O], [N2, CO2]

natural_abundance: bool, optional

If True, the species is considered following the Earth’s isotopic ratios. Default is False.

charge: int, optional

The charge of the species (for single-species opacities only). A value of 0 is used for neutral species. Default is 0.

source: str, optional

The source (i.e., where or how the opacity were obtained) of the opacity. Default is “unknown”.

spectral_sampling_type: {‘DeltaWavelength’, ‘DeltaWavenumber’, ‘R’}, optional
The opacity spectral sampling type. Default is ‘R’.
  • ‘DeltaWavelength’: sampling with a constant wavelength step.

  • ‘DeltaWavenumber’: sampling with a constant wavenumber step.

  • ‘R’: sampling with a constant resolving power (wavelength / wavelength step).

spectral_sampling: int or float, optional
The opacity spectral sampling value. Default is 1e6. Units depends on spectral_sampling_type:
  • ‘DeltaWavelength’: um

  • ‘DeltaWavenumber’: cm-1

  • ‘R’: no units

Example:

To indicate a spectral sampling with a constant resolving power of 1000. >>> spectral_sampling_type=’R’ >>> spectral_sampling=1000

wavelength_min: float, optional

(um) Lower wavelength bounds of the opacity data. Default is 0.1.

wavelength_max: float, optional

(um) Upper wavelength bounds of the opacity data. Default is 250.

species_full_name: str, optional

Override the species full name. The species full name is composed of the species isotopic information, the natural abundance flag (if relevant), and the charge.

species_cloud_info: str, optional

Override the species cloud information. The species cloud information is composed of the species matter state, and of its solid structure and structure id (if relevant).

species_base_name: str, optional

Override the species base name. The species base name is the species chemical formula without isotopic information. It may contain cloud information and charge. Examples: “H2O”, “H2O(l)”, “H2O_+(s)_crystalline_000”.

species_isotopologue_name: str, optional

Override the species isotopologue name. The species isotopologue name is the species name with isotopic information. It may contain cloud information and charge. Examples: “1H2-16O”, “H2O-NatAbund(l)”, “1H2-18O_+(s)_crystalline_000”.

extension: str, optional

The opacity file type extension. Default is “unknown”. Use “petitRADTRANS” for files generated with petitRADTRANS.

full_extension: str, optional

Override the opacity file full extension. The opacity file full extension is composed of the opacity file type extension, the opacity file generator software extension, and of the file format extension.

file_name: str, optional

Override the opacity file name. By default, it is generated from the instanciation arguments.

sub_path: str, optional

Override the opacity sub path. By default, it depends on the selected category.

directory: str, optional

Override the opacity directory. By default, it is generated from the species full name and from the other path information.

absolute_path: str, optional

Override the absolute path of the opacity file. By default, it is genrated from the other path information.

_default_category: str = 'line_by_line_opacities'#
_default_extension: str = 'xsec'#
_default_resolving_power: float = 1000000.0#
_default_wavelength_range: tuple[float, float] = (0.3, 28)#
classmethod from_species(species: str, spectral_sampling_type: str = 'R', spectral_sampling: int | float = Opacity._default_line_by_line_resolving_power, wavelength_min: float = _default_wavelength_range[0], wavelength_max: float = _default_wavelength_range[1], path_input_data: str = None, category: str = _default_category)#

Instantiate an Opacity object from a species name and from spectral sampling information.

Args:
species: str

The species name, containing the species isotopic information, the natural abundance flag (if relevant), and the charge.

spectral_sampling_type: {‘DeltaWavelength’, ‘DeltaWavenumber’, ‘R’}, optional
The opacity spectral sampling type. Default is ‘R’.
  • ‘DeltaWavelength’: sampling with a constant wavelength step.

  • ‘DeltaWavenumber’: sampling with a constant wavenumber step.

  • ‘R’: sampling with a constant resolving power (wavelength / wavelength step).

spectral_sampling: int or float, optional
The opacity spectral sampling value. Default is 0. Units depends on spectral_sampling_type:
  • ‘DeltaWavelength’: um

  • ‘DeltaWavenumber’: cm-1

  • ‘R’: no units

wavelength_min: float, optional

(um) Lower wavelength bounds of the opacity data. Default is 0.

wavelength_max: float, optional

(um) Upper wavelength bounds of the opacity data. Default is 0.

path_input_data: str, optional

Absolute path to petitRADTRANS “input_data” directory, where the opacity files are stored. By default, use the path provided in petitRADTRANS config file.

Returns:
new_opacity: Opacity

A new instance of an Opacity object.

classmethod from_species_fullname(species_fullname: str, path_input_data: str = None, category: str = _default_category)#

Instantiate an Opacity object from a species full name and from spectral sampling information.

Args:
species_fullname: str

The species full name, containing the species isotopic information. May contain the natural abundance flag if relevant and the charge. Absolute path to petitRadtrans’ “input_data” directory, where the opacity files are stored. By default, use the path provided in petitRadtrans’ config file.

category: {‘cia_opacities’, ‘clouds_opacities’, ‘correlated_k_opacities’, ‘line_by_line_opacities’},

optional

The opacity category. Indicates the input_data subpath. Default is ‘unknown’.
  • ‘cia_opacities’: for collision-induced absorptions.

  • ‘clouds_opacities’: for cloud opacities.

  • ‘correlated_k_opacities’: for correlated-k opacities.

  • ‘line_by_line_opacities’: for line-by-line opacities.

path_input_data: str, optional

Absolute path to petitRADTRANS “input_data” directory, where the opacity files are stored. By default, use the path provided in petitRADTRANS config file.

Returns:
new_opacity: Opacity

A new instance of an Opacity object.

classmethod write(file: str, species_name: str, cross_sections: numpy.typing.NDArray[numpy.floating], wavenumber_bin_edges: numpy.typing.NDArray[numpy.floating], pressures: numpy.typing.NDArray[numpy.floating], temperatures: numpy.typing.NDArray[numpy.floating], temperature_grid_type: str, molar_mass: float = None, doi: str = '', contributor: str = '', description: str = '', date_id: str = None, n_g: int = None, wavelength_range: tuple[float] = None)#