예제 #1
0
def getMock(zydata, confile, topfile, doufile, phofile, set_plot=False, mode="test") :
    """ downsample the truth to get more realistic light curves
    """
    if mode == "test" :
        return(None)
    else :
        _c, _y, _z, _yb = zydata.split()
        _zydata = _c + _y + _z
        zydata_dou = True2Mock(_zydata, sparse=[8, 8, 8], errfac=[0.01, 0.01, 0.01], hasgap=[True, True, True], errcov=0.0)
        zylclist_top = zydata_dou.zylclist[:2]
        zydata_top = LightCurve(zylclist_top, names=names[0:2])
        _zydata = _c + _yb
        zydata_pho = True2Mock(_zydata, sparse=[8, 8], errfac=[0.01, 0.01], hasgap=[True, True], errcov=0.0)
        if mode == "run" :
            confile = ".".join([confile, "myrun"])
            doufile = ".".join([doufile, "myrun"])
            topfile = ".".join([topfile, "myrun"])
            phofile = ".".join([phofile, "myrun"])
            zydata_dou.save_continuum(confile)
            zydata_dou.save(doufile)
            zydata_top.save(topfile)
            zydata_pho.save(phofile)
    if set_plot :
        print("plot mock light curves for continuum, yelm, zing, and yelm band lines")
        _c, _yb = zydata_pho.split()
        zymock = zydata_dou + _yb
        zymock.plot(figout="mocklc", figext=figext)
예제 #2
0
파일: demo.py 프로젝트: askielboe/JAVELIN
def getMock(zydata, confile, topfile, doufile, phofile, set_plot=False, mode="test") :
    """ downsample the truth to get more realistic light curves
    """
    if mode == "test" :
        return(None)
    else :
        _c, _y, _z, _yb = zydata.split()
        _zydata = _c + _y + _z
        zydata_dou = True2Mock(_zydata, sparse=[8, 8, 8], errfac=[0.01, 0.01, 0.01], hasgap=[True, True, True], errcov=0.0)
        zylclist_top = zydata_dou.zylclist[:2]
        zydata_top = LightCurve(zylclist_top, names=names[0:2])
        _zydata = _c + _yb
        zydata_pho = True2Mock(_zydata, sparse=[8, 8], errfac=[0.01, 0.01], hasgap=[True, True], errcov=0.0) 
        if mode == "run" :
            confile = ".".join([confile, "myrun"])
            doufile = ".".join([doufile, "myrun"])
            topfile = ".".join([topfile, "myrun"])
            phofile = ".".join([phofile, "myrun"])
            zydata_dou.save_continuum(confile)
            zydata_dou.save(doufile)
            zydata_top.save(topfile)
            zydata_pho.save(phofile)
    if set_plot :
        print("plot mock light curves for continuum, yelm, zing, and yelm band lines")
        _c, _yb = zydata_pho.split()
        zymock = zydata_dou + _yb
        zymock.plot(figout="mocklc", figext=figext)
예제 #3
0
def generateTrueLC2(covfunc="drw"):
    """ Generate RMap light curves first, with the sampling designed to allow a post-processing into the line band light curve. The simlest solution is to build light curves on dense regular time axis. The only downside here is that, only 'drw' covariance is allowed.

    covfunc : str, optional
        Name of the covariance funtion (default: drw).

    """
    if covfunc != "drw":
        raise RuntimeError(
            "current no such covfunc implemented for generateTrueLC2, see demo_covfunc.py for details on how to generate LCs using non-DRW models %s"
            % covfunc)
    ps = PredictSpear(sigma, tau, llags, lwids, lscales, spearmode="Rmap")
    mdense = np.zeros_like(jdense)
    edense = np.zeros_like(jdense)
    zylistold = [
        [jdense, mdense + lcmeans[0], edense],
        [jdense, mdense + lcmeans[1], edense],
        [jdense, mdense + lcmeans[2], edense],
    ]
    # this is for handling the prediction for Continuum, Yelm, and Zing.
    zylistnew = ps.generate(zylistold)
    # this is for handling the prediction for YelmBand.
    phlc = [jdense, mdense, edense]
    phlc[1] = zylistnew[0][1] + zylistnew[1][1]
    zylistnew.append(phlc)
    # this is for handling the prediction for YelmZingBand.
    dplc = [jdense, mdense, edense]
    dplc[1] = zylistnew[1][1] + zylistnew[2][1]
    # combine into a single LightCurve
    zylistnew.append(dplc)
    zydata = LightCurve(zylistnew, names=names)
    return (zydata)
