species.analysis package

Submodules

species.analysis.fit_model module

Module with functionalities for fitting atmospheric model specra.

class species.analysis.fit_model.FitModel(object_name, filters, model, bounds, inc_phot=True, inc_spec=True)[source]

Bases: object

Class for fitting atmospheric model spectra to photometric data.

Parameters:
  • object_name (str) – Object name in the database.
  • filters (tuple(str, )) – Filter IDs for which the photometry is selected. All available photometry of the object is selected if set to None.
  • model (str) – Atmospheric model.
  • bounds (dict) – Parameter boundaries. Full parameter range is used if set to None or not specified. The radius parameter range is set to 0-5 Rjup if not specified.
  • inc_phot (bool) – Include photometry data with the fit.
  • inc_spec (bool) – Include spectral data with the fit.
Returns:

None

Return type:

NoneType

run_mcmc(nwalkers, nsteps, guess, tag, prior=None, weighting=None)[source]

Function to run the MCMC sampler.

Parameters:
  • nwalkers (int) – Number of walkers.
  • nsteps (int) – Number of steps per walker.
  • guess (dict) – Guess for the parameter values. Random values between the boundary values are used if set to None.
  • tag (str) – Database tag where the MCMC samples are stored.
  • prior (tuple(str, float, float)) – Gaussian prior on one of the parameters. Currently only possible for the mass, e.g. (‘mass’, 13., 3.) for an expected mass of 13 Mjup with an uncertainty of 3 Mjup. Not used if set to None.
  • weighting (float, None) – Weighting applied to the spectrum when calculating the likelihood function in order to not have a spectrum dominate the chi-squared value. For example, with weighting=3 then all combined spectrum points (e.g. covering the YJH bandpasses) have a weighted that is equal to three photometry points. The spectrum data points have an equal weighting as the photometry points if set to None.
Returns:

None

Return type:

NoneType

species.analysis.fit_model.lnlike(param, modelpar, modelphot, objphot, synphot, distance, spectrum, modelspec, weighting)[source]

Internal function for the likelihood probability.

