petitRADTRANS.__file_conversion#

Stores functions that convert files from a format to another.

The functions in this module are stored for the sake of keeping trace of changes made to files. They are intended to be used only once.

Attributes#

Functions#

__get_prt2_input_data_subpaths(→ dict[str, str])

__remove_files(old_files)

_clean_input_data_mac_junk_files([path_input_data])

__print_missing_data_file_message(obj, object_name, ...)

__print_skipping_message(hdf5_opacity_file)

_chemical_table_dat2h5([path_input_data, rewrite, ...])

_continuum_cia_dat2h5([path_input_data, rewrite, ...])

Using ExoMol units for HDF5 files.

_continuum_clouds_opacities_dat2h5([path_input_data, ...])

Using ExoMol units for HDF5 files.

_correlated_k_opacities_dat2h5([path_input_data, ...])

_correlated_k_opacities_dat2h5_external_species(...[, ...])

_get_base_cia_names()

_get_base_cloud_names()

_get_base_correlated_k_names()

Only used for file conversion from pRT2 to pRT3.

_get_base_line_by_line_names()

Only used for file conversion from pRT2 to pRT3.

_get_default_rebinning_wavelength_range()

_get_prt2_cia_names()

_get_prt2_cloud_names()

_get_prt2_correlated_k_names()

_get_prt2_line_by_line_names()

_line_by_line_opacities_dat2h5([path_input_data, ...])

Using ExoMol units for HDF5 files.

_phoenix_spec_dat2h5([path_input_data, rewrite, ...])

Convert a PHOENIX stellar spectrum in .dat format to HDF5 format.

_refactor_input_data_folder([path_input_data])

_sort_pressure_temperature_grid(...)

bin_species_exok(species, resolution)

This function uses exo-k to bin the c-k table of a

continuum_clouds_opacities_dat2h5(input_directory, ...)

Using ExoMol units for HDF5 files.

continuum_clouds_opacities_dat2h5_external_species(...)

fits_output(wavelength, spectrum, covariance, object_name)

Generate a fits file that can be used as an input to a pRT retrieval.

format2petitradtrans(load_function, ...[, charge, ...])

Convert opacities loaded with the specified load function into petitRADTRANS line-by-line and correlated-k

get_opacity_filename(resolving_power, ...[, ...])

line_by_line_opacities_dat2h5(directory, output_name, ...)

Using ExoMol units for HDF5 files.

load_dace(file, file_extension, molmass[, ...])

Read a DACE opacity file.

load_exocross(file, file_extension[, molmass, ...])

rebin_ck_line_opacities(input_file, target_resolving_power)

rebin_multiple_ck_line_opacities(target_resolving_power)

write_cia_opacities(hdf5_cia_file, molecules, ...[, ...])

write_cloud_opacities(hdf5_opacity_file, ...[, doi, ...])

write_correlated_k(file, doi, wavenumbers, ...[, ...])

write_line_by_line(file, doi, wavenumbers, opacities, ...)

convert_all([path_input_data, memory_map_mode, ...])

Module Contents#

petitRADTRANS.__file_conversion.prt_emcee_mode#
petitRADTRANS.__file_conversion.load_mpi = True#
petitRADTRANS.__file_conversion.load_mpi = False#
petitRADTRANS.__file_conversion.MPI = None#
petitRADTRANS.__file_conversion.rank = 0#
petitRADTRANS.__file_conversion.comm = None#
petitRADTRANS.__file_conversion.comm#
petitRADTRANS.__file_conversion.__get_prt2_input_data_subpaths() dict[str, str]#
petitRADTRANS.__file_conversion.__remove_files(old_files)#
petitRADTRANS.__file_conversion._clean_input_data_mac_junk_files(path_input_data=petitradtrans_config_parser.get_input_data_path())#
petitRADTRANS.__file_conversion.__print_missing_data_file_message(obj, object_name, directory)#
petitRADTRANS.__file_conversion.__print_skipping_message(hdf5_opacity_file)#
petitRADTRANS.__file_conversion._chemical_table_dat2h5(path_input_data=petitradtrans_config_parser.get_input_data_path(), rewrite=False, old_paths=False, clean=False)#
petitRADTRANS.__file_conversion._continuum_cia_dat2h5(path_input_data=petitradtrans_config_parser.get_input_data_path(), rewrite=False, output_directory=None, old_paths=False, clean=False)#

Using ExoMol units for HDF5 files.

petitRADTRANS.__file_conversion._continuum_clouds_opacities_dat2h5(path_input_data=petitradtrans_config_parser.get_input_data_path(), rewrite=False, old_paths=False, clean=False)#

Using ExoMol units for HDF5 files.

