species.util package — species 0.1.2 documentation

# species.util package

## Submodules

## species.util.data_util module

Utility functions for data processing.

`species.util.data_util.` `add_missing`(model, parameters, database)

  Parameters: | model (str) – Atmosphere model. parameters (tuple(str, )) – Model parameters. database (h5py._hl.files.File) – Database.
  Returns: |
  Return type: | None

`species.util.data_util.` `sort_data`(teff, logg, feh, co, fsed, wavelength, flux)

  Parameters: | teff (numpy.ndarray) – logg (numpy.ndarray) – feh (numpy.ndarray, None) – co (numpy.ndarray, None) – fsed (numpy.ndarray, None) – wavelength (numpy.ndarray) – flux (numpy.ndarray) –
  Returns: |
  Return type: | tuple(numpy.ndarray, )

`species.util.data_util.` `update_filter`(filter_in)

  Function to update afilter 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)

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

  Parameters: | sptypes (numpy.ndarray) – Input spectral types.
  Returns: | Updated spectral types.
  Return type: | numpy.ndarray

`species.util.data_util.` `write_data`(model, parameters, database, data_sorted)

  Parameters: | model (str) – Atmosphere model. parameters (tuple(str, )) – Model parameters. database (h5py._hl.files.File) – Database. data_sorted (tuple(numpy.ndarray, )) –
  Returns: |
  Return type: | None

## species.util.phot_util module

Utility functions for photometry.

`species.util.phot_util.` `apparent_to_absolute`(app_mag, distance)

  Parameters: | app_mag (float or numpy.ndarray) – Apparent magnitude (mag). distance (float or numpy.ndarray) – Distance (pc).
  Returns: | Absolute magnitude (mag).
  Return type: | float or numpy.ndarray

`species.util.phot_util.` `get_residuals`(datatype, spectrum, parameters, filters, objectbox, inc_phot=True, inc_spec=False)

  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 spectrum of an object. inc_phot (bool) – Include photometry. inc_spec (bool) – Include spectrum.
  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)

  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)

  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)

  Parameters: | key (str) –
  Returns: |
  Return type: | str

`species.util.plot_util.` `quantity_unit`(param, object_type)

  Parameters: | param (list) – object_type (str) –
  Returns: | list list

`species.util.plot_util.` `sptype_stellar`(sptype, shape)

  Parameters: | sptype – shape –
  Returns: |
  Return type: | numpy.ndarray

`species.util.plot_util.` `sptype_substellar`(sptype, shape)

  Parameters: | sptype – shape –
  Returns: |
  Return type: | numpy.ndarray

`species.util.plot_util.` `update_labels`(param)

  Parameters: | param (list) –
  Returns: |
  Return type: | list

## species.util.read_util module

Utility functions for reading data.

`species.util.read_util.` `add_luminosity`(modelbox)

  Function to add the luminosity of a model spectrum to the parameter dictionary of the box. The luminosity is by default calculated at a spectral resolution of 1000.

  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)

  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)

  Function to convolve 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 the wavelength divided by 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 (micron). Should be equally-spaced. flux (numpy.ndarray) – Flux density (W m-2 micron-1). spec_res (float) – Spectral resolution size (int) – Kernel size (odd number).
  Returns: | Smoothed spectrum (W m-2 micron-1) at the same wavelength points as the input spectrum.
  Return type: | numpy.ndarray

## species.util.test_util module

Utility functions for running the unit tests.

`species.util.test_util.` `create_config`(test_path)

  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