Parameters:
  • param (numpy.ndarray) – Parameter values.
  • modelpar (list(str, )) – Parameter names.
  • modelphot (list('species.read.read_model.ReadModel, )) –
  • objphot (list(tuple(float, float), )) –
  • synphot (list(species.analysis.photometry.SyntheticPhotometry, )) –
  • distance (float) – Distance (pc).
  • spectrum (numpy.ndarray) – Wavelength (micron), apparent flux (W m-2 micron-1), and flux error (W m-2 micron-1).
  • modelspec (species.read.read_model.ReadModel) –
  • weighting (float, None) – Weighting applied to the spectrum when calculating the likelihood function in order to not have a spectrum dominate the chi-squared value. For example, with weighting=3 then all combined spectrum points (e.g. covering the YJH bandpasses) have a weighted that is equal to three photometry points. The spectrum data points have an equal weighting as the photometry points if set to None.
Returns:

Log likelihood probability.

Return type:

float

species.analysis.fit_model.lnprior(param, bounds, modelpar, prior=None)[source]

Internal function for the prior probability.

Parameters:
  • param (numpy.ndarray) – Parameter values.
  • bounds (dict) – Parameter boundaries.
  • modelpar (list(str, )) – Parameter names.
  • prior (tuple(str, float, float), None) – Gaussian prior on one of the parameters. Currently only possible for the mass, e.g. (‘mass’, 13., 3.) for an expected mass of 13 Mjup with an uncertainty of 3 Mjup. Not used if set to None.
Returns:

Log prior probability.

Return type:

float

species.analysis.fit_model.lnprob(param, bounds, modelpar, modelphot, objphot, synphot, distance, prior, spectrum, modelspec, weighting)[source]

Internal function for the posterior probability.

Parameters:
  • param (numpy.ndarray) – Parameter values.
  • bounds (dict) – Parameter boundaries.
  • modelpar (list(str, )) – Parameter names.
  • modelphot (list('species.read.read_model.ReadModel, )) –
  • objphot (list(tuple(float, float), )) –
  • synphot (list(species.analysis.photometry.SyntheticPhotometry, )) –
  • distance (float) – Distance (pc).
  • prior (tuple(str, float, float)) – Gaussian prior on one of the parameters. Currently only possible for the mass, e.g. (‘mass’, 13., 3.) for an expected mass of 13 Mjup with an uncertainty of 3 Mjup. Not used if set to None.
  • spectrum (numpy.ndarray) – Wavelength (micron), apparent flux (W m-2 micron-1), and flux error (W m-2 micron-1).
  • modelspec (species.read.read_model.ReadModel) –
  • weighting (float, None) – Weighting applied to the spectrum when calculating the likelihood function in order to not have a spectrum dominate the chi-squared value. For example, with weighting=3 then all combined spectrum points (e.g. covering the YJH bandpasses) have a weighted that is equal to three photometry points. The spectrum data points have an equal weighting as the photometry points if set to None.
Returns:

Log posterior probability.

Return type:

float

species.analysis.fit_planck module

Module with functionalities for fitting a Planck spectrum.

class species.analysis.fit_planck.FitPlanck(object_name, filters, bounds, inc_phot=True, inc_spec=True)[source]

Bases: object

Class for fitting Planck spectra to spectral and photometric data.

Parameters:
  • object_name (str) – Object name in the database.
  • filters (tuple(str, )) – Filter names for which the photometry is selected. All available photometry of the object are used if set to None.
  • bounds (dict) – Parameter boundaries for ‘teff’ and ‘radius’. The values should be provided either as float or as list of floats such that multiple Planck functions can be combined, e.g. {'teff': [(1000., 2000.), (500., 1500.)], 'radius': [(0.5, 1.5), (1.5, 2.0)]}.
  • inc_phot (bool) – Include photometry data with the fit.
  • inc_spec (bool) – Include spectral data with the fit.
Returns:

None

Return type:

NoneType

run_mcmc(nwalkers, nsteps, guess, tag, weighting=None)[source]

Function to run the MCMC sampler.

Parameters:
  • nwalkers (int) – Number of walkers.
  • nsteps (int) – Number of steps per walker.
  • guess (dict, None) – Guess for the ‘teff’ and ‘radius’. Random values between the boundary values are used if a value is set to None. The values should be provided either as float or in a list of floats such that multiple Planck functions can be combined, e.g. {'teff': [1500., 1000.], 'radius': [1., 2.].
  • tag (str) – Database tag where the MCMC samples are stored.
  • weighting (float, None) – Weighting applied to the spectrum when calculating the likelihood function in order to not have a spectrum dominate the chi-squared value. For example, with weighting=3 then all combined spectrum points (e.g. covering the YJH bandpasses) have a weighted that is equal to three photometry points. The spectrum data points have an equal weighting as the photometry points if set to None.
Returns:

None

Return type:

NoneType

species.analysis.fit_planck.lnlike(param, bounds, objphot, synphot, distance, spectrum, weighting)[source]

Internal function for the likelihood probability.

Parameters:
  • param (numpy.ndarray) – Parameter values.
  • bounds (dict) – Parameter boundaries for ‘teff’ and ‘radius’. The values should be provided in a list such that multiple Planck functions can be combined, e.g. {'teff': [(1000., 2000.), (500., 1500.)], 'radius': [(0.5, 1.5), (1.5, 2.0)]}.
  • objphot (list(tuple(float, float), )) – List with the photometric fluxes and uncertainties.
  • synphot (list(species.analysis.photometry.SyntheticPhotometry, )) – List with the SyntheticPhotometry objects for calculation of synthetic photometry from the model spectra.
  • distance (float) – Distance (pc).
  • spectrum (numpy.ndarray, None) – Spectrum array with the wavelength (micron), flux (W m-2 micron-1), and error (W m-2 micron-1). Not used if set to None.
  • weighting (float, None) – Weighting applied to the spectrum when calculating the likelihood function in order to not have a spectrum dominate the chi-squared value. For example, with weighting=3 then all combined spectrum points (e.g. covering the YJH bandpasses) have a weighted that is equal to three photometry points. The spectrum data points have an equal weighting as the photometry points if set to None.
Returns:

Log likelihood probability.

Return type:

float

species.analysis.fit_planck.lnprior(param, bounds)[source]

Internal function for the prior probability.

Parameters:
  • param (numpy.ndarray) – Parameter values.
  • bounds (dict) – Parameter boundaries for ‘teff’ and ‘radius’. The values should be provided in a list such that multiple Planck functions can be combined, e.g. {'teff': [(1000., 2000.), (500., 1500.)], 'radius': [(0.5, 1.5), (1.5, 2.0)]}.
Returns:

Log prior probability.

Return type:

float

species.analysis.fit_planck.lnprob(param, bounds, objphot, synphot, distance, spectrum, weighting)[source]

Internal function for the posterior probability.

Parameters:
  • param (numpy.ndarray) – Parameter values.
  • bounds (dict) – Parameter boundaries for ‘teff’ and ‘radius’. The values should be provided in a list such that multiple Planck functions can be combined, e.g. {'teff': [(1000., 2000.), (500., 1500.)], 'radius': [(0.5, 1.5), (1.5, 2.0)]}.
  • objphot (list(tuple(float, float), )) – List with the photometric fluxes and uncertainties.
  • synphot (list(species.analysis.photometry.SyntheticPhotometry, )) – List with the SyntheticPhotometry objects for calculation of synthetic photometry from the model spectra.
  • distance (float) – Distance (pc).
  • spectrum (numpy.ndarray, None) – Spectrum array with the wavelength (micron), flux (W m-2 micron-1), and error (W m-2 micron-1). Not used if set to None.
  • weighting (float, None) – Weighting applied to the spectrum when calculating the likelihood function in order to not have a spectrum dominate the chi-squared value. For example, with weighting=3 then all combined spectrum points (e.g. covering the YJH bandpasses) have a weighted that is equal to three photometry points. The spectrum data points have an equal weighting as the photometry points if set to None.
Returns:

Log posterior probability.

Return type:

float

species.analysis.fit_spectrum module

Module with functionalities for fitting a calibration spectrum.

class species.analysis.fit_spectrum.FitSpectrum(object_name, filters, spectrum, bounds)[source]

Bases: object

Class for fitting a calibration spectrum to photometric data.

Parameters:
  • object_name (str) – Object name in the database.
  • filters (tuple(str, )) – Filter IDs for which the photometry is selected. All available photometry of the object is selected if set to None.
  • spectrum (str) – Calibration spectrum.
  • bounds (dict) – Boundaries of the scaling parameter, as {‘scaling’:(min, max)}.
Returns:

Return type:

None

run_mcmc(nwalkers, nsteps, guess, tag, bands=False)[source]

Function to run the MCMC sampler.

Parameters:
  • nwalkers (int) – Number of walkers.
  • nsteps (int) – Number of steps per walker.
  • guess (dict) – Guess of the scaling parameter.
  • tag (str) – Database tag where the MCMC samples are stored.
  • bands (bool) – Use band-dependent scaling parameters in addition to the main scaling parameter which is used for the full spectrum.
Returns:

Return type:

None

species.analysis.fit_spectrum.lnprob(param, bounds, modelpar, objphot, specphot, bands)[source]

Internal function for the posterior probability.

Parameters:
  • param (numpy.ndarray) – Values of the main scaling parameter and optionally additional band-dependent scaling parameters.
  • bounds (dict) – Boundaries of the main scaling parameter.
  • modelpar (list(str, )) – Parameter names.
  • objphot (list(tuple(float, float), )) – Photometry of the object.
  • specphot (list(float, )) – Synthetic photometry of the calibration spectrum for the same filters as the photometry of the object.
  • bands (bool) – Use band-dependent scaling parameters in addition to the main scaling parameter which is used for the full spectrum.
Returns:

Log posterior probability.

Return type:

float

species.analysis.photometry module

Module with functionalities for calculating synthetic photometry.

class species.analysis.photometry.SyntheticPhotometry(filter_name)[source]

Bases: object

Class for calculating synthetic photometry from a spectrum.

Parameters:filter_name (str) – Filter ID as listed in the database. Filters from the SVO Filter Profile Service are automatically downloaded and added to the database.
Returns:None
Return type:NoneType
flux_to_magnitude(flux, distance)[source]

Function for converting a flux density to a magnitude.

Parameters:
  • flux (float) – Flux density (W m-2 micron-1).
  • distance (float) – Distance (pc).
Returns:

  • float – Apparent magnitude (mag).
  • float – Absolute magnitude (mag).

magnitude_to_flux(magnitude, error=None, zp_flux=None)[source]

Function for converting a magnitude to a flux density.

Parameters:
  • magnitude (float) – Magnitude (mag).
  • error (float, None) – Error (mag). Not used if set to None.
  • zp_flux (float) – Zero-point flux density (W m-2 micron-1). The value is calculated if set to None.
Returns:

  • float – Flux density (W m-2 micron-1).
  • float – Error (W m-2 micron-1).

spectrum_to_flux(wavelength, flux, threshold=None)[source]

Function for calculating the average flux density from a spectrum and a filter profile.

Parameters:
  • wavelength (numpy.ndarray, list(numpy.ndarray)) – Wavelength points (micron) provided as a 1D array or a list of 1D arrays.
  • flux (numpy.ndarray, list(numpy.ndarray)) – Flux density (W m-2 micron-1) provided as a 1D array or a list of 1D arrays.
  • threshold (float, None) – Transmission threshold (value between 0 and 1). If the minimum transmission value is larger than the threshold, a NaN is returned. This will happen if the input spectrum does not cover the full wavelength range of the filter profile. Not used if set to None.
Returns:

Average flux density (W m-2 micron-1).

Return type:

float, numpy.ndarray

spectrum_to_magnitude(wavelength, flux, distance=None, threshold=None)[source]

Function for calculating the apparent and absolute magnitude from a spectrum and a filter profile.

Parameters:
  • wavelength (numpy.ndarray, list(numpy.ndarray)) – Wavelength points (micron) provided as a 1D array or a list of 1D arrays.
  • flux (numpy.ndarray, list(numpy.ndarray)) – Flux density (W m-2 micron-1) provided as a 1D array or a list of 1D arrays.
  • distance (float, None) – Distance (pc). No absolute magnitude is calculated if set to None.
  • threshold (float, None) – Transmission threshold (value between 0 and 1). If the minimum transmission value is larger than the threshold, a NaN is returned. This will happen if the input spectrum does not cover the full wavelength range of the filter profile. Not used if set to None.
Returns:

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

zero_point()[source]

Internal function for calculating the zero-point of the provided filter_name.

Returns:Zero-point flux density (W m-2 micron-1).
Return type:float

Module contents