species.util package

Submodules

species.util.data_util module

Utility functions for data processing.

species.util.data_util.add_missing(model, parameters, database)[source]

Function for adding missing grid points by linearly interpolating the available grid points.

Parameters:
  • model (str) – Atmosphere model.
  • parameters (list(str, )) – Model parameters.
  • database (h5py._hl.files.File) – Database.
Returns:

None

Return type:

NoneType

species.util.data_util.correlation_to_covariance(cor_matrix, spec_sigma)[source]
Parameters:
  • cor_matrix (np.ndarray) – Correlation matrix of the spectrum.
  • spec_sigma (np.ndarray) – Uncertainties (W m-2 um-1).
Returns:

Covariance matrix of the spectrum.

Return type:

np.ndarrays

species.util.data_util.sort_data(param_teff, param_logg, param_feh, param_co, param_fsed, wavelength, flux)[source]
Parameters:
  • param_teff (np.ndarray) – Array with the effective temperature (K) of each spectrum.
  • param_logg (np.ndarray) – Array with the log10 surface gravity (cgs) of each spectrum.
  • param_feh (np.ndarray, None) – Array with the metallicity of each spectrum. Not used if set to None.
  • param_co (np.ndarray, None) – Array with the carbon-to-oxygen ratio of each spectrum. Not used if set to None.
  • param_fsed (np.ndarray, None) – Array with the sedimentation parameter of each spectrum. Not used if set to None.
  • wavelength (np.ndarray) – Array with the wavelengths (um).
  • flux (np.ndarray) – Array with the spectra (n_spectra, n_wavelengths).
Returns:

List with the unique values of the atmosphere parameters (each in a separate array), an array with the wavelengths, and a multidimensional array with the sorted spectra.

Return type:

list(np.ndarray, )

species.util.data_util.update_filter(filter_in)[source]

Function to update a filter ID from the Vizier Photometry viewer VOTable to the filter ID from the SVO Filter Profile Service.

Parameters:filter_in (str) – Filter ID in the format of the Vizier Photometry viewer.
Returns:Filter ID in the format of the SVO Filter Profile Service.
Return type:str
species.util.data_util.update_sptype(sptypes)[source]

Function to update a list with spectral types to two characters (e.g., M8, L3, or T1).

Parameters:sptypes (np.ndarray) – Input spectral types.
Returns:Updated spectral types.
Return type:np.ndarray
species.util.data_util.write_data(model, parameters, database, data_sorted)[source]

Function for writing the model spectra and parameters to the database.

Parameters:
  • model (str) – Atmosphere model.
  • parameters (list(str, )) – Model parameters.
  • database (h5py._hl.files.File) – Database.
  • data_sorted (list(np.ndarray, )) – Sorted model data with the parameter values, wavelength points (um), and flux densities (W m-2 um-1).
Returns:

None

Return type:

NoneType

species.util.phot_util module

Utility functions for photometry.

species.util.phot_util.absolute_to_apparent(abs_mag, distance)[source]

Function for converting an absolute magnitude into an apparent magnitude.

Parameters:
  • abs_mag (tuple(float, float), tuple(numpy.ndarray, numpy.ndarray)) – Absolute magnitude and uncertainty (mag). The same uncertainty is used for the apparent magnitude.
  • distance (tuple(float, float), tuple(numpy.ndarray, numpy.ndarray)) – Distance and uncertainty (pc).
Returns:

  • float, numpy.ndarray – Apparent magnitude (mag).
  • float, numpy.ndarray, None – Uncertainty (mag).

species.util.phot_util.apparent_to_absolute(app_mag, distance)[source]

Function for converting an apparent magnitude into an absolute magnitude. The uncertainty on the distance is propagated into the uncertainty on the absolute magnitude.

Parameters:
  • app_mag (tuple(float, float), tuple(numpy.ndarray, numpy.ndarray)) – Apparent magnitude and uncertainty (mag). The returned error on the absolute magnitude is set to None if the error on the apparent magnitude is set to None, for example app_mag=(15., None).
  • distance (tuple(float, float), tuple(numpy.ndarray, numpy.ndarray)) – Distance and uncertainty (pc). The error is not propagated into the error on the absolute magnitude if set to None, for example distance=(20., None).
Returns:

  • float, numpy.ndarray – Absolute magnitude (mag).
  • float, numpy.ndarray, None – Uncertainty (mag).

species.util.phot_util.get_residuals(datatype, spectrum, parameters, filters, objectbox, inc_phot=True, inc_spec=False, **kwargs_radtrans)[source]
Parameters:
  • datatype (str) – Data type (‘model’ or ‘calibration’).
  • spectrum (str) – Name of the atmospheric model or calibration spectrum.
  • parameters (dict) – Parameters and values for the spectrum
  • filters (tuple(str, )) – Filter IDs. All available photometry of the object is used if set to None.
  • objectbox (species.core.box.ObjectBox) – Box with the photometry and/or spectra of an object. A scaling and/or error inflation of the spectra should be applied with update_spectra() beforehand.
  • inc_phot (bool) – Include photometry.
  • inc_spec (bool) – Include spectrum.
