MonoTools package¶
Submodules¶
MonoTools.fit module¶
- class MonoTools.fit.monoModel(ID, mission, lc=None, rvs=None, planets=None, overwrite=False, savefileloc=None, **kwargs)¶
Bases:
object
The core MonoTools model class
- Raises
ValueError – [description]
- Returns
[description]
- Return type
[type]
- CheckPeriodsHaveGaps(pers, tdur, tcen, tcen_2=None, coverage_thresh=0.15)¶
Checking a list of potential periods and seeing if period are observed by counting the number of points in-transit
- Parameters
pers (list) – List of potential periods (e.g. for each Duotransit alias)
tdur (float) – Transit duration (days)
tcen (float) – Epoch of first transit (days)
tcen_2 (float, optional) – Epoch of second transit (days). Defaults to None.
coverage_thresh (float, optional) – Threshhold below which we say no transit was observed. Defaults to 0.15.
- Returns
Boolean array specifying which of the input period list is observed.
- Return type
array
- CheopsPlanetPropertiesTable(planet=None)¶
Create output compatible with the Cheops “PlanetPropertiesTable”. Not yet implemented
- Parameters
planet (str, optional) – string name of planet. Defaults to None.
- GP_training(n_draws=900, max_len_lc=25000, use_binned=False)¶
Function to train GPs on out-of-transit photometry
- Parameters
n_draws (int, optional) – Number of draws from sample. Defaults to 900.
max_len_lc (int, optional) – Maximum length of lightcurve to use (limiting to a few 1000 helps with compute time). Defaults to 25000.
uselc (bool, optional) – Specify lightcurve to use. Defaults to None, which takes the mod.lc light curve.
- GetSavename(how='load', overwrite=None)¶
Adds unique savename prefixes to class (self.savenames) with two formats: ‘[savefileloc]/[T/K]IC[11-number ID]_[20YY-MM-DD]_[n]…’ ‘[savefileloc]/[T/K]IC[11-number ID]_[n]…’
- Parameters
how (str, optional) – ‘load’ or ‘save’. Defaults to ‘load’.
overwrite (bool, optional) – if how=’save’, whether to overwrite past save or not. Defaults to None.
- LoadModelFromFile(loadfile=None)¶
Load a monoModel object direct from file.
- Parameters
loadfile (str, optional) – File to load from, otherwise it takes the default location using GetSavename. Defaults to None.
- Returns
Whether the load is successful
- Return type
bool
- LoadPickle(loadname=None)¶
Load data from saved pickle
- Parameters
loadname (str, optional) – Filename to load from. Defaults to None, which loads from savenames
- MakeCheopsOR(DR2ID, pl=None, min_eff=45, oot_min_orbits=1.0, timing_sigma=3, t_start=None, t_end=None, Texp=None, max_orbits=14, min_pretrans_orbits=0.5, min_intrans_orbits=None, orbits_flex=1.4, observe_threshold=0.018, max_ORs=None, prio_1_threshold=0.25, prio_3_threshold=0.0, min_orbits=4.0, outfilesuffix='_output_ORs.csv')¶
- Given a list of observable transits (which are outputted from trace_to_cheops_transits),
create a csv which can be run by pycheops make_xml_files to produce input observing requests (both to FC and observing tool).
- Parameters
DR2ID (int) – Gaia DR2 ID
pl (str, optional) – name of planet in self.planets dict to process. Defaults to None, i.e. assumes all planets)
min_eff (int, optional) – minimum efficiency in percent. Defaults to 45
oot_min_orbits (int, optional) – minimum number of out-of-transit orbits to include both before & after (this may be higher if timing uncertainty is worse). Defaults to 2.
timing_sigma (float,optional) – Number of uncertainty
t_start (float, optional) – time of start of Cheops observations, in same jd as model (e.g. TESS HJD BJD-2457000). Defaults to None.
t_end (float, optional) – time of end of Cheops observations, in same jd as model (e.g. TESS HJD BJD-2457000). Defaults to None.
Texp (float, optional) – Exposure Time of CHEOPS observations. Defaults to None, i.e. generated by PyCheops
max_orbits (float, optional) – Maximum number of orbits per visit. Defaults to 14 (i.e. 1d)
min_pretrans_orbits (float, optional) – Number of orbits to insist happen before (and after) transit, rather than either before/after (as with oot_min_orbits). Defaults to 0.5
min_intrans_orbits (float, optional) – In the case that the visit duration does not cover the full transit, this tells us how much of the transit we have to observe
orbits_flex (float, optional) – Flexibility in orbits. Defaults to None
observe_threshold (float, optional) – threshold above which to create ORs Default=0.018. Defaults to 0.018.
prio_1_threshold (float, optional) – Rough percentage of ORs we want to make P1 on Cheops. Defaults to 0.25.
prio_3_threshold (float, optional) – Rough percentage of ORs we want to make P3 on Cheops. Defaults to 0.0 - i.e. no P3 observations
min_orbits (float, optional) – Minimum number of total orbits to observe. Defaults to 4.0.
outfilesuffix (str, optional) – suffix place to save CSV. Defaults to ‘_output_ORs.csv’.
- Returns
panda DF to save as csv in location where one can run make_xml_files. e.g. make_xml_files output.csv –auto-expose -f
- Return type
df = model.PredictFutureTransits
- MakeTable(short=True, save=True, cols=['all'])¶
Make table from MCMC Samples
- Parameters
short (bool, optional) – Create “short” table (i.e. without hyperparameters). Defaults to True.
save (bool, optional) – Save to csv? Defaults to True.
cols (list, optional) – [‘all’] or list of selected column names. Defaults to [‘all’].
- Returns
Dataframe of parameters and specific parameters for the samples
- Return type
pandas DataFrame
- Plot(interactive=False, n_samp=None, overwrite=False, interp=True, newgp=False, return_fig=False, max_gp_len=20000, save=True, plot_loc=None, palette=None, plot_flat=False, pointcol='k', plottype='png', plot_rows=None, ylim=None)¶
Varied photometric plotting function for MonoTransit model
- Parameters
interactive (bool, optional) – Plot interactive bokeh image? Defaults to False i.e. matplotlib plot
n_samp (int, optional) – Number of samples to use to initialise the RV plotting. Defaults to 300.
overwrite (bool, optional) –
interp (bool, optional) Whether to interpolate the GP fits to create GP timeseries for all t (bin_oot must be True) –
newgp (bool, optional) –
return_fig (bool, optional) –
max_gp_len (int, optional) – Maximum length of photometric data to . Defaults to 20000.
save (bool, optional) –
bin_gp (bool, optional) – Bin GP or use raw x points? Defaults to True.
plot_loc (str, optional) – File location to plot. Defaults to None, which uses mod.savenames
palette ([str, optional) – Colour palette to plot with. Defaults to None.
plot_flat (bool, optional) – Plot flatted lightcurve instead of “raw”. Defaults to True.
pointcol (str, optional) – Point colour of smallest points. Defaults to “k”.
plottype (str, optional) – Type of image to save. Defaults to ‘png’.
- Returns
[description]
- Return type
[type]
- PlotCorner(corner_vars=None, use_marg=True, truths=None)¶
Create Corner plot for MCMC samples
- Parameters
corner_vars (list, optional) – List of parameter names to include. Defaults to None, which uses stellar density & various important orbital params.
use_marg (bool, optional) – Use marginalised parameters (e.g. weighted average across all aliases) or individual alias values. Defaults to True.
truths (list, optional) – “True” parameters for the selected parameters (e.g. for use in testing/comparisons). Defaults to None.
- PlotPeriods(plot_loc=None, ylog=True, nbins=25, pmax=None, pmin=None, ymin=None, ymax=None, xlog=False)¶
Plot Marginalised probabilities of the possible periods
- Parameters
plot_loc (str, optional) – File location. Defaults to None, which takes location from savenames
ylog (bool, optional) – Set y axis as log scale? Defaults to True.
nbins (int, optional) – Number of total bins . Defaults to 25.
pmax (float, optional) – Max period on plot. Defaults to None.
pmin (float, optional) – Min period on plot. Defaults to None.
ymin (float, optional) – Minimum on y axis (logprob). Defaults to None.
ymax (float, optional) – Max on y axis (logprob). Defaults to None.
xlog (bool, optional) – Set x axis (period) to log scale? Defaults to False.
- PlotRVs(interactive=False, plot_alias='best', nbest=4, n_samp=300, overwrite=False, return_fig=False, plot_resids=False, plot_loc=None, palette=None, pointcol='k', plottype='png', raster=False, nmargtoplot=0, save=True)¶
Varied plotting function for RVs of MonoTransit model
- Parameters
interactive (bool, optional) – Plot interactive bokeh image? Defaults to False i.e. matplotlib plot
plot_alias (str, optional) – How to plot RV aliaes - ‘all’ or ‘best’. Defaults to ‘best’.
nbest (int, optional) – Number of the best aliases to plot. Defaults to 4.
n_samp (int, optional) – Number of samples to use to initialise the RV plotting. Defaults to 300.
overwrite (bool, optional) –
return_fig (bool, optional) –
plot_resids (bool, optional) –
plot_loc ([type], optional) – [description]. Defaults to None.
palette (str, optional) – colour palette to use. Defaults to None.
pointcol (str, optional) – small point colour to use. Defaults to ‘k’.
plottype (str, optional) – Type of image to save, if not interactive. Defaults to ‘png’.
raster (bool, optional) – Whether to rasterize the image to reduce file size. Defaults to False.
nmargtoplot (int, optional) – Which marginalised planet (Mono/Duo) to plot. Defaults to 0, i.e. first planet
save (bool, optional) –
- Raises
ValueError – [description]
- PlotTable(plot_loc=None, return_table=False)¶
Plot table as PDF (i.e. to assemble PDF report)
- Parameters
plot_loc (str, optional) – File location. Defaults to None, which uses mod.savenames
return_table (bool, optional) – Return DF figure? Defaults to False.
- Returns
Dataframe of parameters and specific parameters (output from MakeTable)
- Return type
pandas DataFrame
- PredictFutureTransits(time_start, time_end, include_multis=True)¶
Return a dataframe of potential transits of all Duo candidates between time_start & time_end dates.
- Parameters
time_start (Astropy.Time object or float) – Astropy.Time date or julian date (in same base as lc) for the start of the observing period
time_end (Astropy.Time object or float) – Astropy.Time date or julian date (in same base as lc) for the end of the observing period
include_multis (bool, optional) – Also generate transits for multi-transiting planets? Defaults to True.
- Returns
Dataframe of transits observable between time_start and time_end.
- Return type
pandas DataFrame
Example
# e.g. after running model.RunMcmc(): df = model.PredictFutureTransits(Time(‘2021-06-01T00:00:00.000’,format=’isot’),Time(‘2021-10-01T00:00:00.000’,format=’isot’))
- RunMcmc(n_draws=500, n_burn_in=None, overwrite=False, continuesampling=False, chains=4, **kwargs)¶
Run PyMC3 sampler
- Parameters
n_draws (int, optional) – Number of independent samples to draw from each chain. Defaults to 500.
n_burn_in (int, optional) – Number of steps to ‘burn in’ the sampler. Defaults to None in which case it becomes 2/3 the number of draws
overwrite (bool, optional) – Overwrite past stored data in this model? Defaults to False.
continuesampling (bool, optional) – Continue sampling from a previous sampler? Defaults to False.
chains (int, optional) – Number of chains to run. Defaults to 4.
- SaveModelToFile(savefile=None, limit_size=False)¶
Save a monoModel object direct to file.
- Parameters
savefile (str, optional) – File location to save to, otherwise it takes the default location using GetSavename. Defaults to None.
limit_size (bool, optional) – If we want to limit size this function can delete unuseful hyperparameters before saving. Defaults to False.
- ToLatexTable(varnames='all', order='columns')¶
Creating a Latex table for specfic parameters
- Parameters
varnames (str, optional) – . Defaults to ‘all’.
order (str, optional) – Whether to stack by ‘columns’ or ‘rows’. Defaults to ‘columns’.
- Returns
Multi-line latex table string.
- Return type
str
- add_duo(pl_dic, name)¶
add_duo Adds a transiting planet with two non-consecutive transits to planet properties dict
- Parameters
pl_dic (dict) – Dictionary of planet properties which requires: tcen: transit epoch in same units as time array (i.e. TJD) tcen_2: second transit epoch in same units as time array (i.e. TJD) period: (optional) transit period in same units as time array (i.e. days) period_err: (optional) transit period error in same units as time array (i.e. days) K: RV semi-amplitude in m/s
name (str) – Planet name (i.e. ‘01’, ‘b’, or ‘Malcolm’)
- add_mono(pl_dic, name)¶
Adds a transiting planet with a single transit to planet properties dict
- Parameters
pl_dic (dict) – Dictionary of planet properties which requires: tcen: transit epoch in same units as time array (i.e. TJD) tcen_err: transit epoch error (optional) period: transit period in same units as time array (i.e. days) period_err: transit period error in same units as time array (i.e. days) K: RV semi-amplitude in m/s
name (str) – Planet name (i.e. ‘01’, ‘b’, or ‘Malcolm’)
- add_multi(pl_dic, name)¶
Adds a transiting planet with multiple, consecutive transits to planet properties dict
- Parameters
pl_dic (dict) – Dictionary of planet properties which requires: tcen: transit epoch in same units as time array (i.e. TJD) tcen_err: transit epoch error (optional) period: transit period in same units as time array (i.e. days) period_err: transit period error in same units as time array (i.e. days) K: RV semi-amplitude in m/s
name (str) – Planet name (i.e. ‘01’, ‘b’, or ‘Malcolm’)
- add_planet(pltype, pl_dic, name)¶
Adds any planet type to planet properties dict
- Parameters
pltype (str) – Type of planet - i.e. ‘mono’, ‘duo’, ‘multi’ or ‘rvplanet’
pl_dic (dict) – Dictionary of planet properties which requires: depth: transit depth in unitless flux ratio (NOT ppm or ppt) tdur: transit duration in same units as time array (i.e. days) tcen: transit epoch in same units as time array (i.e. TJD) period: (if multi or rvplanet) transit period in same units as time array (i.e. days) period_err: (if rvplanet) transit period error in same units as time array (i.e. days) tcen_2: (if duo) second transit epoch in same units as time array (i.e. TJD)
name (str) – Planet name (i.e. ‘01’, ‘b’, or ‘Malcolm’)
- add_rvplanet(pl_dic, name)¶
Adds non-transiting planet seen only in RVs to planet properties dict
- Parameters
pl_dic (dict) – Dictionary of planet properties which requires: tcen: transit epoch in same units as time array (i.e. TJD) tcen_err: transit epoch error (optional) period: transit period in same units as time array (i.e. days) period_err: transit period error in same units as time array (i.e. days) K: RV semi-amplitude in m/s
name (str) – Planet name (i.e. ‘01’, ‘b’, or ‘Malcolm’)
- add_rvs(rv_dic, n_poly_trend=2, overwrite=False, **kwargs)¶
Add a dictionary of rvs with arrays of:
- Parameters
rv_dic (dict) –
Dictionary of radial velocity info. Necessary values: “time”, “rv”, “rv_err” Optional values: “rv_unit” (assumes m/s),
”tele_index” (unique telescope id for each RV), “jd_base” (assumes same as lc), “jitter_min” (default=0.5) “logjitter_mean” (default=0.0) “logjitter_sd” (default=0.4, or ~40%)
n_poly_trend (int, optional) – [description]. Defaults to 2.
overwrite (bool, optional) – [description]. Defaults to False.
- calc_gap_edge_likelihoods(mono, n_check=100)¶
- Calculate the effect on likelihood of a transit model for those transits which occur at the “edges” of photometric data coverage.
- e.g. In the case that we are not creating transit models for each period gap, we want to calculate how the
“edges” of those gaps affect the log probability.Effectively we’ll calculate the likelihood of the edges of the gaps w.r.t the initial-fit transit model. This will then become a 1D (e.g. linear) polynomial which sets the logprior at the edges of each monotransit gap.
The saved monotransit dictionary is updated within the model.
- Parameters
mono (str) – Name of the selected Monotransit in the mod.planets
n_check (int, optional) – Number of positions to check across each edge. Defaults to 100.
- compute_duo_period_aliases(duo, dur=0.5)¶
- Calculating Duotransit period aliases
- Given the time array, the t0 of transit, and the fact that two transits are observed,
we want to calculate a distribution of periods, and then remove those which are impossible/observed
- Parameters
duo (dict) – Planet properties dictionary for the selected Duotransit, as described in add_duo
dur (float, optional) – Transit duration [days]. Defaults to 0.5.
- Returns
Updated planet properties dictionary with period_aliases term
- Return type
dict
- compute_period_gaps(tcen, tdur, depth, max_per=8000, SNR_thresh=4)¶
- Compute regions of period space which are not covered by photometry (i.e. find the gaps)
e.g. Given the time array, the t0 of transit, and the fact that another transit is not observed, we want to calculate a distribution of impossible periods to remove from the Period PDF post-MCMC In this case, a list of periods is returned, with all points within 0.5dur to be cut
- Parameters
tcen (float) – transit epoch
tdur (float) – transit duration (in days)
depth (float) – transit depth (in ratio, i.e. NOT ppt/ppm)
max_per (int, optional) – Maximum period bound. Defaults to 8000.
SNR_thresh (int, optional) – [description]. Defaults to 4.
- Returns
Period gap start and ends, with each gap start/end forming a tuple entry to the array rmsseries (array): Array of binned times and RMS scatter for each time at the implied duration, as calculated by compute_rms_series
- Return type
gap_start_ends (array)
- compute_rms_series(tdur, split_gap_size=2.0, n_steps_per_dur=7)¶
Computing an RMS time series for the lightcurve by binning
- Parameters
tdur (float) – transit duration
split_gap_size (float, optional) – Duration at which to cut the lightcurve and compute in loops. Defaults to 2.0.
n_steps_per_dur (int, optional) – number of steps with which to cut up each duration. Odd numbers work most uniformly. Defaults to 7.
- Returns
2-column array of bin times, and bin RMS
- Return type
array
- drop_planet(name)¶
Removes planet from saved planet properties dict (mod.planets)
- Parameters
name (str) – Name of planet within planets dictionary
- getLDs(n_samples, mission='tess', how='2')¶
- Gets theoretical quadratic Limb Darkening parameters for any specified mission.
This is done by first interpolating the theoretical samples (e.g. Claret) onto Teff and logg axes. FeH is typically fixed to the closest value. Then, using stellar samples from normally-distributed Teff and logg, a distribution of values for each LD parameter are retrieved. This can be performed for TESS, Kepler, CoRoT and CHEOPS bandpasses.
- Parameters
n_samples (int) – Number of samples to generate
mission (str, optional) – [description]. Defaults to ‘tess’.
how (str, optional) – [description]. Defaults to ‘2’.
- Returns
Two-column array of quadratic limb darkening parameters (u1 and u2) as generated from the interpolated Normally-distributed Teff & logg
- Return type
np.ndarray
- init_gp_to_plot(n_samp=7, max_gp_len=12000, interp=True, newgp=False, overwrite=False)¶
Initialise the GP model for plotting.
As it is memory-intensive to store predicted GP samples for each datapoint in the light curve during sampling, this is not done by default by MonoTools. Instead, the GPs are re-computed after-the-fact from the sampled hyperparameters, enabling plotting. This re-computation is typically done on limited shorter segments of lightcurve.
The result is the gp_to_plot array, which is a dictionary of predicted GP flux percentiles computed for each point in the time series.
- Parameters
n_samp (int, optional) – Number of samples to produce. Defaults to 7.
max_gp_len (int, optional) – Maximum length of photometry to compute a GP on. Defaults to 12000.
interp (bool, optional) – Whether to interpolate the binned out-of-transit GP to the fine time grid (only possible with self.bin_oot is used)
newgp (bool, optional) – Whether to initialise a new GP using the sampled kernel hyperparameters to re-predict the fine time grid
- init_interpolated_Mp_prior()¶
Initialise a 2D interpolated prior for the mass of a planet given the radius
- init_interpolated_v_prior()¶
Initialise the interpolated functions for log prob vs log velocity and marginalised eccentricity vs log velocity
- init_lc(**kwargs)¶
Initialise light curve. This can be done either after or before model initialisation. This function creates transit maskes and flattens/bins the light curve in ways to avoid influencing the transit.
- init_model(overwrite=False, **kwargs)¶
Initalise fitting model
- Parameters
overwrite (bool, optional) – whether to overwrite. Defaults to False.
- Kwargs:
assume_circ (int, optional): Assume circular orbits (no ecc & omega)? Defaults to False use_GP (bool, optional): Use GPs to co-fit light curve? Defaults to True train_GP (bool, optional): Train the lightcurve GP on out-of-transit data before sampling? Defaults to True constrain_LD (bool, optional): Use constrained LDs from model or unconstrained? Defaults to True ld_mult (float, optional): How much to multiply theoretical LD param uncertainties. Defaults to 3. useL2 (bool, optional): Fit for “second light” (i.e. a binary or planet+blend). Defaults to False FeH (float, optional): Stellar FeH. Defaults to 0.0 LoadFromFile (bool, optional): Load previous model? Defaults to False cutDistance (float, optional): cut out points further than cutDistance*Tdur. 0.0 means no cutting. Defaults to 3.75 maskdist (float, optional): Distance, in transit durations, from set transits, to “mask” as in-transit data when e.g. flattening.
Defaults to 0.666
- force_match_input (float OR None, optional): Float/None add potential with this the sigma between the input and the output logror and logdur
to force MCMC to match the input duration & maximise logror [e.g. 0.1 = match to 1-sigma=10%]. Defaults to None
debug (int, optional): print debug statements? Defaults to False fit_params (list, optional): fit these parameters. Options: [‘logror’, ‘b’ or ‘tdur’, ‘ecc’, ‘omega’].
Defaults to [‘logror’,’b’,’tdur’, ‘t0’]
- marginal_params (list, optional): marginalise over these parameters. Options: [‘per’, ‘b’ ´or ‘tdur’, ‘ecc’, ‘omega’,’logror’].
Defaults to [‘per’,’ecc’,’omega’]
interpolate_v_prior (bool, optional): Whether to use interpolation to produce transit velocity prior. Defaults to True ecc_prior (str, optional): ‘uniform’, ‘kipping’ or ‘vaneylen’. If ‘auto’ we decide based on multiplicity. Defaults to ‘auto’ per_index (float, optional): period prior index e.g. P^{index}. -8/3 in to Kipping 2018. Defaults to -8/3 derive_K (bool, optional): If we have RVs, do we derive K for each alias or fit for a single K param. Defaults to True use_multinest (bool, optional): Use Multinest sampling [NOT SUPPORTED YET]. Defaults to False use_pymc3 (bool, optional): Use PyMC3 sampling? Defaults to True bin_oot (bool, optional): bool - Bin points outside the cutDistance to 30mins. Defaults to True
- init_plot(interactive=False, gap_thresh=10, plottype='lc', pointcol='k', palette=None, ncols=None)¶
Initialising plotting
- Parameters
interactive (bool, optional) – Interactive bokeh plot? Defaults to False.
gap_thresh (int, optional) – Threshold in days above which we cut the plot into smaller figures. Defaults to 10.
plottype (str, optional) – ‘lc’ or ‘rv’. Defaults to ‘lc’.
pointcol (str, optional) – colour of smallest raw points. Defaults to ‘k’ (black)
palette (str, optional) – specify the (i.e. seaborn) colour palette to use. Defaults to None.
ncols (int, optional) – The number of colours to use. Defaults to None.
- init_pymc3(ld_mult=1.5)¶
Initialise the PyMC3 sampler
- init_rvs_to_plot(n_samp=300, plot_alias='all')¶
Initialise RV models to plot.
The result is the rvs_to_plot array. This is formed of two hierarchical dictionaries - one for each RV x point (rvs_to_plot[“x”]), and one for a fine grid of time points (rvs_to_plot[“t”]) Then, each contains the following dictionaries of percentiles (keys=[‘-2sig’,’-1sig’,’med’,’+1sig’,’+2sig’]) computed for each x and t point in the time series:
the RV polynomial trend (e.g. rvs_to_plot[“x”][“trend”])
a summed RV model (e.g. rvs_to_plot[“x”][“all”])
combined RV models with the trend (e.g. rvs_to_plot[“x”][“all+trend”])
- For each individual planet dictionaries with either:
marginalised RV model given the multiple perid aliases (for Duo/Monotransiting planets, e.g. rvs_to_plot[“x”][“marg”])
Individual RV models (for rv planets/multi-transiting planets, e.g. rvs_to_plot[“x”][0])
- Parameters
n_samp (int, optional) – Number of MCMC samples to use to generate RV models. Defaults to 300
plot_alias (str, optional) – How to plot aliases - either ‘all’ or ‘best’. Defaults to ‘all’.
- init_starpars(Rstar=array([1., 0.08, 0.08]), Teff=array([5227, 100, 100]), logg=array([4.3, 1., 1.]), FeH=0.0, rhostar=None, Mstar=None)¶
Adds stellar parameters to model
- Parameters
Rstar (list, optional) – Stellar radius in Rsol in format [value, neg_err, pos_err]. Defaults to np.array([1.0,0.08,0.08]).
Teff (list, optional) – Stellar effective Temperature in K in format [value, neg_err, pos_err]. Defaults to np.array([5227,100,100]).
logg (list, optional) – Stellar logg in cgs in format [value, neg_err, pos_err]. Defaults to np.array([4.3,1.0,1.0]).
FeH (float, optional) – Stellar log Metallicity. Defaults to 0.0.
rhostar (list, optional) – Stellar density in rho_sol (1.411gcm^-3) in format [value, neg_err, pos_err]. Defaults to None.
Mstar (float or list, optional) – Stellar mass in Msol either as a float or in format [value, neg_err, pos_err]. Defaults to None.
- init_trans_to_plot(n_samp=None)¶
Initialising the transit models to plot
The result is the trans_to_plot array, which is a dictionary of predicted transit flux model percentiles computed for each point in the time series.
- Parameters
n_samp (int, optional) – Number of samples to use from the MCMC trace to generate the models & percentiles. Defaults to None.
- vals_to_latex(vals)¶
Function to turn percentiles (i.e. -1, 0, and +1 sigma values) into rounded latex strings for a table. This function identifies when errorbars are unequal (i.e. val ^ +sig1 _ -sig2), and when they are equal (val +/- sig)
- Parameters
vals (list) – Values in the form [-1-sigma, median, +1-sigma]
- Returns
Latex string for a single parameter’s value and errors
- Return type
str
- MonoTools.fit.theano_pars = {'base_compiledir': '/Volumes/LUVOIR/MonoToolsData/.theano_dir_4', 'device': 'cpu', 'floatX': 'float64', 'gcc.cxxflags': '-fbracket-depth=1024'}¶
- if MonoData_savepath==”/Users/hosborn/python/MonoToolsData” or MonoData_savepath==”/Volumes/LUVOIR/MonoToolsData”:
theano_pars[‘cxx’]=’/usr/local/Cellar/gcc/9.3.0_1/bin/g++-9’
- if MonoData_savepath==”/Users/hosborn/python/MonoToolsData” or MonoData_savepath==”/Volumes/LUVOIR/MonoToolsData”:
theano_pars[‘cxx’]=’cxx=/Library/Developer/CommandLineTools/usr/bin/g++’
MonoTools.lightcurve module¶
- class MonoTools.lightcurve.lc¶
Bases:
object
Base lightcurve class which allows for standard binning, flattening, loading, etc. Typically for objects observed by multiple sectors, campaigns, missions, etc. the multilc daughter class should be used instead.
- OOTbin(near_transit_mask, use_flat=False, binsize=0.020833333333333332)¶
Out-Of-Transit binning of the lightcurve (to speed up computation)
- Parameters
near_transit_mask ([type]) – [description]
use_flat (bool, optional) – [description]. Defaults to False.
binsize (float, optional) – [description]. Defaults to 1/48.
- bin(timeseries=['flux'], binsize=0.020833333333333332, split_gap_size=0.8, use_masked=True, extramask=None, overwrite=False, **kwargs)¶
Binning lightcurve to e.g. 30-min cadence for planet search
- Parameters
timeseries (list, optional) – List of timeseries which to bin. Defaults to [‘flux’]
binsize (float, optional) – Size of bins in units matching lightcurve time. Defaults to 1/48.
split_gap_size (float, optional) – Size to count as a “gap” in the lightcurve. Defaults to 0.8.
use_masked (bool, optional) – whether to bin using only the masked flux array. Defaults to True.
extramask (np.ndarray, optional) – Added mask to use when binning, otherwise either only mask or nothing is used. Defaults to None.
overwrite (bool, optional) – Whether to overwrite already-stored binned data array. Defaults to False
- change_flx_system(new_flx_system, mask=None)¶
Convert lightcurves between flux unit/systems, e.g. to a lightcurve in ppm normalised to 0 (‘ppm’), or to a flux ratio normalised to 1 (‘norm1’)
- Parameters
new_flx_system (str) – One of “ppm”, “ppt”, “norm0”, “norm1” or “elec”. These denote: - ppm: normalised lightcurve with median at 0.0 with units in parts per million - ppt: normalised lightcurve with median at 0.0 with units in parts per thousand - norm0: normalised lightcurve with median at 0.0 with units as a ratio (0->1) - norm1: normalised lightcurve with median at 1.0 with units as a ratio (0->1) - elec: un-normalised lightcurve with units of pure electrons and median proportional to stellar magnitude
mask (np.ndarray, optional) – Boolean array masking bad points to create median. Default is None
- change_jd_base(new_jd_base)¶
Change timing epoch
- Parameters
new_jd_base (float) – New base for timing array
- flatten(timeseries=['flux'], knot_dist=1.25, maxiter=10, sigmaclip=3.0, flattype='bspline', stepsize=0.15, reflect=True, polydegree=3, transit_mask=None)¶
AI is creating summary for flatten
- Parameters
timeseries (list, optional) – List of timeseries to flatten. Defaults to [‘flux’].
knot_dist (float, optional) – Typical distance between spline “knots” OR polynomial fitting lengths. Defaults to 1.25.
maxiter (int, optional) – Maximum iterations to perform to find/remove anomalies. Defaults to 10.
sigmaclip (float, optional) – Significance of anomalies from the mean above which we clip. Defaults to 3..
flattype (str, optional) – Either use a ‘bspline’ (which fits smooth splines while iterating away anomalies/transits/etc) Or a ‘polystep’ (which uses out-of-box polynomials to smooth data without influencing transit depth). Defaults to ‘bspline’.
stepsize (float, optional) – [description]. Defaults to 0.15.
reflect (bool, optional) – [description]. Defaults to True.
polydegree (int, optional) – [description]. Defaults to 3.
transit_mask (np.ndarray, optional) – Mask of transits where 0 = in transit and 1 = out of transit. Defaults to None.
- load_lc(time, fluxes, flux_errs, flx_system, src=None, mission=None, jd_base=0, sect=None, cadence=None, default_flx_system='ppt', *args, **kwargs)¶
Loading lightcuve given vital infomation.
- Parameters
time (np.ndarray) – time array
fluxes (np.array or dict) – Either a numpy array of flux, or a Dictionary of various flux arrays
flux_errs (np.array or dict) – Either a numpy array of flux errors or a Dictionary of various flux error arrays. This should only have fluxes as seen in the fluxes dict with “_err” as suffixes
src (str) – String describing source of lightcurve (e.g. pipeline)
mission (str) – Photometric mission/telescope of lightcurve (e.g. k2, tess, kepler, etc)
jd_base (float) – JD epoch for time=0
flx_system (str) – Type of flux - either “ppm”, “ppt”, “norm0”, “norm1” or “elec” (see change_flx_system)
cadence (float OR int OR np.ndarray) –
- Either - cadence in seconds OR
a 1D array of strings in format [telescope ID k1/k2/co/te/ch]_[cadence in secs]_[pipeline source]_[Sector/Q/camp]
If left None this is estimated from time array. Default is None
default_flx_system (str) – Type of flux - either “ppm”, “ppt”, “norm0”, “norm1” or “elec” (see `change_flx_system `)
- make_fluxmask(flux_arr_name='flux', cut_all_anom_lim=5.0, end_of_orbit=True, use_flat=False, mask_islands=False, input_mask=None, in_transit=None, extreme_anom_limit=0.25)¶
mask bad points in lightcurve
- Parameters
cut_all_anom_lim (float, optional) – Cut all single points above AND below lightcurve further away than this anomalous value. Defaults to 5.0.
end_of_orbit (bool, optional) – Check if masking lightcurve segments before/after a gap vastly reduces rms? Defaults to True.
use_flat (bool, optional) – Run mask on flattened flux array? Defaults to False.
mask_islands (bool, optional) – Mask small islands of data in time series? Defaults to False.
input_mask (np.ndarray, optional) – A previously-defined mask. Defaults to None.
in_transit (np.ndarray, optional) – A mask where all in-transit points are flagged as True. Defaults to None
cut_periodic_high_regions (bool, optional) – Using the orbital period, should we cut the periodic high SAA regions? Defaults to False
extreme_anom_limit (float, optional) – Flux variation in ratio above/below which, we will out. Defaults to 0.25 (i.e. points above/below 25% are missing)
- Returns
[description]
- Return type
[type]
- make_mask(overwrite=False)¶
Making mask for timeseries. Requires both a “flux” mask (i.e. bad/anomalous points) and a “cadence” mask (i.e. duplicate cadences due to multiple lightcurve sources)
- Parameters
overwrite (bool, optional) – [description]. Defaults to False.
- plot(plot_rows=1, timeseries=['flux'], jump_thresh=10, ylim=None, xlim=None, yoffset=0, savepng=False, savepdf=False, savefileloc=None)¶
Plot the lightcurve using Matplotlib.
In the default case, either data that is extremely long (i.e Kepler), or data that has a large gap (i.e. TESS Y1/3) will be split into two rows. Gaps between quarters, sectors, etc will result in horizontally-split plot frames. Typically ~30min cadence data is plotted unbinned and shorter-cadence ddata is plotted raw and with 30-minute bins
- Parameters
plot_rows (int, optional) – Number of rows for the plot to have. Defaults to None, in which case this is automatically guessed between 1 and 4
timeseries (list, optional) – List of which timeseries to plot (i.e. enables plotting of e.g. background flux or flattened flux. Defaults to [‘flux’]
jump_thresh (int, optional) – Threshold beyond which we call a gap/jump between observations a major difference. Defaults to 10.
- remove_binned_arrs()¶
Removing binned timeseries arrays. This is necessary to stack lightcurves
- remove_flattened_arrs()¶
Removing flattened timeseries arrays. This reduces size when saving
- sort_timeseries()¶
Loop through the timeseries associated with this lightcurve (timeseries) and sort by time.
- class MonoTools.lightcurve.multilc(id, mission, radec=None, load=True, do_search=True, flx_system='ppt', jd_base=2457000.0, savefileloc=None, extralc=None)¶
Bases:
MonoTools.lightcurve.lc
- A flexible lightcurve class built from multiple individual lightcurves
i.e. a combination of TESS sectors, or an ensemble of both CoRoT, K2 and TESS data
Example: mylc=lc(203311200,’k2’) mylc.
- get_K2_campaigns(id=None)¶
See which K2 campaigns observed a given target?
- Parameters
id (int, optional) – EPIC ID. Defaults to None, in which case it is taken from all_ids
- Returns
List of campaigns in which the target was observed with K2
- Return type
list
- get_all_lightcurves(all_pipelines=False, extralc=None, **kwargs)¶
Download all available space photometry for a target. This uses the info stored in all_ids
- Parameters
all_pipelines (bool, optional) – Whether to download (i.e. simultaneous) photometry from multiple pipelines? Defaults to False.
- get_all_survey_ids(search=['all'], overwrite=False, **kwargs)¶
Given the source ID and mission, search all photometric missions for both the coplementary mission IDs, and extra catalogue data/observability
- Parameters
search (list, optional) – A list of missions to search. Defaults to [‘all’].
overwrite (bool, optional) – Whether to overwrite the info already stored in all_ids. Defaults to False.
- get_corot_campaigns(id=None, search_radius=25.0)¶
AI is creating summary for corot_observability
- Parameters
search_radius (float, optional) – Square search “radius” (i.e. half boxlength) in arcseconds. Defaults to 15.
- Returns
A table with each holding data for a CoRoT field
- Return type
pandas DataFrame
- get_corot_lc(fitslink, campaign, **kwargs)¶
Get single CoRoT lightcurve from link to fits file
- Parameters
fitslink (str) – HTTP path to fits file on MAST/exoarchive
campaign (str) – CoRoT campaign ID
- Returns
CoRoT lightcurve
- Return type
- get_everest_k2_lc(id, camp)¶
Get single Everest (Luger et al 2016) K2 lightcurve for selected campaign
- Parameters
id (int) – EPIC ID of target
camp (str) – K2 Campaign
- Returns
Detrended K2 lightcurve
- Return type
- get_k2_lc(camp, id=None, search=['all'], **kwargs)¶
Get K2 lightcurve for a single campaign
- Parameters
camp (str or int) – K2 Campaign
id (str or int,optional) – EPIC ID of target. Defaults to None, in which case the ID is taken from all_ids
search (list, optional) – Which pipelines to search. Defaults to [‘all’] which will iterate through ‘everest’,’vand’ and then ‘pdc’ until it finds a lightcurve
- Returns
Detrended K2 lightcurve
- Return type
- get_kepler_lc(q, id=None, get_short_cadence=True, **kwargs)¶
Get Kepler lightcurve for single quarter
- Parameters
q ([type]) – [description]
id ([type], optional) – [description]. Defaults to None.
get_short_cadence (bool, optional) – [description]. Defaults to True.
- Returns
[description]
- Return type
[type]
- get_pdc_k2_lc(id, camp, **kwargs)¶
Get single PDC K2 lightcurve for selected campaign
- Parameters
id (int) – EPIC ID of target
camp (str) – K2 Campaign
v (int, optional) – Version of pipeline. Defaults to 1.
- Returns
Detrended K2 lightcurve
- Return type
- get_radec()¶
Get radec from ID by searching the input catalogue
- get_tess_lc(sector, search=['all'], use_fast=False, use_eleanor=False, **kwargs)¶
Access TESS ligthcurve for given sector
- Parameters
sector (int) – sector to search
search (list, optional) – list of lightcurve sources to search. Defaults to [‘all’]. This will iterate through ‘spoc_20’, ‘spoc_120’, ‘spoc_1800’/’spoc_600’, ‘qlp_1800’/’qlp_600’ and ‘eleanor_1800’/’eleanor_600’ until a lightcurve is found
use_fast (bool, optional) – Search for 20-second data? Defaults to False.
use_eleanor (bool, optional) – Search eleanor? Defaults to False.
- Returns
TESS lightcurve
- Return type
- get_tess_sectors(id=None, sectors='all', **kwargs)¶
See which sectors are observable with TESS
- Parameters
id (int, optional) – TIC ID. Defaults to None, in which case it is taken from all_ids
sectors (str,list of np.ndarray, optional) – Either ‘all’ (in which case we search all sectors), or a list/array of sectors to search. Defaults to ‘all’.
- Returns
List of sectors observed with TESS for the specfied ID
- Return type
list
- get_vanderburg_k2_lc(id, camp, v=1, **kwargs)¶
Get single K2SFF (Vanderburg et al 2013) K2 lightcurve for selected campaign
- Parameters
id (str) – EPIC ID of target
camp (str) – K2 Campaign
v (int, optional) – Version of pipeline. Defaults to 1.
- Returns
Detrended K2 lightcurve
- Return type
- load_pickle()¶
- make_cadmask()¶
- make_mask(overwrite=False)¶
Making mask for timeseries. Requires both a “flux” mask (i.e. bad/anomalous points) and a “cadence” mask (i.e. duplicate cadences due to multiple lightcurve sources)
- Parameters
overwrite (bool, optional) – [description]. Defaults to False.
- plot(plot_rows=None, timeseries=['flux'], jump_thresh=10, ylim=None, xlim=None, yoffset=0, savepng=True, savepdf=False)¶
Plot the lightcurve using Matplotlib.
In the default case, either data that is extremely long (i.e Kepler), or data that has a large gap (i.e. TESS Y1/3) will be split into two rows. Gaps between quarters, sectors, etc will result in horizontally-split plot frames. Typically ~30min cadence data is plotted unbinned and shorter-cadence ddata is plotted raw and with 30-minute bins
- Parameters
plot_rows (int, optional) – Number of rows for the plot to have. Defaults to None, in which case this is automatically guessed between 1 and 4
timeseries (list, optional) – List of which timeseries to plot (i.e. enables plotting of e.g. background flux or flattened flux. Defaults to [‘flux’]
jump_thresh (int, optional) – Threshold beyond which we call a gap/jump between observations a major difference. Defaults to 10.
- read_from_file(f, fname, sect, **kwargs)¶
opens and processes all lightcurve files (especially, but not only, fits files).
- Parameters
f (various types) – opened file. This could be: - astropy.fits format from kepler, k2 (everest, k2sc, pdc, vand) or tess
fname (str) – string of filename. Can be blank for certain file types.
sect (str) – string of sector. Can be left blank (i.e. None), but this may make stitching lightcurves more difficult…
- Kwargs:
src (str): String describing source of lightcurve (e.g. pipeline) mission (str): Photometric mission/telescope of lightcurve (e.g. k2, tess, kepler, etc) jd_base (float): JD epoch for time=0 flx_system (str): Type of flux used in lightcurve - either “ppm”, “ppt”, “norm0”, “norm1” or “elec” (see change_flx_system) cut_all_anom_lim (float, optional): Perform cuts on all anomalies when masking. Defaults to 4.0. default_flx_system (str, optional): Default flux system to use. Defaults to ‘ppt’. force_raw_flux (bool, optional): Force the lightcurve to swap ‘flux’ for ‘raw_flux’ (i.e. due to bad PDC detrending). Defaults to False. end_of_orbit (bool, optional): Cut/fix the end-of-orbit flux? Defaults to False.
- save(savename=None)¶
Saving the lightcurve as gzipped pickle file.
- Parameters
savename (str, optional) – Savename to save to. Defaults to None.
- save_csv(savename=None)¶
AI is creating summary for save_csv
- Parameters
savename (str, optional) – Filename to save under Defaults to None.
- stack(newlcs, priorities=None)¶
Stacks lightcurves onto the multilc object
- Parameters
newlcs (list) – A list of lightcurve classes (either multilc or lc) to add together
priorities (list, optional) – Which lightcurve sources take priority in the case that they overlap in timing? This is required in the case that lightcurves are overlapping… Defaults to None.
MonoTools.oldcode module¶
MonoTools.search module¶
- class MonoTools.search.Duo(ID, mission, lc=None, rvs=None, planets=None, overwrite=False, savefileloc=None, **kwargs)¶
Bases:
MonoTools.search.detection
The Duotransit detection class - i.e. a candidate with two non-consecutive transits which builds on the generalized detection class
- class MonoTools.search.Mono(ID, mission, lc=None, rvs=None, planets=None, overwrite=False, savefileloc=None, **kwargs)¶
Bases:
MonoTools.search.detection
The Monotransit detection class - i.e. a candidate with a single transit which builds on the generalized detection class
- class MonoTools.search.Multi(ID, mission, lc=None, rvs=None, planets=None, overwrite=False, savefileloc=None, **kwargs)¶
Bases:
MonoTools.search.detection
The Multi-transit detection class - i.e. a candidate with multiple transits and constrained period which builds on the generalized detection class
- class MonoTools.search.detection(ID, mission, lc=None, rvs=None, planets=None, overwrite=False, savefileloc=None, **kwargs)¶
Bases:
object
The core detection class which represents candidates
- QuickFit(Rs=None, Ms=None, Teff=None, useL2=False, fit_poly=True, force_tdur=False, polyorder=2, ndurs=4.2, how='mono', init_period=None, fluxindex='flux_flat', mask=None, **kwargs)¶
Perform Quick fit of candidate detection
- Parameters
useL2 (bool, optional) – [description]. Defaults to False.
fit_poly (bool, optional) – [description]. Defaults to True.
force_tdur (bool, optional) – [description]. Defaults to False.
polyorder (int, optional) – [description]. Defaults to 2.
ndurs (float, optional) – [description]. Defaults to 4.2.
init_period ([type], optional) – [description]. Defaults to None.
fluxindex (str, optional) – [description]. Defaults to ‘flux_flat’.
mask ([type], optional) – [description]. Defaults to None.
- Returns
[description]
- Return type
[type]
- class MonoTools.search.target(id, mission, radec=None, lc=None, dataloc=None)¶
Bases:
object
The core target class which represents an individual star
- AsteroidCheck(monoparams, ID, order=3, dur_region=3.5, plot=False, plot_loc=None, return_fit_lcs=False, remove_earthshine=True, **kwargs)¶
- CentroidCheck(monoparams, interpmodel, ID, order=2, dur_region=3.5, plot=True, plot_loc=None, return_fit_lcs=False, **kwargs)¶
- CheckInstrumentalNoise(monodic, jd_base=None, **kwargs)¶
# Using the processed “number of TCEs per cadence” array, we try to use this as a proxy for Instrumental noise in TESS # Here we simply use the detected SNR over the instrumental noise SNR as a proxy INPUTS: - lc - monotransit dic - jd_base (assumed to be that of TESS)
- CheckMonoPairs(all_pls, prox_thresh=3.5, **kwargs)¶
- CheckPeriodConfusedPlanets(all_dets, mono_mono=True, multi_multi=True, mono_multi=True)¶
- CutAnomDiff(thresh=4.2)¶
- DoEBfit(tc, dur)¶
- EB_modelPriors(priors)¶
- EBmodel(t, Ms, tsec=False)¶
- EBmodel_lnprob(x, y, yerr, priors, Ms, tsec=False)¶
- EBmodel_neg_lnprob(x, y, yerr, priors, Ms, tsec=False)¶
- GapCull(t, dat, std_thresh=10, boolean=None, time_jump_thresh=0.4)¶
- Gaussian_lnprob(x, y, yerr, priors, order=3)¶
- Gaussian_neg_lnprob(x, y, yerr, priors, order=3)¶
- GenModelLc(all_pls, mission, Rstar=1.0, rhostar=1.0, Teff=5800, logg=4.43)¶
- MonoVetting(mission, tcen=None, tdur=None, overwrite=None, do_search=True, do_fit=False, coords=None, lc=None, useL2=False, PL_ror_thresh=0.2, variable_llk_thresh=5, file_loc=None, plot=True, **kwargs)¶
#Here we’re going to initialise the Monotransit fitting by searching for other planets/transits/secondaries and filtering out binaries. INPUTS: - ID - mission - useL2=False - PL_ror_thresh=0.2
**kwargs: - StarPars=None, a list of radius, rho, teff and logg which are each lists of values/errors - multi_SNR_thresh=6.25, - plot=True - file_loc - a location to store images/files - overwrite=False For MonoTransitSearch: - mono_BIC_thresh=-10 - mono_SNR_thresh - n_oversamp=75, - use_binned=True - use_flat=True - use_poly=True - binsize=1/96.0, - Rs=Rstar[0] - Ms=rhostar[0]*Rstar[0]**3 - Teff=Teff[0], - plot=plot - plot_loc=file_loc+”/” - poly_order=4
- Poly_lnprob(x, y, yerr, priors, polyorder=2)¶
- Poly_neg_lnprob(x, y, yerr, priors, polyorder)¶
- QuickMonoFit(planet, useL2=False, fit_poly=True, tdur_prior='loguniform', polyorder=2, ndurs=3.3, fluxindex='flux_flat', mask=None, **kwargs)¶
Performs simple planet fit to monotransit dip given the detection data.
- Parameters
planet (str) – Candidate identifying to fit
useL2 (bool, optional) – Use diluted second light. Defaults to False.
fit_poly (bool, optional) – Fit a transit dip AND a polynomial trend around transit. Defaults to True.
tdur_prior (str, optional) – Prior function to use on tdur - ‘lognormal’,’loguniform’,’normal’ or ‘uniform’. Defaults to ‘loguniform’.
polyorder (int, optional) – Degree of polynomial fit. Defaults to 2.
ndurs (float, optional) – Number of transit durations to fit each side. Defaults to 3.3
fluxindex (str, optional) – Which array in self.lc to use for the fitting. Defaults to ‘flux_flat’.
mask (np.ndarray, optional) – Addidtional flux mask to use. Defaults to None (in which can self.lc.mask is used)
- Sinusoid_lnprob(x, y, yerr, priors, polyorder=2)¶
- Sinusoid_neg_lnprob(x, y, yerr, priors, polyorder)¶
- Step_neg_lnprob(x, y, yerr, priors, polyorder, npolys)¶
- VariabilityCheck(params, ID, modeltype='all', plot=False, plot_loc=None, ndurs=2.4, polyorder=1, return_fit_lcs=False, **kwargs)¶
- VetCand(pl, ID, lc, mission, Rs=1.0, Ms=1.0, Teff=5800, mono_SNR_thresh=6.5, mono_SNR_r_thresh=5, variable_llk_thresh=5, plot=False, file_loc=None, vet_do_fit=True, return_fit_lcs=False, do_cent=True, **kwargs)¶
- broken_TLS(masked_t, masked_y, masked_yerr, max_period=None, min_period=1.1)¶
Running TLS on non-consecutive timeseries. This is performed by searching for short-period planets in individual sectors and then stacking the resulting power spectra together using interpolation. For detections found in the stacked power spectrum, a focused TLS is re-run on a small (1%-wide) period window to hone the period.
- Parameters
masked_t (np.ndarray) – Time with known transits and anomalies masked
masked_y (np.ndarray) – Flux with known transits and anomalies masked. This must be normalised to median 1.0
masked_yerr (np.ndarray) – Flux error with known transits and anomalies masked
max_period (float, optional) – Maximum period to search. Defaults to 2/3 of the total observation duration.
min_period (float, optional) – Minimum period to search. Defaults to 1.1d.
- Returns
TransitLeastSquares results dictionary for the detected object np.ndarray: full combined power spectrum with columns of period and power
- Return type
dict
- calc_min_P(tcen, tdur)¶
For a monotransit, calculate the minimum possible radius given that no other transit was detected for this candidate
- Parameters
tcen (float) – Transit epoch
tdur (float) – Transit durtion
- Returns
Minimum period in days
- Return type
float
- centroid_lnprob(t, x, y, xerr, yerr, priors, interpmodel, order=3)¶
- centroid_neg_lnprob(t, x, y, xerr, yerr, priors, interpmodel, order=3)¶
- check_instrum_noise(planet)¶
- create_transit_mask()¶
- dipmodel_centroid(t, interpmodel, order)¶
- dipmodel_gaussian(x)¶
- dipmodel_sinusoid(x)¶
- dipmodel_step(x, npolys)¶
- exoplanet_EB_model(objects, Teffs, Rs, Ms, nrep=9, try_sec=False, use_ellc=False)¶
- get_interpmodels(Rs, Ms, Teff, n_durs=3, gap_thresh=2.0, texp=None)¶
- get_snr_red(tcen, tdur, planet, depth, tcen_2=None, period=None)¶
Calculating std in typical bin with width of the transit duration, to compute SNR_red
- Parameters
tcen (float) – Transit epoch
tdur (float) – Transut duration
planet (str) – string for the candidate idenfier
depth (float) – Depth (as a ratio) of the
tcen_2 (float, optional) – Second transit time centre (for duo transiting planets). Defaults to None.
period (float, optional) – Orbital period. Defaults to None.
- Returns
Dictionary with ‘N_trans’ (number of transits), ‘cdpp’ (scatter at the transit duration) and ‘snr_r’ (S/N of the transit w.r.t. red noise at the transit duration)
- Return type
dict
- init_mono(tcen, tdur, depth, name=None, otherinfo=None)¶
Initalise Monotransit
- Parameters
tcen (float) – transit epoch [d]
tdur (float) – transit duration [d]
depth (float) – transit depth [ratio]
name (str, optional) – Name of the detection - for the detns dictionary. Defaults to None, in which case it will take a numerical value
otherinfo (dict or pd.Series, optional) – Dictionary of extra info related to the monotransit detection. Defaults to None.
- init_multi(tcen, tdur, depth, period, name=None, otherinfo=None)¶
Initalise multi-transiting candidate
- Parameters
tcen (float) – transit epoch [d]
tdur (float) – transit duration [d]
depth (float) – transit depth [ratio]
name (str, optional) – Name of the detection - for the detns dictionary. Defaults to None, in which case it will take a numerical value
otherinfo (dict or pd.Series, optional) – Dictionary of extra info related to the monotransit detection. Defaults to None.
- init_starpars(Rs=None, Ms=None, Teff=None, logg=None, rhostar=None)¶
Initialise stellar parameters of target star.
- log_gaussian(mu, sig, weight=0.1)¶
- log_likelihood_EBmodel(x, y, yerr, Ms, tsec=False)¶
- log_likelihood_centroid(t, x, y, xerr, yerr, interpmodel, order)¶
- log_likelihood_gaussian_dip(x, y, yerr)¶
- log_likelihood_poly(x, y, yerr)¶
- log_likelihood_sinusoid(x, y, yerr)¶
- log_likelihood_step(x, y, yerr, npolys)¶
- minimize_EBmodel(objects, Teffs, Rs, Ms, nrep=9, try_sec=False, use_ellc=False)¶
- model_asteroid_fp(planet, how)¶
- model_centroid_shift(planet, llk_thresh)¶
- model_variability_fp(planet, how)¶
- plot_mono_search(use_flat=True, use_binned=True, use_poly=False, transit_zoom=2.25, plot_loc=None, **kwargs)¶
Plot the results found by search_monos
- Parameters
use_flat (bool, optional) – Whether to plot the flattened or raw lightcurve. Defaults to True.
use_binned (bool, optional) – Whether to plot the binned or raw lightcurve. Defaults to True.
use_poly (bool, optional) – Whether to use the local polynomials fits in plotting. Defaults to False.
transit_zoom (float, optional) – Size of window around transit to plot zoom (in transit durations). Defaults to 2.25.
plot_loc (str, optional) – File location to save plot. Defaults to None.
- plot_multi_search(plot_loc=None, plot_extent=0.8)¶
Plot the output of search_multi_planets
- Parameters
plot_loc (str, optional) – Location at which to save. Defaults to a file in self.dataloc
plot_extent (float, optional) – Extent in time of zoom plots in days. Defaults to 0.8.
- plot_vet()¶
- pri_sec_const(t_pri, dur_pri, t_sec=None, dur_sec=None)¶
- remove_detn(name)¶
Remove candidate detection given the name
- Parameters
name (str) – key from the detns dict to remove.
- search_monos(mono_SNR_thresh=6.5, mono_BIC_thresh=- 6, n_durs=5, poly_order=3, n_oversamp=20, binsize=0.010416666666666666, custom_mask=None, transit_zoom=3.5, use_flat=False, use_binned=True, use_poly=True, plot=False, plot_loc=None, n_max_monos=8, use_stellar_dens=True, **kwargs)¶
AI is creating summary for search_monos
- Parameters
mono_SNR_thresh (float, optional) – threshold in sigma to alert mono candidate. Defaults to 6.5.
mono_BIC_thresh (int, optional) – threshold in BIC to alert mono candidate. Defaults to -6.
n_durs (int, optional) – Number of distinct durations to iterate lightcurve search. Defaults to 5.
poly_order (int, optional) – polynomial order to use for a “no transit” fit. Defaults to 3.
n_oversamp (int, optional) – oversampling factor in transit durations from which to match to lightcurve. Defaults to 20.
binsize (float, optional) – size of bins in days. Defaults to 15/1440.0.
custom_mask (np.ndarray, optional) – [description]. Defaults to None.
transit_zoom (float, optional) – size (in transit durations) to cut around transit when minimizing transit model. Defaults to 3.5.
use_flat (bool, optional) – Flattens lightcurve before monotransit search. Defaults to False.
use_binned (bool, optional) – Uses binned (rather than raw) lightcurve. Defaults to True.
use_poly (bool, optional) – co-fits transits with a polynomial (order = poly_order-1) to account for variability. Defaults to True.
plot (bool, optional) – Whether to plot the transit search output. Defaults to False.
plot_loc (str, optional) – Location at which to save plot. Defaults to None.
n_max_monos (int, optional) – Max number of mono candidates to save/alert. Defaults to 8.
use_stellar_dens (bool, optional) – Use stellar density to produce transit templates to search. Defaults to True.
- search_multi_planets(fluxname='bin_flux_flat', binsize=0.010416666666666666, n_search_loops=5, multi_FAP_thresh=0.00125, multi_SNR_thresh=7.0, mask_prev_planets=False, **kwargs)¶
Use transitleastsquares to search for periodic planets.
- Parameters
fluxname (str, optional) – Which flux array to use for the detection. Defaults to ‘bin_flux_flat’.
binsize (float, optional) – Size of data binning in days. Defaults to 15/1440.0 (i.e. 15mins).
n_search_loops (int, optional) – Maximum number of times to run a TLS search (i.e. multiple detections). Defaults to 5.
multi_FAP_thresh (float, optional) – False Alarm Probability threshold for multi detection. Defaults to 0.00125.
multi_SNR_thresh (float, optional) – Signal to Noise Ratio threshold for multi detection. Defaults to 7.0.
mask_prev_planets (bool, optional) – Whether to mask those events we found during other searches (e.g. search_mono_planets). Defaults to False.
- vet(planet, tests=['all'], variable_llk_thresh=- 6, centroid_llk_thresh=- 6, **kwargs)¶
Vet candidate
- Parameters
planet (str) – String ID for planet candidate
tests (list, optional) – list of tests to perform. Can be one of: - ‘multidur’; - ‘model_variability’; Compares transit model fit to a variable (sinusoid) model fit - ‘model_step’; Compares transit model fit to a step model fit - ‘check_centroid’; Checks if the transit flux model is also significant in x/y centroids - ‘check_instrum’; Compares planet SNR to SNR of all candidates at that timestamp - ‘all’; performs all above tests
variable_llk_thresh (int, optional) – [description]. Defaults to -6.
centroid_llk_thresh (int, optional) – [description]. Defaults to -6.
- xoEB(planets)¶
- MonoTools.search.theano_pars = {'base_compiledir': '/Volumes/LUVOIR/MonoToolsData/.theano_dir_6', 'device': 'cpu', 'floatX': 'float64', 'gcc.cxxflags': '-fbracket-depth=1024'}¶
- if MonoData_savepath==”/Users/hosborn/python/MonoToolsData” or MonoData_savepath==”/Volumes/LUVOIR/MonoToolsData”:
theano_pars[‘cxx’]=’/usr/local/Cellar/gcc/9.3.0_1/bin/g++-9’
- if MonoData_savepath==”/Users/hosborn/python/MonoToolsData” or MonoData_savepath==”/Volumes/LUVOIR/MonoToolsData”:
theano_pars[‘cxx’]=’cxx=/Library/Developer/CommandLineTools/usr/bin/g++’
MonoTools.search_old module¶
- MonoTools.search_old.AsteroidCheck(lc, monoparams, ID, order=3, dur_region=3.5, plot=False, plot_loc=None, return_fit_lcs=False, remove_earthshine=True, **kwargs)¶
- MonoTools.search_old.CentroidCheck(lc, monoparams, interpmodel, ID, order=2, dur_region=3.5, plot=True, plot_loc=None, return_fit_lcs=False, **kwargs)¶
- MonoTools.search_old.CheckInstrumentalNoise(lc, monodic, jd_base=None, **kwargs)¶
# Using the processed “number of TCEs per cadence” array, we try to use this as a proxy for Instrumental noise in TESS # Here we simply use the detected SNR over the instrumental noise SNR as a proxy INPUTS: - lc - monotransit dic - jd_base (assumed to be that of TESS)
- MonoTools.search_old.CheckMonoPairs(lc_time, all_pls, prox_thresh=3.5, **kwargs)¶
- MonoTools.search_old.CheckPeriodConfusedPlanets(lc, all_dets, mono_mono=True, multi_multi=True, mono_multi=True)¶
- MonoTools.search_old.CutAnomDiff(flux, thresh=4.2)¶
- MonoTools.search_old.DoEBfit(lc, tc, dur)¶
- MonoTools.search_old.EB_modelPriors(params, priors)¶
- MonoTools.search_old.EBmodel(params, t, Ms, tsec=False)¶
- MonoTools.search_old.EBmodel_lnprob(params, x, y, yerr, priors, Ms, tsec=False)¶
- MonoTools.search_old.EBmodel_neg_lnprob(params, x, y, yerr, priors, Ms, tsec=False)¶
- MonoTools.search_old.GapCull(t0, t, dat, std_thresh=10, boolean=None, time_jump_thresh=0.4)¶
- MonoTools.search_old.Gaussian_lnprob(params, x, y, yerr, priors, order=3)¶
- MonoTools.search_old.Gaussian_neg_lnprob(params, x, y, yerr, priors, order=3)¶
- MonoTools.search_old.GenModelLc(lc, all_pls, mission, Rstar=1.0, rhostar=1.0, Teff=5800, logg=4.43)¶
- MonoTools.search_old.MonoTransitSearch(lc, ID, mission, Rs=None, Ms=None, Teff=None, mono_SNR_thresh=6.5, mono_BIC_thresh=- 6, n_durs=5, poly_order=3, n_oversamp=20, binsize=0.010416666666666666, custom_mask=None, transit_zoom=3.5, use_flat=False, use_binned=True, use_poly=True, plot=False, plot_loc=None, n_max_monos=8, use_stellar_dens=True, **kwargs)¶
lc ID mono_SNR_thresh=6.5 - threshold in sigma mono_BIC_thresh=-10 - threshold in BIC to be used for a significant monotransit n_durs=5 poly_order=3 - polynomial order to use for a “no transit” fit n_oversamp=10 - oversampling factor wrt to durations from which to match to lightcurve binsize=1/96. - size of bins in days transit_zoom=3.5 - size (in transit durations) to cut around transit when minimizing transit model use_flat=True - flattens lightcurve before monotransit search use_binned=True use_poly=True - fits transits (and sin) with a polynomial (order = poly_order-1) to account for variability Rs=None Ms=None Teff=None plot=False plot_loc=None use_stellar_dens=True - use stellar density to produce transit templates to search.
- MonoTools.search_old.MonoVetting(ID, mission, tcen=None, tdur=None, overwrite=None, do_search=True, do_fit=False, coords=None, lc=None, useL2=False, PL_ror_thresh=0.2, variable_llk_thresh=5, file_loc=None, plot=True, **kwargs)¶
#Here we’re going to initialise the Monotransit fitting by searching for other planets/transits/secondaries and filtering out binaries. INPUTS: - ID - mission - useL2=False - PL_ror_thresh=0.2
- **kwargs:
StarPars=None, a list of radius, rho, teff and logg which are each lists of values/errors
multi_SNR_thresh=6.25,
plot=True
file_loc - a location to store images/files
overwrite=False
For MonoTransitSearch: - mono_BIC_thresh=-10 - mono_SNR_thresh - n_oversamp=75, - use_binned=True - use_flat=True - use_poly=True - binsize=1/96.0, - Rs=Rstar[0] - Ms=rhostar[0]*Rstar[0]**3 - Teff=Teff[0], - plot=plot - plot_loc=file_loc+”/” - poly_order=4
- MonoTools.search_old.PeriodicPlanetSearch(lc, ID, planets, use_binned=False, use_flat=True, binsize=0.010416666666666666, n_search_loops=5, rhostar=None, Ms=1.0, Rs=1.0, Teff=5800, multi_FAP_thresh=0.00125, multi_SNR_thresh=7.0, plot=False, plot_loc=None, mask_prev_planets=True, **kwargs)¶
- MonoTools.search_old.PlotMonoSearch(lc, ID, monosearchparams, mono_dic, interpmodels, tdurs, use_flat=True, use_binned=True, use_poly=False, transit_zoom=2.5, plot_loc=None, custom_mask=None, **kwargs)¶
- MonoTools.search_old.Poly_lnprob(params, x, y, yerr, priors, polyorder=2)¶
- MonoTools.search_old.Poly_neg_lnprob(params, x, y, yerr, priors, polyorder)¶
- MonoTools.search_old.QuickMonoFit(lc, it0, dur, Rs=None, Ms=None, Teff=None, useL2=False, fit_poly=True, force_tdur=False, polyorder=2, ndurs=4.2, how='mono', init_period=None, fluxindex='flux_flat', mask=None, **kwargs)¶
Perform Quick fit of MonoTransit (or )
- Parameters
lc ([type]) – [description]
it0 ([type]) – [description]
dur ([type]) – [description]
Rs ([type], optional) – [description]. Defaults to None.
Ms ([type], optional) – [description]. Defaults to None.
Teff ([type], optional) – [description]. Defaults to None.
useL2 (bool, optional) – [description]. Defaults to False.
fit_poly (bool, optional) – [description]. Defaults to True.
force_tdur (bool, optional) – [description]. Defaults to False.
polyorder (int, optional) – [description]. Defaults to 2.
ndurs (float, optional) – [description]. Defaults to 4.2.
how (str, optional) – [description]. Defaults to ‘mono’.
init_period ([type], optional) – [description]. Defaults to None.
fluxindex (str, optional) – [description]. Defaults to ‘flux_flat’.
mask ([type], optional) – [description]. Defaults to None.
- Returns
[description]
- Return type
[type]
- MonoTools.search_old.Sinusoid_lnprob(params, x, y, yerr, priors, polyorder=2)¶
- MonoTools.search_old.Sinusoid_neg_lnprob(params, x, y, yerr, priors, polyorder)¶
- MonoTools.search_old.Step_neg_lnprob(params, x, y, yerr, priors, polyorder, npolys)¶
- MonoTools.search_old.VariabilityCheck(lc, params, ID, modeltype='all', plot=False, plot_loc=None, ndurs=2.4, polyorder=1, return_fit_lcs=False, **kwargs)¶
- MonoTools.search_old.VetCand(pl_dic, pl, ID, lc, mission, Rs=1.0, Ms=1.0, Teff=5800, mono_SNR_thresh=6.5, mono_SNR_r_thresh=5, variable_llk_thresh=5, plot=False, file_loc=None, vet_do_fit=True, return_fit_lcs=False, do_cent=True, **kwargs)¶
- MonoTools.search_old.calc_min_P(time, tcen, tdur)¶
- MonoTools.search_old.centroid_lnprob(params, t, x, y, xerr, yerr, priors, interpmodel, order=3)¶
- MonoTools.search_old.centroid_neg_lnprob(params, t, x, y, xerr, yerr, priors, interpmodel, order=3)¶
- MonoTools.search_old.dipmodel_centroid(params, t, interpmodel, order)¶
- MonoTools.search_old.dipmodel_gaussian(params, x)¶
- MonoTools.search_old.dipmodel_sinusoid(params, x)¶
- MonoTools.search_old.dipmodel_step(params, x, npolys)¶
- MonoTools.search_old.exoplanet_EB_model(lc, objects, Teffs, Rs, Ms, nrep=9, try_sec=False, use_ellc=False)¶
- MonoTools.search_old.get_interpmodels(Rs, Ms, Teff, lc_time, lc_flux_unit, mission='tess', n_durs=3, gap_thresh=2.0, texp=None)¶
- MonoTools.search_old.log_gaussian(x, mu, sig, weight=0.1)¶
- MonoTools.search_old.log_likelihood_EBmodel(params, x, y, yerr, Ms, tsec=False)¶
- MonoTools.search_old.log_likelihood_centroid(params, t, x, y, xerr, yerr, interpmodel, order)¶
- MonoTools.search_old.log_likelihood_gaussian_dip(params, x, y, yerr)¶
- MonoTools.search_old.log_likelihood_poly(params, x, y, yerr)¶
- MonoTools.search_old.log_likelihood_sinusoid(params, x, y, yerr)¶
- MonoTools.search_old.log_likelihood_step(params, x, y, yerr, npolys)¶
- MonoTools.search_old.minimize_EBmodel(lc, objects, Teffs, Rs, Ms, nrep=9, try_sec=False, use_ellc=False)¶
- MonoTools.search_old.pri_sec_const(time, t_pri, dur_pri, t_sec=None, dur_sec=None)¶
- MonoTools.search_old.theano_pars = {'base_compiledir': '/Volumes/LUVOIR/MonoToolsData/.theano_dir_3', 'device': 'cpu', 'floatX': 'float64', 'gcc.cxxflags': '-fbracket-depth=1024'}¶
- if MonoData_savepath==”/Users/hosborn/python/MonoToolsData” or MonoData_savepath==”/Volumes/LUVOIR/MonoToolsData”:
theano_pars[‘cxx’]=’/usr/local/Cellar/gcc/9.3.0_1/bin/g++-9’
- if MonoData_savepath==”/Users/hosborn/python/MonoToolsData” or MonoData_savepath==”/Volumes/LUVOIR/MonoToolsData”:
theano_pars[‘cxx’]=’cxx=/Library/Developer/CommandLineTools/usr/bin/g++’
- MonoTools.search_old.xoEB(lc, planets)¶
MonoTools.starpars module¶
- MonoTools.starpars.Assemble_and_run_isoclassify(icid, sc, mission, survey_dat, exofop_dat, errboost=0.2, spec_dat=None, useGaiaLum=True, useGaiaBR=True, useBV=True, useGaiaSpec=True, use2mass=True, useGriz=True, useGaiaAg=True)¶
- MonoTools.starpars.CheckSpecCsv(radec, icid, thresh=<Quantity 20. arcsec>)¶
- MonoTools.starpars.GetExoFop(icid, mission='tess', file='')¶
- MonoTools.starpars.GetKICinfo(kic)¶
- MonoTools.starpars.IsoClass(icid, mission, coor, ic_info=None, return_best=True, errboost=0.05, useGaiaLum=True, useGaiaBR=True, useGaiaSpec=True, useBV=True, use2mass=True, useGriz=True, useGaiaAg=True)¶
- MonoTools.starpars.LoadDust(sc, plx, dust='allsky')¶
- MonoTools.starpars.LoadModel()¶
- MonoTools.starpars.MainSequenceFit(dist, V)¶
- MonoTools.starpars.QueryCats(n, ser, mission, APASS)¶
- MonoTools.starpars.QueryGaiaAndSurveys(sc, CONESIZE=<Quantity 15. arcsec>, savefile=None, mission='tess', loop_gaia=False)¶
- MonoTools.starpars.QueryNearbyGaia(sc, CONESIZE, file=None)¶
- MonoTools.starpars.RenameSeries(info)¶
- MonoTools.starpars.TICdata(tics, sect=None, getImageData=False)¶
Download TESS stellar data
- Parameters
IDs (tics -- list of TESS) –
- Returns
pandas DataFrame of stellar info from TIC.
- MonoTools.starpars.compileInfos(ID, norminfo, tic_dat, epicdat)¶
- MonoTools.starpars.dens2(logg, loggerr1, loggerr2, rad, raderr1, raderr2, mass, masserr1, masserr2, nd=6000, returnpost=False)¶
- MonoTools.starpars.getStellarDensity(ID, mission, errboost=0.1)¶
- MonoTools.starpars.getStellarInfo(ID, hdr, mission, radec=None, overwrite=False, fileloc=None, savedf=True, use_surveys=True)¶
- MonoTools.starpars.getStellarInfoFromCsv(ID, mission, radec=None, k2tab=None, keptabs=None, use_isochrones=0)¶
- MonoTools.starpars.make_numeric(df)¶
- MonoTools.starpars.mastQuery(request)¶
Perform a MAST query.
- Parameters
(dictionary) (request) –
head (Returns) –
headers (content where head is the response HTTP) –
data (and content is the returned) –
- MonoTools.starpars.starpars(icid, mission, errboost=0.1, radec=None, return_best=True, useGaiaLum=True, useGaiaBR=True, useGaiaSpec=True, useBV=True, use2mass=True, useGriz=True, useGaiaAg=True, use_surveys=False)¶
MonoTools.tools module¶
- MonoTools.tools.CutAnomDiff(flux, thresh=4.2)¶
- MonoTools.tools.CutHighRegions(flux, mask, std_thresh=3.2, n_pts=25, n_loops=2)¶
- MonoTools.tools.GetSavename(ID, mission, how='load', suffix='mcmc.pickle', overwrite=False, savefileloc=None)¶
# Get unique savename (defaults to MCMC suffic) with format: # [savefileloc]/[T/K]IC[11-number ID]_[20YY-MM-DD]_[n]_mcmc.pickle # # INPUTS: # - ID # - mission - (TESS/K2/Kepler) # - how : ‘load’ or ‘save’ # - suffix : final part of file string. default is _mcmc.pickle # - overwrite : if ‘save’, whether to overwrite past save or not. # - savefileloc : file location of files to save (default: ‘MonoTools/[T/K]ID[11-number ID]/ # # OUTPUTS: # - filepath
- MonoTools.tools.K2_lc(epic, coor=None, pers=None, durs=None, t0s=None, use_ppt=True)¶
# Opens K2 lc
- MonoTools.tools.LoadLc(lcid, mission='tess', file_loc=None)¶
- MonoTools.tools.LoadPickle(ID, mission, loadname=None, savefileloc=None)¶
- MonoTools.tools.PlotCorner(trace, ID, mission='TESS', varnames=['b', 'ecc', 'period', 'r_pl', 'u_star', 'vrel'], savename=None, overwrite=False, savefileloc=None, returnfig=False, tracemask=None)¶
- MonoTools.tools.RunFromScratch(ID, mission, tcen, tdur, ra=None, dec=None, mono_SNRthresh=6.0, other_planet_SNRthresh=6.0, PL_ror_thresh=0.2)¶
# Given only an ID, mission, tcen and tdur, this function will # - get the lightcurve and stellar parameters # - check if the candidate is a false positive # - Search for other transits and/or planets in the lightcurve # - Run the required Namaste model for all high-SNR planet candidates
- MonoTools.tools.SavePickle(trace, ID, mission, savename=None, overwrite=False, savefileloc=None)¶
- MonoTools.tools.TESS_lc(tic, sectors='all', use_ppt=True, coords=None, use_qlp=None, use_eleanor=None, data_loc=None, search_fast=False, **kwargs)¶
- MonoTools.tools.ToLatexTable(trace, ID, mission='TESS', varnames='all', order='columns', savename=None, overwrite=False, savefileloc=None, tracemask=None)¶
- MonoTools.tools.bin_lc_segment(lc_segment, binsize, return_digi=False)¶
- MonoTools.tools.create_transit_mask(t, tcens, tdurs, maskdist=1.1)¶
- MonoTools.tools.cutLc(lctimes, max_len=10000, return_bool=True, transit_mask=None)¶
- MonoTools.tools.dopolyfit(win, mask=None, stepcent=0.0, d=3, ni=10, sigclip=3)¶
- MonoTools.tools.find_time_regions(time, split_gap_size=1.5)¶
- MonoTools.tools.formwindow(dat, cent, size, boxsize, gapthresh=1.0)¶
- MonoTools.tools.getCorotLC(corid, use_ppt=True, **kwargs)¶
- MonoTools.tools.getK2lc(epic, camp, saveloc=None, pers=None, durs=None, t0s=None, use_ppt=True)¶
Gets (or tries to get) all LCs from K2 sources. Order is Everest > Vanderburg > PDC.
- MonoTools.tools.getKeplerLC(kic, cadence='long', use_ppt=True, **kwargs)¶
This module uses the KIC of a planet candidate to download lightcurves
- Parameters
kic – EPIC (K2) or KIC (Kepler) id number
- Returns
lightcurve
- MonoTools.tools.getLDs(Ts, logg=4.43812, FeH=0.0, mission='TESS')¶
- MonoTools.tools.kepler_spline(time, flux, flux_mask=None, transit_mask=None, bk_space=1.25, maxiter=5, outlier_cut=3, polydegree=3, reflect=False)¶
Computes a best-fit spline curve for a light curve segment. The spline is fit using an iterative process to remove outliers that may cause the spline to be “pulled” by discrepent points. In each iteration the spline is fit, and if there are any points where the absolute deviation from the median residual is at least 3*sigma (where sigma is a robust estimate of the standard deviation of the residuals), those points are removed and the spline is re-fit. :param time: Numpy array; the time values of the light curve. :param flux: Numpy array; the flux (brightness) values of the light curve. :param flux_mask: Numpy array where False values refer to anomalies. Defaults to None :type flux_mask: np.ndarray of booleans, optional :param transit_mask: Numpy array where False values refer to in-transit points :type transit_mask: np.ndarray of booleans, optional :param bk_space: Spline break point spacing in time units. :param maxiter: Maximum number of attempts to fit the spline after removing badly
fit points.
- Parameters
outlier_cut – The maximum number of standard deviations from the median spline residual before a point is considered an outlier.
polydegree – Polynomial degre. Defaults to 3
reflect – Whether to perform spline fit using reflection of final time…
- Returns
- The values of the fitted spline corresponding to the input time
values.
mask: Boolean mask indicating the points used to fit the final spline.
- Return type
spline
- Raises
InsufficientPointsError – If there were insufficient points (after removing outliers) for spline fitting.
SplineError – If the spline could not be fit, for example if the breakpoint spacing is too small.
- MonoTools.tools.lcBin(lc, binsize=0.020833333333333332, split_gap_size=0.8, use_flat=True, use_masked=True, use_raw=False, extramask=None, modify_lc=True)¶
- MonoTools.tools.lcFlatten(lc, winsize=3.5, stepsize=0.15, polydegree=2, niter=10, sigmaclip=3.0, gapthreshold=1.0, use_binned=False, use_mask=True, reflect=True, transit_mask=None, debug=False)¶
#Flattens any lightcurve while maintaining in-transit depth.
Args: lc. # dictionary with time,flux,flux_err, flux_unit (1.0 or 0.001 [ppt]) and mask winsize = 2 #days, size of polynomial fitting region stepsize = 0.2 #days, size of region within polynomial region to detrend polydegree = 3 #degree of polynomial to fit to local curve niter = 20 #number of iterations to fit polynomial, clipping points significantly deviant from curve each time. sigmaclip = 3. #significance at which points are clipped (as niter) gapthreshold = 1.0 #days, threshold at which a gap in the time series is detected and the local curve is adjusted to not run over it use_binned = False. #Using the binned values in the lc dict use_mask = True. #Use the lightcurve mask to remove pre-determined anomalous values from fitting reflect = True #Whether to use end-of-lightcurve reflection to remove poor end-of-lc detrending transit_mask = None #bolean array masking known transits so that their depressed flux wont influence the polynomial fitting
- MonoTools.tools.lcStack(lcs)¶
- MonoTools.tools.lcStackDicts(lcdicts, ordered=None)¶
- MonoTools.tools.maskLc(lc, fhead, cut_all_anom_lim=5.0, use_ppt=False, end_of_orbit=True, mask=None, use_binned=False, use_flat=False, mask_islands=True, input_mask=None)¶
- MonoTools.tools.observed(tic, radec=None, maxsect=50)¶
- MonoTools.tools.openEverest(epic, camp, pers=None, durs=None, t0s=None, use_ppt=True, **kwargs)¶
- MonoTools.tools.openFits(f, fname, mission, cut_all_anom_lim=4.0, use_ppt=True, force_raw_flux=False, end_of_orbit=False, mask=None, **kwargs)¶
opens and processes all lightcurve files (especially, but not only, fits files).
- Parameters
f ([type]) – [description]
fname ([type]) – [description]
mission ([type]) – [description]
cut_all_anom_lim (float, optional) – [description]. Defaults to 4.0.
use_ppt (bool, optional) – [description]. Defaults to True.
force_raw_flux (bool, optional) – [description]. Defaults to False.
end_of_orbit (bool, optional) – Cut/fix the end-of-orbit flux? Defaults to False.
mask ([type], optional) – [description]. Defaults to None.
- Returns
[description]
- Return type
[type]
- MonoTools.tools.openLightCurve(ID, mission, coor=None, use_ppt=True, other_data=True, jd_base=2457000, save=True, **kwargs)¶
- MonoTools.tools.openPDC(epic, camp, use_ppt=True, **kwargs)¶
- MonoTools.tools.openVand(epic, camp, v=1, use_ppt=True, **kwargs)¶
- MonoTools.tools.partition_list(a, k)¶
AI is creating summary for partition_list
- Parameters
a (list) – Ordered list of lengths that we wish to evenly split into k pieces
k (int) – Number of parts along which to split a
- Returns
Ordered index of which of k bins the value in a belongs
- Return type
list
- MonoTools.tools.robust_mean(y, cut)¶
Computes a robust mean estimate in the presence of outliers. :param y: 1D numpy array. Assumed to be normally distributed with outliers. :param cut: Points more than this number of standard deviations from the median are
ignored.
- Returns
A robust estimate of the mean of y. mean_stddev: The standard deviation of the mean. mask: Boolean array with the same length as y. Values corresponding to
outliers in y are False. All other values are True.
- Return type
mean
- MonoTools.tools.update_lc_locs(epoch, most_recent_sect)¶
- MonoTools.tools.vals_to_latex(vals)¶
- MonoTools.tools.weighted_avg_and_std(values, errs, masknans=True, axis=None)¶
Return the weighted average and standard deviation.
values, weights – Numpy ndarrays with the same shape.