Nested Sampling
Nested Main:
- ForMoSA.nested_sampling.nested_sampling.import_obsmod(global_params)[source]
Function to import spectra (model and data) before the inversion
- Parameters:
global_params (object) – Class containing every input from the .ini file.
- Returns:
- Return a list of lists with the wavelengths, flux, errors, covariance matrix,
transmission, star flux, systematics, grid indices and the grids for both spectroscopic and photometric data.
- Return type:
main_file (list(array))
Authors: Simon Petrus, Matthieu Ravet and Allan Denis
- ForMoSA.nested_sampling.nested_sampling.launch_nested_sampling(global_params)[source]
Function to launch the nested sampling. We first perform LogL function check-ups. Then the free parameters are counted and the data imported. Finally, depending on the nested sampling methode chosen in the config file, we perform the inversion. (Methods succesfully implemented are Nestle and PyMultinest)
- Parameters:
global_params (object) – Class containing every input from the .ini file.
- Returns:
None
Author: Simon Petrus and Matthieu Ravet
- ForMoSA.nested_sampling.nested_sampling.loglike(theta, theta_index, global_params, main_file, for_plot='no')[source]
Function that calculates the logarithm of the likelihood. The evaluation depends on the choice of likelihood. (If this function is used on the plotting module, it returns the outputs of the modif_spec function)
- Parameters:
theta (list) – Parameter values randomly picked by the nested sampling
theta_index (list) – Index for the parameter values randomly picked
global_params (object) – Class containing every input from the .ini file.
main_file (list(list)) – List containing the wavelengths, flux, errors, covariance, and grid information
for_plot (str) – Default is ‘no’. When this function is called from the plotting functions module, we use ‘yes’
- Returns:
Final evaluated loglikelihood for both spectra and photometry.
- Return type:
FINAL_logL (float)
Authors: Simon Petrus, Matthieu Ravet and Allan Denis
- ForMoSA.nested_sampling.nested_sampling.prior_transform(theta, theta_index, lim_param_grid, global_params)[source]
Function that define the priors to be used for the inversion. We check that the boundaries are consistent with the grid extension.
- Parameters:
theta (list) – Parameter values randomly picked by the nested sampling
theta_index (list) – Index for the parameter values randomly picked
lim_param_grid (list) – Boundaries for the parameters explored
global_params (object) – Class containing every input from the .ini file.
- Returns:
List containing all the prior information
- Return type:
prior (list)
Author: Simon Petrus, Matthieu Ravet, Allan Denis
Modify Spectra:
- ForMoSA.nested_sampling.nested_modif_spec.modif_spec(global_params, theta, theta_index, obs_dict, flx_mod_spectro, flx_mod_photo, wav_mod_spectro, res_mod_obs_spectro, indobs=0)[source]
Modification of the interpolated synthetic spectra with the different extra-grid parameters. It can perform : Re-calibration on the data, Doppler shifting, Application of a substellar extinction, Application of a rotational velocity, Application of a circumplanetary disk (CPD).
- Parameters:
global_params (object) – Class containing each parameter
theta (list) – Parameter values randomly picked by the nested sampling
theta_index (list) – Parameter index identificator
obs_dict (dict) – Dictionay containing all the observationnal entries (photometry, spectroscopy and/or optional)
flx_mod_spectro (array) – New flux of the interpolated synthetic spectrum (spectroscopy)
flx_mod_photo (array) – New flux of the interpolated synthetic spectrum (photometry)
wav_mod_spectro (array) – Wavelength array of the model (can be different from wav_obs_spectro)
res_mod_obs_spectro (array) – Spectroscopic resolution of the model interpolated onto wav_obs_spectro
indobs (int) – Index of the current observation looping
- Returns:
New dictionay containing all the observationnal entries (photometry, spectroscopy and/or optional) - flx_mod_spectro (array): New flux of the interpolated synthetic spectrum (spectroscopy) - flx_mod_photo (array): New flux of the interpolated synthetic spectrum (photometry) - flx_mod_spectro_nativ (array): New flux of the interpolated synthetic spectrum NOT RESAMPLED (spectroscopy) - contributions (array): Contributions from the high-contrast model - scale_spectro (float): Spectroscopic flux scaling factor - scale_photo (float): Photometric flux scaling factor
- Return type:
obs_dict (dict)
Author: Simon Petrus, Paulina Palma-Bifani, Allan Denis and Matthieu Ravet
Prior Functions:
- ForMoSA.nested_sampling.nested_prior_functions.gaussian_prior(prior_fct_arg, theta)[source]
Gaussian prior for nested sampling.
- Parameters:
prior_fct_arg (list) – Two-values list with uniform prior boundaries.
theta (list) – Parameter values randomly picked by the nested sampling
- Returns:
Evaluated prior
- Return type:
Evaluated (float)
Author: Simon Petrus
- ForMoSA.nested_sampling.nested_prior_functions.loguniform_prior(prior_fct_arg, theta)[source]
LogUniform prior for nested sampling.
- Parameters:
prior_fct_arg (list) – Two-values list with loguniform prior boundaries.
theta (list) – Parameter values randomly picked by the nested sampling
- Returns:
Evaluated prior
- Return type:
Evaluated (float)
Author: Simon Petrus
- ForMoSA.nested_sampling.nested_prior_functions.uniform_prior(prior_fct_arg, theta)[source]
Uniform prior for nested sampling.
- Parameters:
prior_fct_arg (list) – Two-values list with uniform prior boundaries.
theta (list) – Parameter values randomly picked by the nested sampling
- Returns:
Evaluated prior
- Return type:
Evaluated (float)
Author: Simon Petrus
Likelihood Functions:
- ForMoSA.nested_sampling.nested_logL_functions.logL_CCF_Brogi(flx_obs, flx_mod)[source]
Function to compute logL based on the CCF mapping from Brogi et al. 2019 under the assumption of gaussian and spectrally constant noise.
- Parameters:
flx_obs (array) – flux of the observation as a function of wavelength
flx_mod (array) – flux of the model as a function of wavelength
- Returns:
the loglikelihood value
- Return type:
logL (float)
Author: Matthieu Ravet
- ForMoSA.nested_sampling.nested_logL_functions.logL_CCF_Zucker(flx_obs, flx_mod)[source]
Function to compute logL based on the CCF mapping from Zucker 2003 under the assumption of gaussian and spectrally constant noise.
- Parameters:
flx_obs (array) – flux of the observation as a function of wavelength
flx_mod (array) – flux of the model as a function of wavelength
- Returns:
the loglikelihood value
- Return type:
logL (float)
Author: Matthieu Ravet
- ForMoSA.nested_sampling.nested_logL_functions.logL_CCF_custom(flx_obs, flx_mod, err_obs)[source]
Function to compute logL based on the custom CCF mapping from Me under the assumption of gaussian and spectrally constant noise.
- Parameters:
flx_obs (array) – flux of the observation as a function of wavelength
flx_mod (array) – flux of the model as a function of wavelength
err_obs (array) – errors of the observation as a function of wavelength
- Returns:
the loglikelihood value
- Return type:
logL (float)
Author: Matthieu Ravet
- ForMoSA.nested_sampling.nested_logL_functions.logL_chi2(delta_flx, err, log_det, full=False)[source]
Function to compute logL based on the upper limits chi2 under the assumption of gaussian and spectrally uncorrelated noise.
- Parameters:
delta_flx (array) – residual data-model as a function of wavelength
err (array) – error (=standard deviation) of the observed spectrum as a function of wavelength
log_det (float) – Log-determinant of the error bars
full (bool) – True or False to add the usual constant terms
- Returns:
the loglikelihood value
- Return type:
logL (float)
Author: Matthieu Ravet & Alice Radcliffe
- ForMoSA.nested_sampling.nested_logL_functions.logL_chi2_covariance(delta_flx, inv_cov, log_det, full=False)[source]
Function to compute logL based on the generalized chi2 under the assumption of gaussian and spectrally correlated noise.
- Parameters:
delta_flx (array) – residual data-model as a function of wavelength
inv_cov (n-array) – inverse of the covariance matrix of the observed spectrum as a function of wavelength
full (bool) – True or False to add the usual constant terms
log_det (float) – Log-determinant of the covariance matrix
- Returns:
the loglikelihood value
- Return type:
logL (float)
Author: Matthieu Ravet
- ForMoSA.nested_sampling.nested_logL_functions.logL_chi2_noisescaling(delta_flx, err, log_det, full=False)[source]
Function to compute logL based on the chi2 with a fitted noise scaling s (marginalized) under the assumption of gaussian and spectrally uncorrelated noise.
- Parameters:
delta_flx (array) – residual data-model as a function of wavelength
err (array) – error (=standard deviation) of the observed spectrum as a function of wavelength
full (bool) – True or False to add the usual constant terms
log_det (float) – Log-determinant of the error bars matrix
- Returns:
the loglikelihood value
- Return type:
logL (float)
Author: Allan Denis and Matthieu Ravet
- ForMoSA.nested_sampling.nested_logL_functions.logL_chi2_noisescaling_covariance(delta_flx, inv_cov, log_det, full=False)[source]
Function to compute logL based on the chi2 with a fitted noise scaling s (marginalized) under the assumption of gaussian and spectrally correlated noise.
- Parameters:
delta_flx (array) – residual data-model as a function of wavelength
inv_cov (n-array) – inverse of the covariance matrix of the observed spectrum as a function of wavelength
full (bool) – True or False to add the usual constant terms
log_det (float) – Log-determinant of the covariance matrix
- Returns:
the loglikelihood value
- Return type:
logL (float)
Author: Allan Denis and Matthieu Ravet
High-contrast Models:
- ForMoSA.nested_sampling.nested_highcont_models.hc_model(global_params, obs_dict, flx_mod_spectro, indobs)[source]
For high-contrast companions, where the star speckles signal contaminate the data
- Parameters:
global_params (object) – Class containing each parameter used in ForMoSA
obs_dict (dict) – Dictionay containing all the observationnal entries (photometry, spectroscopy and/or optional)
flx_mod_spectro (array) – Model flux of the companion
indobs (int) – Index of the current observation loop
- Returns:
Results of the high-constrast model - flx_mod_spectro (array): Model of the high-constrast model - flx_mod_spectro (array): Model of the high-constrast model - speckles (array): Speckles contribution
- Return type:
contributions (array)
Authors: Allan Denis
- ForMoSA.nested_sampling.nested_highcont_models.hc_model_estimate_speckles(flx_obs_spectro, flx_cont_obs_spectro, star_flx_obs_spectro, star_flx_cont_obs_spectro, flx_mod_spectro, flx_cont_mod_spectro, err, bounds, system_obs_spectro)[source]
high-constrast model of planet and star contributions
- Parameters:
flx_obs_spectro (array) – Flux of the data
flx_cont_obs_spectro (array) – Continuum of the data
star_flx_obs_spectro (array) – Flux of the star data
star_flx_cont_obs_spectro (array) – Continuum of the star data
flx_mod_spectro (array) – Model of the companion
flx_cont_mod_spectro (array) – Continuum of the model of the companion
weights (array) – Weights to apply to the data
bounds (tuple) – Bounds to be applied to the estimated parameters
system_obs_spectro (array) – Systematics
- Returns:
Results of the high-constrast model - flx_mod_spectro (array): Model of the high-constrast model - speckles (array): Speckles contribution
- Return type:
results.x (array)
Authors: Allan Denis
- ForMoSA.nested_sampling.nested_highcont_models.hc_model_remove_speckles(flx_obs_spectro, flx_cont_obs_spectro, star_flx_obs_spectro, star_flx_cont_obs_spectro, flx_mod_spectro, flx_cont_mod_spectro, err_obs_spectro)[source]
high-constrast
- Parameters:
flx_obs_spectro (array) – Flux of the data
flx_cont_obs_spectro (array) – Continuum of the data
star_flx_obs_spectro (array) – Flux of the star data
star_flx_cont_obs_spectro (array) – Continuum of the star data
flx_mod_spectro (array) – Model of the companion
flx_cont_mod_spectro (array) – Continuum of the model of the companion
err_obs_spectro (array) – Noise of the data
- Returns:
High-resolution content of planet model - speckles (array): Speckles contribution - systematics (float): Not taken into account here
- Return type:
flx_mod_spectro (array)
Authors: Allan Denis