astrobase.lcmodels.transits module

This contains a trapezoid model for first order model of planetary transits light curves.

astrobase.lcmodels.transits.trapezoid_transit_func(transitparams, times, mags, errs, get_ntransitpoints=False)[source]

This returns a trapezoid transit-shaped function.

Suitable for first order modeling of transit signals.

Parameters:
  • transitparams (list of float) –

    This contains the transiting planet trapezoid model:

    transitparams = [transitperiod (time),
                     transitepoch (time),
                     transitdepth (flux or mags),
                     transitduration (phase),
                     ingressduration (phase)]
    

    All of these will then have fitted values after the fit is done.

    • for magnitudes -> transitdepth should be < 0
    • for fluxes -> transitdepth should be > 0
  • times,mags,errs (np.array) – The input time-series of measurements and associated errors for which the transit model will be generated. The times will be used to generate model mags, and the input times, mags, and errs will be resorted by model phase and returned.
Returns:

(modelmags, phase, ptimes, pmags, perrs) – Returns the model mags and phase values. Also returns the input times, mags, and errs sorted by the model’s phase.

Return type:

tuple

astrobase.lcmodels.transits.trapezoid_transit_curvefit_func(times, period, epoch, depth, duration, ingressduration, zerolevel=0.0, fixed_params=None)[source]

This is the function used for scipy.optimize.curve_fit.

Parameters:
  • times (np.array) – The array of times used to construct the transit model.
  • period (float) – The period of the transit.
  • epoch (float) – The time of mid-transit (phase 0.0). Must be in the same units as times.
  • depth (float) – The depth of the transit.
  • duration (float) – The duration of the transit in phase units.
  • ingressduration (float) – The ingress duration of the transit in phase units.
  • zerolevel (float) – The level of the measurements outside transit.
  • fixed_params (dict or None) –

    If this is provided, must be a dict containing the parameters to fix and their values. Should be of the form below:

    {'period': fixed value,
     'epoch': fixed value,
     'depth': fixed value,
     'duration': fixed value,
     'ingressduration': fixed value}
    

    Any parameter in the dict provided will have its parameter fixed to the provided value. This is best done with an application of functools.partial before passing the function to the scipy.optimize.curve_fit function, e.g.:

    curvefit_func = functools.partial(
                        transits.trapezoid_transit_curvefit_func,
                        zerolevel=np.median(mags),
                        fixed_params={'ingressduration':0.05})
    
    fit_params, fit_cov = scipy.optimize.curve_fit(
                            curvefit_func,
                            times, mags,
                            p0=initial_params,
                            sigma=errs,
                            ...)
    
Returns:

model – Returns the transit model as an np.array. This is in the same order as the times input array.

Return type:

np.array

astrobase.lcmodels.transits.trapezoid_transit_residual(transitparams, times, mags, errs)[source]

This returns the residual between the modelmags and the actual mags.

Parameters:
  • transitparams (list of float) –

    This contains the transiting planet trapezoid model:

    transitparams = [transitperiod (time),
                     transitepoch (time),
                     transitdepth (flux or mags),
                     transitduration (phase),
                     ingressduration (phase)]
    

    All of these will then have fitted values after the fit is done.

    • for magnitudes -> transitdepth should be < 0
    • for fluxes -> transitdepth should be > 0
  • times,mags,errs (np.array) – The input time-series of measurements and associated errors for which the transit model will be generated. The times will be used to generate model mags, and the input times, mags, and errs will be resorted by model phase and returned.
Returns:

The residuals between the input mags and generated modelmags, weighted by the measurement errors in errs.

Return type:

np.array