species.data package#

Subpackages#

Submodules#

species.data.database module#

Module with functionalities for reading and writing of data.

class species.data.database.Database[source]#

Bases: object

Class with reading and writing functionalities for the HDF5 database.

Returns:

None

Return type:

NoneType

add_accretion() None[source]#

Function for adding the coefficients for converting line luminosities of hydrogen emission lines into accretion luminosities (see Aoyama et al. (2021) and Marleau & Aoyama (2022) for details). The relation is used by EmissionLine for converting the fitted line luminosity.

Returns:

None

Return type:

NoneType

add_calibration(tag: str, filename: str | None = None, data: ndarray | None = None, units: Dict[str, str] | None = None, scaling: Tuple[float, float] | None = None) None[source]#

Function for adding a calibration spectrum to the database.

Parameters:
  • tag (str) – Tag name in the database.

  • filename (str, None) – Name of the file that contains the calibration spectrum. The file could be either a plain text file, in which the first column contains the wavelength (um), the second column the flux density (W m-2 um-1), and the third column the uncertainty (W m-2 um-1). Or, a FITS file can be provided in which the data is stored as a 2D array in the primary HDU. The data argument is not used if set to None.

  • data (np.ndarray, None) – Spectrum stored as 3D array with shape (n_wavelength, 3). The first column should contain the wavelength (um), the second column the flux density (W m-2 um-1), and the third column the error (W m-2 um-1). The filename argument is used if set to None.

  • units (dict, None) – Dictionary with the wavelength and flux units, e.g. {'wavelength': 'angstrom', 'flux': 'w m-2'}. The default units (um and W m-2 um-1) are used if set to None.

  • scaling (tuple(float, float), None) – Scaling for the wavelength and flux as (scaling_wavelength, scaling_flux). Not used if set to None.

Returns:

None

Return type:

NoneType

add_companion(name: str | None | List[str] = None, verbose: bool = True) None[source]#

Function for adding the magnitudes and spectra of directly imaged planets and brown dwarfs from data/companion_data/companion_data.json and companion_spectra() to the database.

Parameters:
  • name (str, list(str), None) – Name or list with names of the directly imaged planets and brown dwarfs (e.g. 'HR 8799 b' or ['HR 8799 b', '51 Eri b', 'PZ Tel B']). All the available companion data are added if the argument is set to None.

  • verbose (bool) – Print details on the companion data that are added to the database.

Returns:

None

Return type:

NoneType

add_comparison(tag: str, goodness_of_fit: ndarray, flux_scaling: ndarray, model_param: List[str], coord_points: List[ndarray], object_name: str, spec_name: List[str], model: str, scale_spec: List[str], extra_scaling: ndarray | None, inc_phot: List[str]) None[source]#

Function for adding results obtained with CompareSpectra to the HDF5 database.

Parameters:
  • tag (str) – Database tag where the results will be stored.

  • goodness_of_fit (np.ndarray) – Array with the goodness-of-fit values.

  • flux_scaling (np.ndarray) – Array with the best-fit scaling values to match the model spectra with the data.

  • model_param (list(str)) – List with the names of the model parameters.

  • coord_points (list(np.ndarray)) – List with 1D arrays of the model grid points, in the same order as model_param.

  • object_name (str) – Object name as stored in the database with add_object() or add_companion().

  • spec_name (list(str)) – List with spectrum names that are stored at the object data of object_name.

  • model (str) – Atmospheric model grid that is used for the comparison.

  • scale_spec (list(str)) – List with spectrum names to which an additional scaling has been applied.

  • extra_scaling (np.ndarray. None) – Array with extra scalings that have been applied to the spectra of scale_spec. The argument can be set to None if no extra scalings have been applied.

  • inc_phot (list(str)) – List with filter names of which photometric data was included with the comparison.

Returns:

None

Return type:

NoneType

add_custom_model(model: str, data_path: str, parameters: List[str], wavel_range: Tuple[float, float] | None = None, wavel_sampling: float | None = None, teff_range: Tuple[float, float] | None = None) None[source]#