petitRADTRANS.__file_conversion._correlated_k_opacities_dat2h5(path_input_data=petitradtrans_config_parser.get_input_data_path(), rewrite=False, old_paths=False, clean=False, external_single_species=False, path_to_external_species_opacity_folder=None, external_species_longname=None, external_species_doi=None, external_species_contributor=None, external_species_description=None, external_species_molmass=None)#
petitRADTRANS.__file_conversion._correlated_k_opacities_dat2h5_external_species(path_to_species_opacity_folder, path_prt2_input_data, longname, doi=None, contributor=None, description=None, molmass=None)#
petitRADTRANS.__file_conversion._get_base_cia_names()#
petitRADTRANS.__file_conversion._get_base_cloud_names()#
petitRADTRANS.__file_conversion._get_base_correlated_k_names()#

Only used for file conversion from pRT2 to pRT3.

petitRADTRANS.__file_conversion._get_base_line_by_line_names()#

Only used for file conversion from pRT2 to pRT3.

petitRADTRANS.__file_conversion._get_default_rebinning_wavelength_range()#
petitRADTRANS.__file_conversion._get_prt2_cia_names()#
petitRADTRANS.__file_conversion._get_prt2_cloud_names()#
petitRADTRANS.__file_conversion._get_prt2_correlated_k_names()#
petitRADTRANS.__file_conversion._get_prt2_line_by_line_names()#
petitRADTRANS.__file_conversion._line_by_line_opacities_dat2h5(path_input_data=petitradtrans_config_parser.get_input_data_path(), memory_map_mode=False, rewrite=False, old_paths=False, clean=False)#

Using ExoMol units for HDF5 files.

petitRADTRANS.__file_conversion._phoenix_spec_dat2h5(path_input_data=petitradtrans_config_parser.get_input_data_path(), rewrite=False, old_paths=False, clean=False)#

Convert a PHOENIX stellar spectrum in .dat format to HDF5 format.

petitRADTRANS.__file_conversion._refactor_input_data_folder(path_input_data=petitradtrans_config_parser.get_input_data_path())#
petitRADTRANS.__file_conversion._sort_pressure_temperature_grid(pressure_temperature_grid_file)#
petitRADTRANS.__file_conversion.bin_species_exok(species: list[str], resolution: float)#

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

resolutionint

The desired spectral resolving power.

petitRADTRANS.__file_conversion.continuum_clouds_opacities_dat2h5(input_directory, output_name, cloud_species, doi, cloud_species_mode=None, path_input_data=petitradtrans_config_parser.get_input_data_path(), description=None, cloud_path=None, path_input_files=None, path_reference_files=None, rewrite=False, clean=False)#

Using ExoMol units for HDF5 files.

petitRADTRANS.__file_conversion.continuum_clouds_opacities_dat2h5_external_species(path_to_species_opacity_folder, longname, cloud_material_density, save_folder='converted_cloud_opacities', doi=None, description=None, wavelength_limit=None)#
petitRADTRANS.__file_conversion.fits_output(wavelength, spectrum, covariance, object_name, output_dir='', correlation=None)#

Generate a fits file that can be used as an input to a pRT retrieval.

Args:
wavelengthnumpy.ndarray

The wavelength bin centers in micron. dim(N)

spectrumnumpy.ndarray

The flux density in W/m2/micron at each wavelength bin. dim(N)

covariancenumpy.ndarray

The covariance of the flux in (W/m2/micron)^2 dim(N,N)

object_namestring

The name of the object, used for file naming.

output_dirstring

The parent directory of the output file.

correlationnumpy.ndarray

