LSSTDESC / sims_GCRCatSimInterface

LSST sims interface to gcr-catalogs
BSD 3-Clause "New" or "Revised" License
1 stars 5 forks source link

Correct DRW implementation #84

Closed jchiang87 closed 4 years ago

jchiang87 commented 4 years ago

I'll merge this at 9am PT tomorrow unless I hear otherwise.

jchiang87 commented 4 years ago

For the record, here are some light curves produced with the old version of the code, showing the incorrect behavior for different values of tau: band_dep_tau_no_rng_bug and here are light curves generated with the corrected version in this PR: agn_lc_example_drw_fix

I also computed the structure functions for different combinations of tau and SF_inf to see how the scaled versions compare to the expected behavior. Here are scaled structure functions obtained using the old version of the calculation: SF_examples_old_DRW and here are the structure functions using the corrected version: SF_examples_new_DRW

For the record, here's the code I used to compute and plot the structure functions:

def SF(t, f):
    '''Compute the structure function of f, assuming it is evenly sampled in time.'''
    npts = len(f)
    offsets = np.arange(1, npts//2)
    my_sf = np.zeros(len(offsets))
    for i, dt in enumerate(offsets):
        df = f[slice(0, npts - dt)] - f[slice(dt, npts)]
        my_sf[i] = np.sqrt(np.mean(df**2)/2.)
    return offsets*(t[1] - t[0]), my_sf

delta_mags = agn_mag_norms(mjds, z, tau, SF_inf, seed)
dt, sf = SF(mjds, delta_mags)
plt.plot(dt/tau, sf/SF_inf, s=2)