Function for adding a custom grid of model spectra to the database. The spectra are read from the data_path and should contain the model_name and parameters in the filenames in the following format example: model-name_teff_1000_logg_4.0_feh_0.0_spec.dat. The list with parameters should contain the same parameters as are included in the filename. Each datafile should contain two columns with the wavelengths in \(\mu\text{m}\) and the fluxes in \(\text{W} \text{m}^{-2} \mu\text{m}^{-1}\). Each file should contain the same number and values of wavelengths. The wavelengths should be logarithmically sampled, so at a constant resolution, \(\lambda/\Delta\lambda\). If not, then the wavel_range and wavel_sampling parameters should be used such that the wavelengths are resampled when reading the data into the species database.

Parameters:
  • model (str) – Name of the model grid. Should be identical to the model name that is used in the filenames.

  • data_path (str) – Path where the files with the model spectra are located. It is best to provide an absolute path to the folder.

  • parameters (list(str)) – List with the model parameters. The following parameters are supported: teff (for \(T_\mathrm{eff}\)), logg (for \(\log\,g\)), feh (for [Fe/H]), c_o_ratio (for C/O), fsed (for \(f_\mathrm{sed}\)), log_kzz (for \(\log\,K_\mathrm{zz}\)), and ad_index (for \(\gamma_\mathrm{ad}\)). Please contact the code maintainer if support for other parameters should be added.

  • wavel_range (tuple(float, float), None) – Wavelength range (\(\mu\text{m}\)) that will be stored in the database. The full wavelength range is used if the argument is set to None.

  • wavel_sampling (float, None) – Wavelength spacing \(\lambda/\Delta\lambda\) to which the spectra will be resampled. Typically this parameter is not needed so the argument can be set to None. The only benefit of using this parameter is limiting the storage in the HDF5 database. The parameter should be used in combination with setting the wavel_range.

  • teff_range (tuple(float, float), None) – Effective temperature range (K) for adding a subset of the model grid. The full parameter grid will be added if the argument is set to None.

Returns:

None

Return type:

NoneType

add_dust() None[source]#

Function for adding optical constants of MgSiO3 and Fe, and MgSiO3 cross sections for a log-normal and power-law size distribution to the database. The optical constants have been compiled by Mollière et al. (2019) for petitRADTRANS from the following sources:

  • MgSiO3, crystalline
    • Scott & Duley (1996), ApJS, 105, 401

    • Jäger et al. (1998), A&A, 339, 904

  • MgSiO3, amorphous
    • Jäger et al. (2003), A&A, 408, 193

  • Fe, crystalline
    • Henning & Stognienko (1996), A&A, 311, 291

  • Fe, amorphous
    • Pollack et al. (1994), ApJ, 421, 615

Returns:

None

Return type:

NoneType

add_empirical(tag: str, names: List[str], sptypes: List[str], goodness_of_fit: List[float], flux_scaling: List[ndarray], av_ext: List[float], rad_vel: List[float], object_name: str, spec_name: List[str], spec_library: str) None[source]#
Parameters:
  • tag (str) – Database tag where the results will be stored.

  • names (list(str)) – Array with the names of the empirical spectra.

  • sptypes (list(str)) – Array with the spectral types of names.

  • goodness_of_fit (list(float)) – Array with the goodness-of-fit values.

  • flux_scaling (list(np.ndarray)) – List with arrays with the best-fit scaling values to match the library spectra with the data. The size of each array is equal to the number of spectra that are provided as argument of spec_name.

  • av_ext (list(float)) – Array with the visual extinction \(A_V\).

  • rad_vel (list(float)) – Array with the radial velocities (km s-1).

  • object_name (str) – Object name as stored in the database with add_object() or add_companion().

  • spec_name (list(str)) – List with spectrum names that are stored at the object data of object_name.

  • spec_library (str) – Name of the spectral library that was used for the empirical comparison.

Returns:

None

Return type:

NoneType

add_filter(filter_name: str, filename: str | None = None, detector_type: str = 'photon', verbose: bool = True) None[source]#

Function for adding a filter profile to the database, either from the SVO Filter profile Service or from an input file. Additional filters that are automatically added are Magellan/VisAO.rp, Magellan/VisAO.ip, Magellan/VisAO.zp, Magellan/VisAO.Ys, ALMA/band6, and ALMA/band7.

Parameters:
  • filter_name (str) – Filter name from the SVO Filter Profile Service (e.g., ‘Paranal/NACO.Lp’) or a user-defined name if a filename is specified.

  • filename (str, None) – Filename of the filter profile. The first column should contain the wavelength (um) and the second column the fractional transmission. The profile is downloaded from the SVO Filter Profile Service if the argument of filename is set to None.

  • detector_type (str) – The detector type (‘photon’ or ‘energy’). The argument is only used if a filename is provided. Otherwise, for filters that are fetched from the SVO website, the detector type is read from the SVO data. The detector type determines if a wavelength factor is included in the integral for the synthetic photometry.

  • verbose (bool) – Print details on the companion data that are added to the database.

