sherlockpipe.bayesian_fit.fitter.Fitter

class sherlockpipe.bayesian_fit.fitter.Fitter(object_dir, fit_dir, only_initial, is_candidate_from_search, candidates_df, mcmc=False, detrend=None, estimate_noise=True, rho_err_multi=5.0, sigma_err_multi=5.0, yerr_err_multi=5.0, odd_even=False, odd_even_dir=None, odd_even_tolerance=None)

Bases: ToolWithCandidate

Used to run a bayesian fit on the Sherlock search results.

__init__(object_dir, fit_dir, only_initial, is_candidate_from_search, candidates_df, mcmc=False, detrend=None, estimate_noise=True, rho_err_multi=5.0, sigma_err_multi=5.0, yerr_err_multi=5.0, odd_even=False, odd_even_dir=None, odd_even_tolerance=None)

Initializes the Fitter with the search results and fit configuration.

Parameters

object_dirstr

The SHERLOCK object directory containing the search results.

fit_dirstr

The directory where the fit output will be written.

only_initialbool

If True, only the initial guess is computed without full sampling.

is_candidate_from_searchbool

Whether the candidates come from a SHERLOCK search.

candidates_dfpandas.DataFrame

DataFrame of candidate planets.

mcmcbool

If True, use MCMC sampling instead of nested sampling.

detrendstr or None

The detrend method used (e.g. ‘gp’, ‘hybrid_spline’).

estimate_noisebool

If True, estimate noise parameters from out-of-transit data.

rho_err_multifloat

Multiplier for the lnrho error in the normal distribution fit.

sigma_err_multifloat

Multiplier for the lnsigma error in the normal distribution fit.

yerr_err_multifloat

Multiplier for the yerr error in the normal distribution fit.

odd_evenbool

If True, run separate fits on odd and even transits.

odd_even_dirstr or None

Directory for odd/even transit fit results.

odd_even_tolerancefloat or None

Nested sampling tolerance for the odd/even fits.

Methods

__init__(object_dir, fit_dir, only_initial, ...)

Initializes the Fitter with the search results and fit configuration.

custom_plot(name, period, fit_width, ...[, mode])

Creates a custom fit plot from the allesfitter data

fill_candidate_params(candidate_row, ...)

Fills the candidate planet initial parameters and their distribution to be fit.

fill_candidates_params(candidate_df, ...[, ...])

Fills the candidate planets initial parameters and their distribution to be fit.

fill_instrument_params(star_df, detrend_mode)

Fills the star and systematics information for each instrument (so far only one)

fit(candidate_df, fit_candidate_df, star_df, ...)

Main method to run the alexfitter fit.

is_candidate_aware()

Boolean return to inform whether the candidate to be processed comes from SHERLOCK searches or is user-given.

mask_non_fit_candidates(time, flux, ...)

Masks all the candidates found in previous runs in the SHERLOCK search.

mask_previous_candidates(time, flux, ...)

Masks all the candidates found in previous runs in the SHERLOCK search.

overwrite_settings(settings_file, cpus, ...)

Writes the allesfitter settings CSV by filling template placeholders with the fit configuration.

select_fit_width(candidate_df)

Calculates the window to be used for the fit around the transits.

static custom_plot(name, period, fit_width, allesfit_dir, mode='posterior')

Creates a custom fit plot from the allesfitter data

Parameters:
  • name – the candidate name

  • period – the final period

  • fit_width – the fit_width window

  • allesfit_dir – the directory where allesfitter data is stred

  • mode – the allesfitter plot model

static fill_candidate_params(candidate_row, star_df, fit_orbit)

Fills the candidate planet initial parameters and their distribution to be fit.

Parameters:
  • candidate_row – the candidate row from the dataframe

  • star_df – the star dataframe

  • fit_orbit – whether to fit eccentricity and arg. of periastron.

Returns:

the allesfitter candidate parameters

fill_candidates_params(candidate_df, star_df, fit_orbit, detrend_mode, distribution: str = 'uniform', distribution_params: DistributionParams = None)

Fills the candidate planets initial parameters and their distribution to be fit.

Parameters:
  • candidate_df – the candidates dataframe

  • star_df – the star dataframe

  • fit_orbit – whether to fit eccentricity and arg. of periastron.

  • detrend_mode – type of detrend to be used

  • distribution – uniform or normal

  • distribution_params – the distribution parameters if known

Returns:

the allesfitter candidates parameters

fill_instrument_params(star_df, detrend_mode, distribution='uniform', distribution_params: DistributionParams = None)

Fills the star and systematics information for each instrument (so far only one)

Parameters:
  • star_df – the star dataframe

  • detrend_mode – type of detrend to be used

  • distribution – distribution: uniform or normal

:param distribution_params : if set, chooses the baseline fit values

Returns:

the allesfitter instrument params

fit(candidate_df, fit_candidate_df, star_df, cpus, allesfit_dir, tolerance, fit_orbit)

Main method to run the alexfitter fit.

Parameters:
  • candidate_df – the candidates dataframe to be used for noise estimation.

  • fit_candidate_df – the candidates dataframe to be used for the final fit.

  • star_df – the star dataframe.

  • cpus – the number of cpus to be used.

  • allesfit_dir – the directory for the fit to be run.

  • tolerance – the nested sampling tolerance threshold.

  • fit_orbit – whether to fit eccentricity and arg. of periastron.

is_candidate_aware()

Boolean return to inform whether the candidate to be processed comes from SHERLOCK searches or is user-given.

Returns:

boolean with the value

mask_non_fit_candidates(time, flux, flux_err, candidate_df, fit_candidate_df)

Masks all the candidates found in previous runs in the SHERLOCK search.

Parameters:
  • time – the time array

  • flux – the flux measurements array

  • flux_err – the flux error measurements array

  • candidate_df – the candidates used for noise estimation

  • fit_candidate_df – the candidates used for fit

Returns:

time, flux and flux_err with previous candidates in-transit data masked

mask_previous_candidates(time, flux, flux_err, candidate_id)

Masks all the candidates found in previous runs in the SHERLOCK search.

Parameters:
  • time – the time array

  • flux – the flux measurements array

  • flux_err – the flux error measurements array

  • candidate_id – the candidate number

Returns:

time, flux and flux_err with previous candidates in-transit data masked

overwrite_settings(settings_file, cpus, candidate_df, tolerance, boundaries='single', secondary_eclipse='True')

Writes the allesfitter settings CSV by filling template placeholders with the fit configuration.

Parameters

settings_filestr

Path to the settings CSV file to write.

cpusint

Number of CPU cores to use.

candidate_dfpandas.DataFrame

The candidate planets to include in the fit.

tolerancefloat

The nested sampling tolerance threshold.

boundariesstr

The fit boundaries mode (e.g. ‘single’, ‘multi’).

secondary_eclipsestr

Whether to fit a secondary eclipse (‘True’ or ‘False’).

static select_fit_width(candidate_df)

Calculates the window to be used for the fit around the transits.

Parameters:

candidate_df – the candidates dataframe

Returns:

the maximum calculated fit_width