Keyword Arguments:
 

kwargs_radtrans (dict) – Dictionary with the keyword arguments for the ReadRadtrans object, containing line_species, cloud_species, and scattering.

Returns:

Box with the photometry and/or spectrum residuals.

Return type:

species.core.box.ResidualsBox

species.util.phot_util.multi_photometry(datatype, spectrum, filters, parameters)[source]
Parameters:
  • datatype (str) – Data type (‘model’ or ‘calibration’).
  • spectrum (str) – Spectrum name (e.g., ‘drift-phoenix’).
  • filters (tuple(str, )) – Filter IDs.
  • parameters (dict) – Parameters and values for the spectrum
Returns:

Box with synthetic photometry.

Return type:

species.core.box.SynphotBox

species.util.plot_util module

Utility functions for plotting data.

species.util.plot_util.field_bounds_ticks(field_range)[source]
Parameters:field_range (tuple(str, str), None) – Range of the discrete colorbar for the field dwarfs. The tuple should contain the lower and upper value (‘early M’, ‘late M’, ‘early L’, ‘late L’, ‘early T’, ‘late T’, ‘early Y). The full range is used if set to None.
Returns:
  • np.ndarray
  • np.ndarray
  • list(str, )
species.util.plot_util.model_name(key)[source]
Parameters:key (str) –
Returns:
Return type:str
species.util.plot_util.quantity_unit(param, object_type)[source]
Parameters:
  • param (list) –
  • object_type (str) –
Returns:

  • list
  • list
  • list

species.util.plot_util.sptype_stellar(sptype, shape)[source]
Parameters:
  • sptype
  • shape
Returns:

Return type:

numpy.ndarray

species.util.plot_util.sptype_substellar(sptype, shape)[source]
Parameters:
  • sptype
  • shape
Returns:

Return type:

numpy.ndarray

species.util.plot_util.update_labels(param)[source]
Parameters:param (list) –
Returns:
Return type:list

species.util.query_util module

Text

class species.util.query_util.NoStdStreams(stdout=None, stderr=None)[source]

Bases: object

Text

species.util.query_util.get_distance(target)[source]
Parameters:target (str) – Target name.
Returns:
  • str – SIMBAD name.
  • tuple(float, float) – Distance and uncertainty (pc).
species.util.query_util.get_parallax()[source]
species.util.query_util.get_simbad(name)[source]

Function for getting the SIMBAD identifier of an object.

Parameters:name (numpy.ndarray) –
Returns:SIMBAD name.
Return type:numpy.ndarray

species.util.read_util module

Utility functions for reading data.

species.util.read_util.add_luminosity(modelbox)[source]

Function to add the luminosity of a model spectrum to the parameter dictionary of the box.

Parameters:modelbox (species.core.box.ModelBox) – Box with the model spectrum. Should also contain the dictionary with the model parameters, the radius in particular.
Returns:The input box with the luminosity added in the parameter dictionary.
Return type:species.core.box.ModelBox
species.util.read_util.get_mass(model_param)[source]
Parameters:model_param (dict) – Model parameter values. Should contain the surface gravity and radius.
Returns:Mass (Mjup).
Return type:float
species.util.read_util.smooth_spectrum(wavelength, flux, spec_res, size=11)[source]

Function to smooth a spectrum with a Gaussian kernel to a fixed spectral resolution. The kernel size is set to 5 times the FWHM of the Gaussian. The FWHM of the Gaussian is equal to the ratio of the wavelength and the spectral resolution. If the kernel does not fit within the available wavelength grid (i.e. at the edge of the array) then the flux values are set to NaN.

Parameters:
  • wavelength (numpy.ndarray) – Wavelength points (um). Should be sampled with a uniform spectral resolution or a uniform wavelength spacing (slow).
  • flux (numpy.ndarray) – Flux (W m-2 um-1).
  • spec_res (float) – Spectral resolution.
  • size (int) – Kernel size (odd integer).
Returns:

Smoothed spectrum (W m-2 um-1) at the same wavelength points as the input spectrum.

Return type:

numpy.ndarray

species.util.read_util.update_spectra(objectbox, model_param)[source]

Function for applying a best-fit scaling and/or error inflation to the spectra of an object.

Parameters:
  • objectbox (species.core.box.ObjectBox) – Box with the object’s data, including the spectra.
  • model_param (dict) – Model parameter values. Should contain the scaling and/or error inflation values.
Returns:

The input box with the scaled and/or error inflated spectra.

Return type:

species.core.box.ObjectBox

species.util.test_util module

Utility functions for running the unit tests.

species.util.test_util.create_config(test_path)[source]

Function for creating a configuration file in the test folder.

Parameters:test_path (str) – Folder where the unit tests are located.
Returns:None
Return type:NoneType

Module contents