Returns:

None

Return type:

NoneType

add_isochrones(model: str, filename: str | None = None, tag: str | None = None) None[source]#

Function for adding isochrone data to the database.

Parameters:
  • model (str) – Evolutionary model (‘ames’, ‘atmo’, ‘baraffe2015’, ‘bt-settl’, ‘linder2019’, ‘nextgen’, ‘saumon2008’, ‘sonora’, or ‘manual’). Isochrones will be automatically downloaded. Alternatively, isochrone data can be downloaded from https://phoenix.ens-lyon.fr/Grids/ or https://perso.ens-lyon.fr/isabelle.baraffe/, and can be manually added by setting the filename and tag arguments, and setting model='manual'.

  • filename (str, None) – Filename with the isochrone data. Setting the argument is only required when model='manual'. Otherwise, the argument can be set to None.

  • tag (str, None) – Database tag name where the isochrone that will be stored. Setting the argument is only required when model='manual'. Otherwise, the argument can be set to None.

Returns:

None

Return type:

NoneType

add_model(model: str, wavel_range: Tuple[float, float] | None = None, wavel_sampling: float | None = None, teff_range: Tuple[float, float] | None = None, unpack_tar: bool = True) None[source]#

Function for adding a grid of model spectra to the database. All spectra have been resampled to logarithmically-spaced wavelengths (see available_models()), typically at the order of several thousand. It should be noted that the original spectra were typically calculated with a constant step size in wavenumber, so the original wavelength sampling decreased from short to long wavelengths. When fitting medium/high- resolution spectra, it is best to carefully check the result to determine if the sampling of the input grid was sufficient for modeling the spectra at the considered wavelength regime. See also add_custom_model() for adding a custom grid to the database.

Parameters:
  • model (str) – Model name (‘ames-cond’, ‘ames-dusty’, ‘atmo-ceq’, ‘atmo-neq-weak’, ‘atmo-neq-strong’, ‘bt-settl’, ‘bt-settl-cifist’, ‘bt-nextgen’, ‘drift-phoenix’, ‘petitcode-cool-clear’, ‘petitcode-cool-cloudy’, ‘petitcode-hot-clear’, ‘petitcode-hot-cloudy’, ‘exo-rem’, ‘blackbody’, bt-cond’, ‘bt-cond-feh, ‘morley-2012’, ‘sonora-cholla’, ‘sonora-bobcat’, ‘sonora-bobcat-co’, ‘koester-wd’, ‘saumon2008-clear’, ‘saumon2008-cloudy’, ‘petrus2023’, ‘sphinx’).

  • wavel_range (tuple(float, float), None) – Wavelength range (\(\mu\text{m}\)) that will be stored in the database. The full wavelength range is used if the argument is set to None.

  • wavel_sampling (float, None) – Wavelength spacing \(\lambda/\Delta\lambda\) to which the spectra will be resampled. Typically this parameter is not needed so the argument can be set to None. The only benefit of using this parameter is limiting the storage in the HDF5 database. The parameter should be used in combination with setting the wavel_range.

  • teff_range (tuple(float, float), None) – Range of effective temperatures (K) of which the spectra are extracted from the TAR file and added to the HDF5 database. The full grid of spectra will be added if the argument is set to None.

  • unpack_tar (bool) – Unpack the TAR file with the model spectra in the data_folder. By default, the argument is set to True such the TAR file with the model spectra will be unpacked after downloading. In case the TAR file had already been unpacked previously, the argument can be set to False such that the unpacking will be skipped. This can save some time with unpacking large TAR files.

Returns:

None

Return type:

NoneType

add_object(object_name: str, parallax: Tuple[float, float] | None = None, distance: Tuple[float, float] | None = None, app_mag: Dict[str, Tuple[float, float] | List[Tuple[float, float]]] | None = None, flux_density: Dict[str, Tuple[float, float]] | None = None, spectrum: Dict[str, Tuple[str | ndarray, str | ndarray | None, float | None]] | None = None, deredden: Dict[str, float] | float | None = None, verbose: bool = True, units: Dict[str, str | Tuple[str, str]] | None = None) None[source]#

