team-sagil / TimeDelay

Final project for the AstroML course, based on data from TDC1
0 stars 1 forks source link

Average correlation #22

Open asadisaghar opened 8 years ago

asadisaghar commented 8 years ago

instead of finding a maximum for the correlation function in each window, we should try to average the correlation values for various time shifts across windows and find one value as our estimated maximum correlation/time delay for each pair

redhog commented 8 years ago
def average_correlation(d):
    "d is a correlation dataset for one lc pair"
    wids = np.unique(d['window_id'])
    ws = [d[d['window_id'] == wid] for wid in wids]

    minoffset = np.max([w['offset'].min() for w in ws])
    maxoffset = np.min([w['offset'].max() for w in ws])

    ws = [w[(w['offset'] >= minoffset) & (w['offset'] <= maxoffset)] for w in ws]
    correlations = ws[0]['correlation']
    for w in ws[1:]:
        correlations += w['correlation']
    offsets = ws[0]['offset']

    return offsets, correlations