petitRADTRANS._input_data_loader
================================

.. py:module:: petitRADTRANS._input_data_loader


Functions
---------

.. autoapisummary::

   petitRADTRANS._input_data_loader.__build_cia_aliases_dict
   petitRADTRANS._input_data_loader.__default_file_selection
   petitRADTRANS._input_data_loader.__get_from_tuple
   petitRADTRANS._input_data_loader.__get_condensed_matter_state
   petitRADTRANS._input_data_loader.__get_natural_abundance_string
   petitRADTRANS._input_data_loader.__get_spectral_sampling_type
   petitRADTRANS._input_data_loader.__get_solid_structure
   petitRADTRANS._input_data_loader.__recursive_merge_contiguous_isotopes
   petitRADTRANS._input_data_loader._get_base_cia_names
   petitRADTRANS._input_data_loader._get_base_cloud_names
   petitRADTRANS._input_data_loader._get_base_correlated_k_names
   petitRADTRANS._input_data_loader._get_base_line_by_line_names
   petitRADTRANS._input_data_loader._get_input_file
   petitRADTRANS._input_data_loader._get_input_file_from_keeper
   petitRADTRANS._input_data_loader._get_spectral_information
   petitRADTRANS._input_data_loader._has_isotope
   petitRADTRANS._input_data_loader._join_spectral_information
   petitRADTRANS._input_data_loader._merge_contiguous_isotopes
   petitRADTRANS._input_data_loader._rebuild_isotope_numbers
   petitRADTRANS._input_data_loader._split_cloud_info
   petitRADTRANS._input_data_loader._split_species_cloud_info
   petitRADTRANS._input_data_loader._split_species_charge
   petitRADTRANS._input_data_loader._split_species_source
   petitRADTRANS._input_data_loader._split_species_spectral_info
   petitRADTRANS._input_data_loader.check_opacity_name
   petitRADTRANS._input_data_loader.get_cia_aliases
   petitRADTRANS._input_data_loader.get_cia_opacity_file_extension
   petitRADTRANS._input_data_loader.get_cloud_aliases
   petitRADTRANS._input_data_loader.get_cloud_opacity_file_extension
   petitRADTRANS._input_data_loader.get_correlated_k_opacity_file_extension
   petitRADTRANS._input_data_loader.get_default_cloud_resolution
   petitRADTRANS._input_data_loader.get_default_correlated_k_resolution
   petitRADTRANS._input_data_loader.get_default_line_by_line_resolution
   petitRADTRANS._input_data_loader.get_input_data_file_not_found_error_message
   petitRADTRANS._input_data_loader.get_input_file
   petitRADTRANS._input_data_loader.get_line_by_line_opacity_file_extension
   petitRADTRANS._input_data_loader.get_opacity_directory
   petitRADTRANS._input_data_loader.get_opacity_input_file
   petitRADTRANS._input_data_loader.get_resolving_power_from_string
   petitRADTRANS._input_data_loader.get_resolving_power_string
   petitRADTRANS._input_data_loader.get_species_basename
   petitRADTRANS._input_data_loader.get_species_isotopologue_name
   petitRADTRANS._input_data_loader.get_species_scientific_name
   petitRADTRANS._input_data_loader.join_species_all_info
   petitRADTRANS._input_data_loader.split_input_data_path
   petitRADTRANS._input_data_loader.split_species_all_info


Module Contents
---------------

.. py:function:: __build_cia_aliases_dict()

.. py:function:: __default_file_selection(files, full_path, sub_path)

.. py:function:: __get_from_tuple(string, _tuple, _tuple_description)

   Base for the naming convention functions.


.. py:function:: __get_condensed_matter_state(string, regex_mode=False)

   Naming convention for condensed matter state. Access names here, change this to change the convention.


.. py:function:: __get_natural_abundance_string(separator='')

   Naming convention for natural abundance. Access names here, change this to change the convention.