Function for adding the photometry and/or spectra of an object to the database.

Parameters:
  • object_name (str) – Object name that will be used as label in the database.

  • parallax (tuple(float, float), None) – Parallax and uncertainty (mas). Not stored if the argument is set to None.

  • distance (tuple(float, float), None) – Distance and uncertainty (pc). Not stored if the argument is set to None. This parameter is deprecated and will be removed in a future release. Please use the parallax parameter instead.

  • app_mag (dict, None) – Dictionary with the filter names, apparent magnitudes, and uncertainties. For example, {'Paranal/NACO.Lp': (15., 0.2), 'Paranal/NACO.Mp': (13., 0.3)}. For the use of duplicate filter names, the magnitudes have to be provided in a list, for example {'Paranal/NACO.Lp': [(15., 0.2), (14.5, 0.5)], 'Paranal/NACO.Mp': (13., 0.3)}. No photometry is stored if the argument is set to None.

  • flux_density (dict, None) – Dictionary with filter names, flux densities (W m-2 um-1), and uncertainties (W m-1 um-1), or setting the units parameter when other flux units are used. For example, {'Paranal/NACO.Lp': (1e-15, 1e-16)}. Currently, the use of duplicate filters is not implemented. The use of app_mag is preferred over flux_density because with flux_density only fluxes are stored while with app_mag both magnitudes and fluxes. However, flux_density can be used in case the magnitudes and/or filter profiles are not available. In that case, the fluxes can still be selected with inc_phot in FitModel. The argument of flux_density is ignored if set to None.

  • spectrum (dict, None) – Dictionary with the spectrum, optional covariance matrix, and resolving power of the instrument. The input data can either be a FITS or ASCII file, or as NumPy array directly. The spectra should have 3 columns, so the array shape should be (n_wavelengths, 3), with wavelength (um), flux (W m-2 um-1), and uncertainty (W m-2 um-1). The units parameter can be set for reading in data with different wavelength and/or flux units. The covariance matrix should be 2D with the same number of wavelength points as the spectrum, so the shape is (n_wavelengths, n_wavelengths). Like the spectrum, the covariance matrix can be provided as FITS or ASCII file, or as NumPy array directly. For example, when providing the input as files, {'SPHERE': ('spectrum.dat', 'covariance.fits', 50.)}. No covariance data is stored if set to None, for example, {'SPHERE': ('spectrum.dat', None, 50.)}. The spectrum parameter is ignored if set to None. For VLTI/GRAVITY data, the same FITS file can be provided as spectrum and covariance matrix.

  • deredden (dict, float, None) – Dictionary with spectrum and app_mag names that will be dereddened with the provided \(A_V\). For example, deredden={'SPHERE': 1.5, 'Keck/NIRC2.J': 1.5} will deredden the provided spectrum named ‘SPHERE’ and the Keck/NIRC2 J-band photometry with a visual extinction of 1.5. For photometric fluxes, the filter-averaged extinction is used for the dereddening.

  • verbose (bool) – Print details on the object data that are added to the database.

  • units (dict, None) – Dictionary with the units of the data provided with flux_density and spectrum. Only required if the wavelength units are not \(\mu\text{m}^{-1}\) and/or the flux units are not provided as \(\text{W} \text{m}^{-2} \mu\text{m}^{-1}\). Otherwise, the argument of units can be set to None such that it will be ignored. The dictionary keys should be the filter names as provided with flux_density and the spectrum names as provided with spectrum. Supported units can be found in the docstring of convert_units().

Returns:

None

Return type:

NoneType

add_photometry(phot_library: str) None[source]#
Parameters:

phot_library (str) – Photometric library (‘vlm-plx’ or ‘leggett’).

Returns:

None

Return type:

NoneType

add_retrieval(tag: str, output_folder: str, inc_teff: bool = False) None[source]#

Function for adding the output data from the atmospheric retrieval with AtmosphericRetrieval to the database.

Parameters:
  • tag (str) – Database tag to store the posterior samples.

  • output_folder (str) – Output folder that was used for the output files by MultiNest.

  • inc_teff (bool) – Calculate \(T_\mathrm{eff}\) for each sample by integrating the model spectrum from 0.5 to 50 um. The \(T_\mathrm{eff}\) samples are added to the array with samples that are stored in the database. The computation time for adding \(T_\mathrm{eff}\) will be long because the spectra need to be calculated and integrated for all samples.

