exo_k.fit

@author: jeremy leconte

This module contain classes to fit a spectrum

Module Contents

class exo_k.fit.Fit(spectrum_to_fit=None, uncertainties=None, fitting_parameters=None, **kwargs)[source]

Bases: object

Class to fit spectra

Initialization method.

cost_function = None
atm = None
N_iter = 0
spectrum_to_fit = None
init_atmosphere(composition=None, Mp=None, **kwargs)[source]

initializes atmospheric model

Parameters:

Mp (float) – Mass of the planet in Kg.

set_fitting_parameters(fitting_parameters=None)[source]
Parameters:

fitting_paramaters (list of str) – The parameters to fit. Must be in T, Rp, logx_MOL

set_spectrum_to_fit(spectrum_to_fit=None, uncertainties=None)[source]
Parameters:
  • spectrum_to_fit (Spectrum object) – The spectrum to fit

  • uncertainties (float or array) – The uncertainty on each spectral point.

plot_spectrum_to_fit(ax, capsize=0, fmt='k.', ecolor='.7', ylabel='Depth', xlabel='Wavelength', **kwargs)[source]

Plots the spectrum that is fitted with uncertainties

transmission_spectrum(parameters, rebin_spectrum=False, **kwargs)[source]

Method to compute the spectrum with a new set of parameters

set_cost_function()[source]

Defines the cost (or merit) function to minimize.

set_progress_report(Nprint=None)[source]
minimize(initial_guess=None, bounds=None, method='Nelder-Mead', verbose=False, tol=0.1, Nprint=None, **kwargs)[source]

Minimizes the cost function over the fitting parameters.

Parameters:
  • initial_guess (list) – Initial value for the fitting parameters. Must be in the order declared in fitting_parameters.

  • bounds (list or 2-value arrays) – Lower and upper values for the parameters. Must be in the order declared in fitting_parameters.

  • method (str) – Method used for minimization. For now, only ‘Nelder-Mead’ seems to handle bounds and yield relatively good results.

  • tol (float) – tolerance transmitted to sciopt.minimize

best_fit()[source]

Output last fit results in a dictionary

best_fit_spectrum(rebin_spectrum=False)[source]

Returns the spectrum computed with the best fit parameters

contributions(rebin_spectrum=False)[source]

Computes a spectrum with each molecule contribution

set_log_likelihood()[source]

Defines the log likelihood.

set_bounds(bounds=None)[source]
set_prior_transform(bounds=None)[source]

Defines the piors.

sample(bounds=None, method='single', npoints=10, maxcall=None, verbose=False, **kwargs)[source]

Minimizes the cost function over the fitting parameters.

Parameters:
  • initial_guess (list) – Initial value for the fitting parameters. Must be in the order declared in fitting_parameters.

  • bounds (list or 2-value arrays) – Lower and upper values for the parameters. Must be in the order declared in fitting_parameters.

  • method (str) – Method used for minimization. For now, only ‘Nelder-Mead’ seems to handle bounds and yield relatively good results.

  • tol (float) – tolerance transmitted to sciopt.minimize