The correlation matrix of the flux points (See Brogi & Line 2018, https://arxiv.org/pdf/1811.01681.pdf)

Returns:
hdulastropy.fits.HDUlist

The HDUlist object storing the spectrum.

petitRADTRANS.__file_conversion.format2petitradtrans(load_function, opacities_directory: str, natural_abundance: bool, source: str, doi: str, species: str, charge: str = '', cloud_info: str = '', contributor: str = None, description: str = None, opacity_files_extension: str = None, spectral_dimension_file: str = None, path_input_data: str = petitradtrans_config_parser.get_input_data_path(), rebin: bool = True, save_correlated_k: bool = True, correlated_k_resolving_power: float = 1000, samples: numpy.ndarray = None, weights: numpy.ndarray = None, save_line_by_line: bool = True, line_by_line_wavelength_boundaries: numpy.ndarray = None, standard_line_by_line_wavelength_boundaries: numpy.ndarray = None, rewrite: bool = False, use_legacy_correlated_k_wavenumbers_sampling: bool = False)#

Convert opacities loaded with the specified load function into petitRADTRANS line-by-line and correlated-k opacities.

Args:
load_function:

String (‘dace’ or ‘exocross’), or function loading the opacities. If ‘dace’, the DACE (https://dace.unige.ch/opacityDatabase/) opacity built-in loading function is used. If ‘exocross’, the ExoCross (Trovemaster/exocross) opacity built-in loading function is used. If a function is used, it must have the following arguments, in that order:

  • file: the file name of a file containing the opacities (automatically taken from opacities_directory)

  • file_extension: see opacity_files_extension below

  • molmass: molar mass of the species (automatically set)

  • wavelength_file: see spectral_dimension_file below

  • wavenumbers_petitradtrans_line_by_line: the petitRADTRANS wavenumber grid for line-by-line opacities (automatically set)

  • save_line_by_line: see save_line_by_line below

  • rebin: see rebin below

  • selection: indices corresponding to the wavenumbers to be extracted

Not all of the above arguments have to be used. The function must output the following, in that order:

  • cross_sections: (cm2/molecule) the cross-sections

  • cross_sections_line_by_line: (cm2/molecule), the cross-sections,

    interpolated to wavenumbers_petitradtrans_line_by_line

  • wavenumbers: (cm-1) the wavenumbers corresponding to cross-sections

  • pressure: (bar) the pressure of the cross-sections

  • temperature: (K) the temperature of the cross-sections

The cross_sections, cross_sections_line_by_line and wavenumbers must be returned in increasing wavenumber order.

opacities_directory:

Directory in which the opacity files are stored.

natural_abundance:

If True, the opacities are considered coming from the natural (Earth’s) occurring isotopologue mix, instead of from a single isotope.

source:

Name of the opacities’ source (e.g., ‘POKAZATEL’).

doi:

DOI of the opacities’ source

species:

Chemical formula of the species (e.g. ‘H2O’)

charge:

Charge of the species (e.g. ‘2+’)

cloud_info:

Cloud additional info (physical state, internal structure, space group). See the petitRADTRANS cloud filename convention for more information.

contributor:

Contributor that helped obtained the opacities.

description:

Additional description on the opacities.

opacity_files_extension:

The extension of the opacity files.

spectral_dimension_file:

File containing the opacities’ wavelengths.

path_input_data:

Path to the input data directory.

rebin:

If true, rebin the opacities to the petitRADTRANS standard wavenumber grid. Should be True in most cases.

save_correlated_k:

If True, convert and save the opacities in correlated-k (‘c-k’) format.

correlated_k_resolving_power:

Resolving power at which to convert the opacities, for the correlated-k case.

samples:

Array containing the correlated-k samples.

weights:

Array containing the correlated-k weights.

save_line_by_line:

If True, convert and save the opacities in line-by-line (‘lbl’) format.

line_by_line_wavelength_boundaries:

Wavelength boundaries to use for the line-by-line conversion.

standard_line_by_line_wavelength_boundaries:

Wavelength boundaries to use when generating the lbl standard petitRADTRANS wavelengths.

rewrite:

if True, rewrite existing converted files

use_legacy_correlated_k_wavenumbers_sampling:

If True, use the legacy (pRT2) way to sample the correlated-k wavenumbers.

petitRADTRANS.__file_conversion.get_opacity_filename(resolving_power, wavelength_boundaries, species_isotopologue_name, source, natural_abundance='', charge='', cloud_info='')#
petitRADTRANS.__file_conversion.line_by_line_opacities_dat2h5(directory, output_name, molmass, doi, path_input_data=petitradtrans_config_parser.get_input_data_path(), contributor=None, description=None, opacities_pressures=None, opacities_temperatures=None, line_paths=None, memory_map_mode=False, rewrite=False, clean=False)#

Using ExoMol units for HDF5 files.

petitRADTRANS.__file_conversion.load_dace(file, file_extension, molmass, wavelength_file=None, wavenumbers_petitradtrans_line_by_line=None, save_line_by_line=False, rebin=True, selection=None)#

Read a DACE opacity file.

petitRADTRANS.__file_conversion.load_exocross(file, file_extension, molmass=None, wavelength_file=None, wavenumbers_petitradtrans_line_by_line=None, save_line_by_line=False, rebin=True, selection=None)#
petitRADTRANS.__file_conversion.rebin_ck_line_opacities(input_file, target_resolving_power, wavenumber_grid=None, rewrite=False)#
petitRADTRANS.__file_conversion.rebin_multiple_ck_line_opacities(target_resolving_power, paths=None, species=None, rewrite=False)#
petitRADTRANS.__file_conversion.write_cia_opacities(hdf5_cia_file, molecules, wavenumbers, wavelengths, alpha, temperatures, doi='', description='')#
petitRADTRANS.__file_conversion.write_cloud_opacities(hdf5_opacity_file, cloud_species, wavenumbers, cloud_wavelengths, cloud_absorption_opacities, cloud_scattering_opacities, cloud_asymmetry_parameter, cloud_particles_densities, cloud_particles_radii, cloud_particles_radius_bins, doi='', description='')#
petitRADTRANS.__file_conversion.write_correlated_k(file, doi, wavenumbers, wavenumbers_bins_edges, cross_sections, mol_mass, species, opacities_pressures, opacities_temperatures, g_gauss, weights_gauss, wavelengths=None, n_g=None, contributor=None, description=None)#
petitRADTRANS.__file_conversion.write_line_by_line(file, doi, wavenumbers, opacities, mol_mass, species, opacities_pressures, opacities_temperatures, wavelengths=None, contributor=None, description=None)#
petitRADTRANS.__file_conversion.convert_all(path_input_data=petitradtrans_config_parser.get_input_data_path(), memory_map_mode=False, rewrite=False, old_paths=False, clean=False)#