Returns:

None

Return type:

NoneType

add_samples(sampler: str, samples: ndarray, ln_prob: ndarray, tag: str, modelpar: List[str], bounds: Dict, normal_prior: Dict, ln_evidence: Tuple[float, float] | None = None, mean_accept: float | None = None, spectrum: Tuple[str, str] | None = None, parallax: float | None = None, spec_labels: List[str] | None = None, attr_dict: Dict | None = None)[source]#

This function stores the posterior samples from classes such as FitModel in the database, including some additional attributes.

Parameters:
  • sampler (str) – Sampler (‘emcee’, ‘multinest’, or ‘ultranest’).

  • samples (np.ndarray) – Samples of the posterior.

  • ln_prob (np.ndarray) – Log posterior for each sample.

  • tag (str) – Database tag.

  • modelpar (list(str)) – List with the model parameter names.

  • bounds (dict) – Dictionary with the (log-)uniform priors.

  • normal_prior (dict) – Dictionary with the normal priors.

  • ln_evidence (tuple(float, float), None) – Log evidence and uncertainty. Set to None when sampler is ‘emcee’.

  • mean_accept (float, None) – Mean acceptance fraction. Set to None when sampler is ‘multinest’ or ‘ultranest’.

  • spectrum (tuple(str, str)) – Tuple with the spectrum type (‘model’ or ‘calibration’) and spectrum name (e.g. ‘drift-phoenix’ or ‘evolution’).

  • parallax (float, None) – Parallax (mas) of the object. Not used if the argument is set to None.

  • spec_labels (list(str), None) – List with the spectrum labels that are used for fitting an additional scaling parameter. Not used if set to None.

  • attr_dict (dict, None) – Dictionary with data that will be stored as attributes of the dataset with samples.

Returns:

None

Return type:

NoneType

add_simple_object(object_name: str, simple_database: str | None = None) None[source]#

Function for retrieving data of an individual object from the SIMPLE database and adding the data to the species database. This function includes code that has been adapted from SEDkitSIMPLE.

Parameters:
  • object_name (str) – Object name that will be used for the query and also used as label by which the data will be stored in the database.

  • simple_database (str, None) – Path to the SIMPLE database file SIMPLE.db. The binary file is automatically downloaded from the Github page of SIMPLE when the argument is set to None.

Returns:

None

Return type:

NoneType

add_spectra(spec_library: str, sptypes: List[str] | None = None) None[source]#

Function for adding empirical spectral libraries to the database. The spectra are stored together with several attributes such as spectral type, parallax, and Simbad ID. The spectra can be read with the functionalities of ReadSpectrum.

Parameters:
  • spec_library (str) – Spectral library (‘irtf’, ‘spex’, ‘kesseli+2017’, ‘bonnefoy+2014’, ‘allers+2013’).

  • sptypes (list(str)) – Spectral types (‘F’, ‘G’, ‘K’, ‘M’, ‘L’, ‘T’). Currently only implemented for spec_library='irtf'.

Returns:

None

Return type:

NoneType

available_models(verbose: bool = True) Dict[source]#

Function for printing an overview of the available model grids that can be downloaded and added to the database with add_model.

Parameters:

verbose (bool) – Print details on the grids of model spectra or list only the names of the available model spectra.

Returns:

Dictionary with the details on the model grids. The dictionary is created from the model_data.json file in the species.data folder.

Return type:

dict

delete_data(data_set: str) None[source]#

Function for deleting a dataset from the HDF5 database.

Parameters:

data_set (str) – Group or dataset path in the HDF5 database. The content and structure of the database can be shown with list_content(). That could help to determine which argument should be provided as argument of data_set. For example, data_set="models/drift-phoenix" will remove the model spectra of DRIFT-PHOENIX.

Returns:

None

Return type:

NoneType

get_compare_sample(tag: str, verbose: bool = True) Dict[str, float][source]#

Function for extracting the sample parameters for which the goodness-of-fit statistic has been minimized when using compare_model() for comparing data with a grid of model spectra.

Parameters:
  • tag (str) – Database tag where the results from compare_model() are stored.

  • verbose (bool) – Print output, including the parameter values.

Returns:

Dictionary with the best-fit parameters, including optional scaling parameters for spectra that can be applied by running update_objectbox() on an ObjectBox() by providing the returned dictionary from get_compare_sample() as argument.

