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
评论列表
文章目录