예제 #4
0
def generateTrueLC(covfunc="kepler2_exp"):
    """generateTrueLC

    covfunc : str, optional
        Name of the covariance funtion, "drw" or "kepler2_exp" (default: kepler2_exp).

    """
    # create a `truth' mode light curve set with one continuum and two lines
    # object name: loopdeloop
    # line1 : yelm
    # line2 : zing
    jmin = np.max(lags)
    jmax = np.max(jdense)-1.0
    zylist = []
    # this is for handling the prediction for Continuum.
    if covfunc == "drw" :
        PS = PredictSignal(lcmean=0.0, covfunc=covfunc, sigma=sigma, tau=tau)
    elif covfunc == "kepler2_exp" :
        PS = PredictSignal(lcmean=0.0, covfunc=covfunc, sigma=sigma, tau=tau,
                nu=tau_cut, rank="NearlyFull")
    else :
        raise RuntimeError("current no such covfunc implemented %s"%covfunc)
    # generate signal with no error
    edense = np.zeros_like(jdense)
    sdense = PS.generate(jdense, ewant=edense)
    imin = np.searchsorted(jdense, jmin)
    imax = np.searchsorted(jdense, jmax)
    zylist.append([jdense[imin: imax], sdense[imin: imax]+lcmeans[0], edense[imin: imax]])
    # this is for handling the prediction for Yelm, and Zing.
    for i in xrange(1, 3) :
        lag  = lags[i]
        wid  = wids[i]
        scale= scales[i]
        jl, sl = generateLine(jdense, sdense, lag, wid, scale, mc_mean=0.0, ml_mean=0.0)
        imin = np.searchsorted(jl, jmin)
        imax = np.searchsorted(jl, jmax)
        # print np.mean(sl)
        zylist.append([jl[imin: imax], sl[imin: imax]+lcmeans[i], edense[imin: imax]])
        if i == 1:
            # special continuum prediction for YelmBand at the observed epochs of the YelmLine
            jdense_yb = jl[imin: imax]
            edense_yb = np.zeros_like(jdense_yb)
            sdense_yb = PS.generate(jdense_yb, ewant=edense_yb)
            phlc = [jdense_yb, sdense_yb + lcmeans[i] + zylist[1][1], edense_yb]
    # this is for handling the prediction for YelmBand.
    # combine into a single LightCurve
    zylist.append(phlc)
    zydata = LightCurve(zylist, names=names)
    return(zydata)
예제 #5
0
def True2Mock(zydata,
              sparse=[2, 4, 4],
              errfac=[0.01, 0.01, 0.01],
              hasgap=[True, True, True],
              errcov=0.0):
    """ Postprocess true light curves to observed light curves.

    Parameters
    ----------
    zydata: LightCurve
        Input true LightCurve.
    """
    test = np.array([len(sparse), len(errfac), len(hasgap)]) == zydata.nlc
    if not np.all(test):
        raise RuntimeError("input dimensions do not match")
    zylclist = zydata.zylclist
    names = zydata.names
    zylclist_new = []
    if any(hasgap):
        # some may have gaps, to make sure the sun is synchronized in all light curves, we have to do this globally.
        rj = zydata.rj
        j0 = zydata.jarr[0]
        j1 = zydata.jarr[-1]
        ng = np.floor(rj / 180.0)
    for i in xrange(zydata.nlc):
        ispa = np.arange(0, zydata.nptlist[i], sparse[i])
        j = zydata.jlist[i][ispa]
        # strip off gaps
        if hasgap[i]:
            dj = np.floor((j - j0) / 180.0)
            igap = np.where(np.mod(dj, 2) == 0)
            indx = ispa[igap]
        else:
            indx = ispa
        j = zydata.jlist[i][indx]
        m = zydata.mlist[i][indx] + zydata.blist[i]
        e = zydata.elist[i][indx]
        # adding errors
        e = e * 0.0 + m * errfac[i]
        et = generateError(e, errcov=errcov)
        m = m + et
        zylclist_new.append([j, m, e])
    zymock = LightCurve(zylclist_new, names=names)
    return (zymock)