Return type:

dict

get_evidence(tag: str) Tuple[float, float][source]#

Function for returning the log-evidence (i.e. marginalized likelihood) that was computed by the nested sampling algorithm when using FitModel or AtmosphericRetrieval.

Parameters:

tag (str) – Database tag with the posterior samples.

Returns:

  • float – Log-evidence.

  • float – Uncertainty on the log-evidence.

get_mcmc_photometry(tag: str, filter_name: str, burnin: int | None = None, phot_type: str = 'magnitude') ndarray[source]#

Function for calculating synthetic magnitudes or fluxes from the posterior samples.

Parameters:
  • tag (str) – Database tag with the posterior samples.

  • filter_name (str) – Filter name for which the synthetic photometry will be computed.

  • burnin (int, None) – Number of burnin steps to remove. No burnin is removed if the argument is set to None. Is only applied on posterior distributions that have been sampled with emcee.

  • phot_type (str) – Photometry type (‘magnitude’ or ‘flux’).

Returns:

Synthetic magnitudes or fluxes (W m-2 um-1).

Return type:

np.ndarray

get_mcmc_spectra(tag: str, random: int, burnin: int | None = None, wavel_range: Tuple[float, float] | str | None = None, spec_res: float | None = None, wavel_resample: ndarray | None = None) List[ModelBox] | List[SpectrumBox][source]#

Function for drawing random spectra from the sampled posterior distributions.

Parameters:
  • tag (str) – Database tag with the posterior samples.

  • random (int) – Number of random samples.

  • burnin (int, None) – Number of burnin steps to remove. No burnin is removed if the argument is set to None. Is only applied on posterior distributions that have been sampled with emcee.

  • wavel_range (tuple(float, float), str, None) – Wavelength range (um) or filter name. Full spectrum is used if set to None.

  • spec_res (float, None) – Spectral resolution that is used for the smoothing with a Gaussian kernel. No smoothing is applied if the argument set to None.

  • wavel_resample (np.ndarray, None) – Wavelength points (um) to which the model spectrum will be resampled. The resampling is applied after the optional smoothing to the resolution of spec_res.

Returns:

List with ModelBox objects.

Return type:

list(species.core.box.ModelBox)

get_median_sample(tag: str, burnin: int | None = None, verbose: bool = True) Dict[str, float][source]#

Function for extracting the median parameter values from the posterior samples.

Parameters:
  • tag (str) – Database tag with the posterior results.

  • burnin (int, None) – Number of burnin steps to remove. No burnin is removed if the argument is set to None. Is only applied on posterior distributions that have been sampled with emcee.

  • verbose (bool) – Print output, including the parameter values.

Returns:

Median parameter values of the posterior distribution.

Return type:

dict

get_object(object_name: str, inc_phot: bool | List[str] = True, inc_spec: bool | List[str] = True, verbose: bool = True) ObjectBox[source]#

Function for extracting the photometric and/or spectroscopic data of an object from the database. The spectroscopic data contains optionally the covariance matrix and its inverse.

Parameters:
  • object_name (str) – Object name in the database.

  • inc_phot (bool, list(str)) – Include photometric data. If a boolean, either all (True) or none (False) of the data are selected. If a list, a subset of filter names (as stored in the database) can be provided.

  • inc_spec (bool, list(str)) – Include spectroscopic data. If a boolean, either all (True) or none (False) of the data are selected. If a list, a subset of spectrum names (as stored in the database with add_object()) can be provided.

  • verbose (bool) – Print output.

Returns:

Box with the object’s data.

Return type:

species.core.box.ObjectBox

get_probable_sample(tag: str, burnin: int | None = None, verbose: bool = True) Dict[str, float][source]#

Function for extracting the sample parameters with the highest posterior probability.

Parameters:
  • tag (str) – Database tag with the posterior results.

  • burnin (int, None) – Number of burnin steps to remove. No burnin is removed if the argument is set to None. Is only applied on posterior distributions that have been sampled with emcee.

  • verbose (bool) – Print output, including the parameter values.

Returns:

Parameters and values for the sample with the maximum posterior probability.

Return type:

dict

get_pt_profiles(tag: str, random: int | None = None, out_file: str | None = None) Tuple[ndarray, ndarray][source]#

Function for returning the pressure-temperature profiles from the posterior of the atmospheric retrieval with petitRADTRANS. The data can also optionally be written to an output file.

