def foldBinLightCurve(data, ntrfr, npts):
    '\n    Fold and bin light curve for input to LPP metric calculation\n    \n    data contains time, tzero, dur, priod,mes and flux (centered around zero)\n    \n    ntrfr -- number of transit fraction for binning around transit ~1.5\n    npts -- number of points in the final binning.\n    \n    '
    phaselc = np.mod(((data.time - (data.tzero - (0.5 * data.period))) / data.period), 1)
    flux = data.flux
    mes = data.mes
    if ((~ np.isnan(data.dur)) & (data.dur > 0)):
        transit_dur = data.dur
    else:
        transit_dur = ((0.2 * data.period) / 24.0)
    transit_fr = ((transit_dur / 24.0) / data.period)
    if ((transit_fr * ntrfr) > 0.5):
        transit_fr = (0.5 / ntrfr)
    binover = 1.3
    if (mes <= 20):
        binover = (((- (1 / 8.0)) * mes) + 3.8)
    endfr = 0.03
    midfr = 0.11
    a = np.concatenate((np.arange(endfr, (0.5 - midfr), (1 / npts)), np.arange((0.5 + midfr), (1 - endfr), (1 / npts))), axis=None)
    ovsamp = 4.0
    b_num = 41
    b = np.linspace((0.5 - (ntrfr * transit_fr)), (0.5 + (ntrfr * transit_fr)), b_num)
    [runta, runya] = runningMedian(phaselc, flux, (binover / npts), a)
    [runtb, runyb] = runningMedian(phaselc, flux, ((((binover * ovsamp) * ntrfr) * transit_fr) / npts), b)
    runymess = np.array((runya + runyb))
    runtmess = np.array((runta + runtb))
    srt = np.argsort(runtmess)
    runy = runymess[srt]
    runt = runtmess[srt]
    scale = ((- 1) * np.min(runyb))
    if (scale != 0):
        scaledFlux = (runy / scale)
    else:
        scaledFlux = runy
    binnedFlux = scaledFlux
    phasebins = runt
    return (binnedFlux, phasebins)
Fold and bin light curve for input to LPP metric calculation

data contains time, tzero, dur, priod,mes and flux (centered around zero)

ntrfr -- number of transit fraction for binning around transit ~1.5
npts -- number of points in the final binning.
def foldBinLightCurve(data, ntrfr, npts):
    '\n    Fold and bin light curve for input to LPP metric calculation\n    \n    data contains time, tzero, dur, priod,mes and flux (centered around zero)\n    \n    ntrfr -- number of transit fraction for binning around transit ~1.5\n    npts -- number of points in the final binning.\n    \n    '
    phaselc = np.mod(((data.time - (data.tzero - (0.5 * data.period))) / data.period), 1)
    flux = data.flux
    mes = data.mes
    if ((~ np.isnan(data.dur)) & (data.dur > 0)):
        transit_dur = data.dur
    else:
        transit_dur = ((0.2 * data.period) / 24.0)
    transit_fr = ((transit_dur / 24.0) / data.period)
    if ((transit_fr * ntrfr) > 0.5):
        transit_fr = (0.5 / ntrfr)
    binover = 1.3
    if (mes <= 20):
        binover = (((- (1 / 8.0)) * mes) + 3.8)
    endfr = 0.03
    midfr = 0.11
    a = np.concatenate((np.arange(endfr, (0.5 - midfr), (1 / npts)), np.arange((0.5 + midfr), (1 - endfr), (1 / npts))), axis=None)
    ovsamp = 4.0
    b_num = 41
    b = np.linspace((0.5 - (ntrfr * transit_fr)), (0.5 + (ntrfr * transit_fr)), b_num)
    [runta, runya] = runningMedian(phaselc, flux, (binover / npts), a)
    [runtb, runyb] = runningMedian(phaselc, flux, ((((binover * ovsamp) * ntrfr) * transit_fr) / npts), b)
    runymess = np.array((runya + runyb))
    runtmess = np.array((runta + runtb))
    srt = np.argsort(runtmess)
    runy = runymess[srt]
    runt = runtmess[srt]
    scale = ((- 1) * np.min(runyb))
    if (scale != 0):
        scaledFlux = (runy / scale)
    else:
        scaledFlux = runy
    binnedFlux = scaledFlux
    phasebins = runt
    return (binnedFlux, phasebins)