TrapezoidFit
- class exovetter.trapezoid_fit.TrapezoidFit(time_series, data_series, error_series, trp_parameters=None, trp_originalestimates=None, trp_planetestimates=None, t_ratio=0.2, error_scale=1.0, logger=None)[source]
Bases:
object
Class to handle trapezoid fits.
- Parameters:
- time_series, data_series, error_seriesarray_like
Data, uncertainty, and time series.
- trp_parameters
TrapezoidFitParameters
orNone
Trapezoid fit parameters. If not given, defaults are used.
- trp_originalestimates
TrapezoidOriginalEstimates
orNone
Trapezoid fit original estimates. If not given, defaults are used.
- trp_planetestimates
TrapezoidOriginalEstimates
orNone
Trapezoid fit planet model estimates. If not given, defaults are used.
- t_ratiofloat
Value for
TRatio
inphysvals
.- error_scalefloat
Errorbars scaling for
trp_likehood()
residual calculation.- loggerobj
Python logger. If not given, default logger is used.
- Attributes:
- loggerobj
Logger.
- parm
TrapezoidFitParameters
Trapezoid fit parameters.
- origests
TrapezoidOriginalEstimates
Trapezoid fit original estimates.
- planetests
TrapezoidPlanetEstimates
Planet model estimates to be set in
trp_estimate_planet()
.- normlcarray_like
Data series (light curve).
- normesarray_like
Uncertainty of data series.
- normotsarray_like
Original time series.
- timezptfloat
Zeropoint of time series.
- normtsarray_like
Normalized time series.
- sampleitarray_like
Region for over-sampling.
- fitdataarray_like
Region for fitting.
- physvalsarray_like
Values corresponding to
physval_names
.- physval_minsarray_like
Minimum limits for
physvals
.- physval_maxsarray_like
Maximum limits for
physvals
.- physvalsavsarray_like
Store
physvals
parameters that are fixed during the calculation.- bestphysvalsarray_like
Best
physvals
to be calculated intrp_iterate_solution()
.- boundedvalsarray_like
Bounded version of
physvals
set inset_boundedvals()
.- boundedvalsavsarray_like
Store
boundedvals
parameters that are fixed during the calculation.- bestboundedvalsarray_like
Best
boundedvals
to be calculated intrp_iterate_solution()
.- fixedarray_like
Flags for whether a
physvals
element is fixed during fitting.- nparmint
Number of elements in
physvals
.- modellcarray_like
Trapezoid model to be set in
trapezoid_model()
.- error_scalefloat
Errorbars scaling for
trp_likehood()
residual calculation.- chi2minfloat
Best chi-squared to be set in
trp_iterate_solution()
.- likecountint
Number of times
trp_likehood()
was called.- minimizedbool
Flag of whether fitting has occured or not.
Attributes Summary
Description of stored
physval`
values.Methods Summary
plot_likehood
([show_legend])Plot results from
trp_likehood()
.Convert parameters to bounded versions that the minimizer will use.
Convert bounded parameter values that the minimizer uses to physical values.
trapezoid_fit
(time_series, data_series, ...)Perform a trapezoid fit to a normalized flux time series.
Generate a subsampled model at the current parameters.
trapezoid_model_onemodel
(ts, period, epoch, ...)Make a trapezoid model at the given input parameters.
trapezoid_model_raw
(epoch, depth, big_t, ...)Generate another model at a different epoch depth duration and ingress time.
Perform crude estimate of a planet model that is close to the trapezoid solution, which must be present for this to work.
trp_iterate_solution
([n_iter, method, ...])Perform multiple iterations starting from random initial conditions.
trp_likehood
(pars)Likelihood function used for Scipy optimizer.
Validate that trapezoid fit inputs look reasonable.
Attributes Documentation
- physval_names
Description of stored
physval`
values.
Methods Documentation
- plot_likehood(show_legend=False)[source]
Plot results from
trp_likehood()
.
- set_boundedvals()[source]
Convert parameters to bounded versions that the minimizer will use.
This sets
self.boundedvals
.- Raises:
- ValueError
Bounded values are invalid.
- set_physvals()[source]
Convert bounded parameter values that the minimizer uses to physical values.
This sets
self.physvals
.- Raises:
- ValueError
Physical values are invalid.
- classmethod trapezoid_fit(time_series, data_series, error_series, signal_period, signal_epoch, signal_duration, signal_depth, fit_trial_n=13, fit_region=4.0, error_scale=1.0, sample_n=15, seed=None)[source]
Perform a trapezoid fit to a normalized flux time series. Assumes all data has the same cadence duration. Period is fixed during the trapezoid fitting.
- Parameters:
- time_seriesarray_like
Mid cadence time stamps.
- data_seriesarray_like
Normalized time series.
- error_seriesarray_like
Uncertainty (error) time series.
- signal_periodfloat
Period of signal in days. Assumed fixed during model fitting.
- signal_epochfloat
Estimated epoch of signal in days. Must be on the same system as
time_series
.- signal_durationfloat
Estimated signal duration in hours.
- signal_depthfloat
Estimated signal depth in ppm.
- fit_trial_nint
How many trial fits to perform starting at random initial locations. Increase this if the minimization is returning local minima.
- fit_regionfloat
Fit data within
fit_region * signal_duration
ofsignal_epoch
.- error_scalefloat
Scale the errorbars by this factor.
- sample_nint
Subsample each cadence by this factor.
- seedint or
None
Seed for Numpy random generator. Usually used in testing for reproducibility.
- Returns:
- ioblk
TrapezoidFit
Instance storing all the information pertaining to fit results.
- ioblk
- trapezoid_model()[source]
Generate a subsampled model at the current parameters.
This sets
self.modellc
.- Raises:
- ValueError
Model generation failed.
- classmethod trapezoid_model_onemodel(ts, period, epoch, depth, big_t, little_t, subsamplen)[source]
Make a trapezoid model at the given input parameters.
You can save time if you want to generate many models by calling this once to generate the instance and then call
trapezoid_model_raw()
to generate the models at other inputs, thus bypassing some of the setup routines.- Parameters:
- tsarray_like
Mid-cadence time stamps.
- periodfloat
Period of signal. Assumed fixed during model generation.
- epochfloat
Estimated epoch of signal. Must be on the same system as
ts
.- depthfloat
Model depth in ppm.
- big_tfloat
Full transit duration in hours.
- little_tfloat
Ingress time in hours.
- subsamplenint
Subsample each cadence by this factor.
- Returns:
- ioblk
TrapezoidFit
Instance that is used in the transit model. It has model light curve in its
modellc
attribute.
- ioblk
- trapezoid_model_raw(epoch, depth, big_t, little_t)[source]
Generate another model at a different epoch depth duration and ingress time.
Run this after you have a pre-existing
TrapezoidFit
instance from fit or fromtrapezoid_model_onemodel()
.Note
Period is not variable at this point.
- Parameters:
- epochfloat
Estimated epoch of signal. Must be on the same system time series.
- depthfloat
Model depth in ppm.
- big_tfloat
Full transit duration in hours.
- little_tfloat
Ingress time in hours.
- Returns:
- ioblk
TrapezoidFit
New instance containing model light curve in its
modellc
attribute.
- ioblk
- trp_estimate_planet()[source]
Perform crude estimate of a planet model that is close to the trapezoid solution, which must be present for this to work.
This mainly sets
self.planetests
.
- trp_iterate_solution(n_iter=20, method='Powell', options=None, seed=None)[source]
Perform multiple iterations starting from random initial conditions. Attributes are updated in-place with the best solution in a chi-squared sense among the iterations.
- Parameters:
- n_iterint
Number of iterations to run.
- methodstr
- optionsdict or
None
See
scipy.optimize.minimize()
. If not given, some pre-defined defaults are used.- seedint or
None
Seed for Numpy random generator. Usually used in testing for reproducibility.