Parameters:
  • tag (str) – Database tag with the posterior samples from the atmospheric retrieval with AtmosphericRetrieval.

  • random (int, None) – Number of random samples that will be used for the P-T profiles. All samples will be selected if set to None.

  • out_file (str, None) – Output file to store the P-T profiles. The data will be stored in a FITS file if the argument of out_file ends with .fits. Otherwise, the data will be written to a text file. The data has two dimensions with the first column containing the pressures (bar) and the remaining columns the temperature profiles (K). The data will not be written to a file if the argument is set to None.

Returns:

  • np.ndarray – Array (1D) with the pressures (bar).

  • np.ndarray – Array (2D) with the temperature profiles (K). The shape of the array is (n_pressures, n_samples).

static get_retrieval_spectra(tag: str, random: int | None, wavel_range: Tuple[float, float] | str | None = None, spec_res: float | None = None) Tuple[List[ModelBox], Any][source]#

Function for extracting random spectra from the posterior distribution that was sampled with AtmosphericRetrieval.

Parameters:
  • tag (str) – Database tag with the posterior samples.

  • random (int, None) – Number of randomly selected samples. All samples are selected if set to None. When setting random=0, no random spectra are sampled (so the returned list with ModelBox objects is empty), but the ReadRadtrans instance is still returned.

  • wavel_range (tuple(float, float), str, None) – Wavelength range (um) or filter name. The wavelength range from the retrieval is adopted (i.e. the``wavel_range`` parameter of AtmosphericRetrieval) when set to None. It is mandatory to set the argument to None in case the log_tau_cloud parameter has been used with the retrieval.

  • spec_res (float, None) – Spectral resolution that is used for the smoothing with a Gaussian kernel. No smoothing is applied when the argument is set to None.

Returns:

  • list(ModelBox) – Boxes with the randomly sampled spectra.

  • species.read.read_radtrans.ReadRadtrans – Instance of ReadRadtrans.

get_retrieval_teff(tag: str, random: int = 100) Tuple[ndarray, ndarray][source]#

Function for calculating \(T_\mathrm{eff}\) and \(L_\mathrm{bol}\) from randomly drawn samples of the posterior distribution that is estimated with AtmosphericRetrieval. This requires the recalculation of the spectra across a broad wavelength range (0.5-50 um).

Parameters:
  • tag (str) – Database tag with the posterior samples.

  • random (int) – Number of randomly selected samples.

Returns:

  • np.ndarray – Array with \(T_\mathrm{eff}\) samples.

  • np.ndarray – Array with \(\log(L/L_\mathrm{sun})\) samples.

get_samples(tag: str, burnin: int | None = None, random: int | None = None, json_file: str | None = None) SamplesBox[source]#
Parameters:
  • tag (str) – Database tag with the samples.

  • burnin (int, None) – Number of burnin steps to remove. No burnin is removed if the argument is set to None. Is only applied on posterior distributions that have been sampled with emcee.

  • random (int, None) – Number of random samples to select. All samples (with the burnin excluded) are selected if set to None.

  • json_file (str, None) – JSON file to store the posterior samples. The data will not be written if the argument is set to None.

Returns:

Box with the posterior samples.

Return type:

species.core.box.SamplesBox

list_companions(verbose: bool = False) List[str][source]#

Function for printing an overview of the companion data that are stored in the database. It will return a list with all the companion names. Each name can be used as input for ReadObject.

Parameters:

verbose (bool) – Print details on the companion data or list only the names of the companions for which data are available.

Returns:

List with the object names that are stored in the database.

Return type:

list(str)

list_content() None[source]#

Function for listing the content of the HDF5 database. The database structure will be descended while printing the paths of all the groups and datasets, as well as the dataset attributes.

Returns:

None

Return type:

NoneType

petitcode_param(tag: str, sample_type: str = 'median', json_file: str | None = None) Dict[str, float][source]#

Function for converting the median are maximum likelihood posterior parameters of petitRADTRANS into a dictionary of input parameters for petitCODE.

Parameters:
  • tag (str) – Database tag with the posterior samples.

  • sample_type (str) – Sample type that will be selected from the posterior (‘median’ or ‘probable’). Either the median or maximum likelihood parameters are used.

  • json_file (str, None) – JSON file to store the posterior samples. The data will not be written if the argument is set to None.

Returns:

Dictionary with parameters for petitCODE.

Return type:

dict

Module contents#