.. py:function:: __get_spectral_sampling_type(string)

   Naming convention for spectral sampling type. Access names here, change this to change the convention.


.. py:function:: __get_solid_structure(string)

   Naming convention for solid structure. Access names here, change this to change the convention.


.. py:function:: __recursive_merge_contiguous_isotopes(isotope_groups, i, index_merge=None)

.. py:function:: _get_base_cia_names()

.. py:function:: _get_base_cloud_names()

.. py:function:: _get_base_correlated_k_names()

   Only used for file conversion from pRT2 to pRT3.


.. py:function:: _get_base_line_by_line_names()

   Only used for file conversion from pRT2 to pRT3.


.. py:function:: _get_input_file(path_input_data: str, sub_path: str, files: list[str] | None = None, filename: str | None = None, expect_spectral_information: bool = False, expect_default_file_exists: bool = True, find_all: bool = False, display_other_files: bool = False) -> str | list[str]

.. py:function:: _get_input_file_from_keeper(full_path, path_input_data=None, sub_path=None, filename=None, expect_spectral_information=False, find_all=False, ext='h5', timeout=3, url_input_data=None)

.. py:function:: _get_spectral_information(filename)

.. py:function:: _has_isotope(string)

.. py:function:: _join_spectral_information(resolution_filename, range_filename)

.. py:function:: _merge_contiguous_isotopes(species, isotope_separator)

.. py:function:: _rebuild_isotope_numbers(species, mode='add')

   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' or 'remove'.
           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, ...), the information is used (e.g. 13C2-1H2, 1H2-18O, ...)
           In 'remove' mode, remove all isotope numbers (e.g. 13C2-1H2 -> C2H2).

   Returns:
       The species name with added or removed isotope information.


.. py:function:: _split_cloud_info(cloud_info)

.. py:function:: _split_species_cloud_info(species)

.. py:function:: _split_species_charge(species, final_charge_format='+-')

.. py:function:: _split_species_source(species)

.. py:function:: _split_species_spectral_info(species)

.. py:function:: check_opacity_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 '-' (H218O is a working ex., 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:



.. py:function:: get_cia_aliases(name: str) -> str

.. py:function:: get_cia_opacity_file_extension()

   Return petitRADTRANS CIA opacity files extension.


.. py:function:: get_cloud_aliases(name: str) -> str

.. py:function:: get_cloud_opacity_file_extension()

   Return petitRADTRANS cloud opacity files extension.


.. py:function:: get_correlated_k_opacity_file_extension()

   Return petitRADTRANS correlated-k opacity files extension.


.. py:function:: get_default_cloud_resolution() -> str

.. py:function:: get_default_correlated_k_resolution() -> str

.. py:function:: get_default_line_by_line_resolution() -> str

.. py:function:: get_input_data_file_not_found_error_message(file: str) -> str

.. py:function:: get_input_file(file: str, path_input_data: str, sub_path: str = None, expect_spectral_information: bool = False, find_all: bool = False, search_online: bool = True)

.. py:function:: get_line_by_line_opacity_file_extension()

   Return petitRADTRANS line-by-line opacity files extension.


.. py:function:: get_opacity_directory(species: str, category: str, path_input_data: str = None, full: bool = False)

.. py:function:: get_opacity_input_file(path_input_data: str, category: str, species: str, 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 correlated-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


.. py:function:: get_resolving_power_from_string(string: str) -> int

.. py:function:: get_resolving_power_string(resolving_power: int | float) -> str | None

.. py:function:: get_species_basename(species: str, join: bool = False) -> str

.. py:function:: get_species_isotopologue_name(species: str, join: bool = False) -> str

.. py:function:: get_species_scientific_name(species: str) -> str

.. py:function:: join_species_all_info(name, natural_abundance='', charge='', cloud_info='', source='', spectral_info='', resolution_filename=None, range_filename=None)

.. py:function:: split_input_data_path(path: str, path_input_data: str)

.. py:function:: split_species_all_info(species, final_charge_format='+-')

