petitRADTRANS.opacities.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.
Functions#
|
|
|
|
|
|
|
|
|
|
|
Using ExoMol units for HDF5 files. |
|
Using ExoMol units for HDF5 files. |
|
|
|
|
Only used for file conversion from pRT2 to pRT3. |
|
Only used for file conversion from pRT2 to pRT3. |
|
|
Using ExoMol units for HDF5 files. |
|
Convert a PHOENIX stellar spectrum in .dat format to HDF5 format. |
|
|
|
This function uses exo-k to bin the c-k table of a |
|
Using ExoMol units for HDF5 files. |
|
Generate a fits file that can be used as an input to a pRT retrieval. |
|
Convert opacities loaded with the specified load function into petitRADTRANS line-by-line and correlated-k |
|
|
|
Using ExoMol units for HDF5 files. |
|
Read a DACE opacity file. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Module Contents#
- petitRADTRANS.opacities.file_conversion.__get_prt2_input_data_subpaths() petitRADTRANS.utils.LockedDict[str, str]#
- petitRADTRANS.opacities.file_conversion.__remove_files(old_files)#
- petitRADTRANS.opacities.file_conversion._clean_input_data_mac_junk_files(path_input_data=petitradtrans_config_parser.get_input_data_path())#
- petitRADTRANS.opacities.file_conversion.__print_missing_data_file_message(obj, object_name, directory)#
- petitRADTRANS.opacities.file_conversion.__print_skipping_message(hdf5_opacity_file)#
- petitRADTRANS.opacities.file_conversion._chemical_table_dat2h5(path_input_data=petitradtrans_config_parser.get_input_data_path(), rewrite=False, old_paths=False, clean=False)#
- petitRADTRANS.opacities.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.opacities.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.opacities.file_conversion._get_base_cia_names()#
- petitRADTRANS.opacities.file_conversion._get_base_cloud_names()#
Only used for file conversion from pRT2 to pRT3.
- petitRADTRANS.opacities.file_conversion._get_base_line_by_line_names()#
Only used for file conversion from pRT2 to pRT3.
- petitRADTRANS.opacities.file_conversion._get_default_rebinning_wavelength_range()#
- petitRADTRANS.opacities.file_conversion._get_prt2_cia_names()#
- petitRADTRANS.opacities.file_conversion._get_prt2_cloud_names()#
- petitRADTRANS.opacities.file_conversion._get_prt2_line_by_line_names()#
- petitRADTRANS.opacities.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.opacities.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.opacities.file_conversion._refactor_input_data_folder(path_input_data=petitradtrans_config_parser.get_input_data_path())#
- petitRADTRANS.opacities.file_conversion._sort_pressure_temperature_grid(pressure_temperature_grid_file)#
- petitRADTRANS.opacities.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.opacities.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.opacities.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.opacities.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.opacities.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.opacities.file_conversion.get_opacity_filename(resolving_power, wavelength_boundaries, species_isotopologue_name, source, natural_abundance='', charge='', cloud_info='')#
- petitRADTRANS.opacities.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.opacities.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.opacities.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.opacities.file_conversion.rebin_ck_line_opacities(input_file, target_resolving_power, wavenumber_grid=None, rewrite=False)#
- petitRADTRANS.opacities.file_conversion.rebin_multiple_ck_line_opacities(target_resolving_power, paths=None, species=None, rewrite=False)#
- petitRADTRANS.opacities.file_conversion.write_cia_opacities(hdf5_cia_file, molecules, wavenumbers, wavelengths, alpha, temperatures, doi='', description='')#
- petitRADTRANS.opacities.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.opacities.file_conversion.write_line_by_line(file, doi, wavenumbers, opacities, mol_mass, species, opacities_pressures, opacities_temperatures, wavelengths=None, contributor=None, description=None)#
- petitRADTRANS.opacities.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)#