twospec.py 文件源码

python
阅读 36 收藏 0 点赞 0 评论 0

项目:PyCS 作者: COSMOGRAIL 项目源码 文件源码
def calcr2s(lc1, lc2, reltimeshifts, spline, trace=False):
    """
    I calcuate the r2 for an array of relative time shifts.
    To be compated to calcd2 of pycs.pelt.twospec !
    """

    lc2abstimeshifts = reltimeshifts + lc2.timeshift

    def r2(lc2abstimeshift):

        # We work with copies at every trial time delay, to always start from the same position.
        mylc1 = lc1.copy()
        mylc2 = lc2.copy()
        mylc2.timeshift = lc2abstimeshift
        myspline = spline.copy()

        return pycs.spl.multiopt.opt_source([mylc1, mylc2], myspline, verbose=False, trace=trace)

    # We vectorize this before applying it to our abstimeshifts
    vecr2 = np.vectorize(r2, otypes=[np.ndarray])
    r2s = vecr2(lc2abstimeshifts)

    return r2s
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号