def test_getNewVals_for_newuncs_dim(): """ The output dimension of newRVs should be the same as the input dimension of newtimes """ newtimes = np.arange(10) times = np.random.uniform(0, 10, 100) rvs = np.random.uniform(-5, 5, 100) uncs = np.random.normal(loc=1., scale=0.5, size=100) newRVs, newUncs = wm.getNewVals(newtimes, times, rvs, uncs, timebin=1.) assert len(newtimes) == len(newUncs)
def test_getNewVals_unc_magnitude(): """ The median single measurement precision should be lower for the binned data. This function ensures that to be the case. """ newtimes = np.arange(10) times = np.random.uniform(0, 10, 100) rvs = np.random.normal(loc=0, scale=5, size=100) uncs = np.random.normal(loc=1., scale=0.5, size=100) newRVs, newUncs = wm.getNewVals(newtimes, times, rvs, uncs, timebin=1.) assert np.median(newUncs) < np.median(uncs)
def test_getNewVals_rv_scatter(): """ The RV scatter (standard deviation from normally distributed points about the mean should be reduced when binning observations down. This routine checks that. """ newtimes = np.arange(10) times = np.random.uniform(0, 10, 100) rvs = np.random.normal(loc=0, scale=5, size=100) uncs = np.random.normal(loc=1., scale=0.5, size=100) newRVs, newUncs = wm.getNewVals(newtimes, times, rvs, uncs, timebin=1.) assert np.std(newRVs) < np.std(rvs)
def test_big_gaps_getNewVals(): """ Ensure getNewVals routine can handle big gaps in times """ timebin = 1. times = np.concatenate((np.random.uniform(0, 10, 50), np.random.uniform(30, 40, 50))) newtimes = wm.getNewTimes(times, timebin) rvs = np.random.normal(loc=0, scale=5, size=100) uncs = np.random.normal(loc=1., scale=0.5, size=100) newRVs, newUncs = wm.getNewVals(newtimes, times, rvs, uncs, timebin=timebin) fins = np.where(np.isfinite(newUncs)) newRVs = newRVs[fins] newUncs = newUncs[fins] newtimes = newtimes[fins] assert np.median(newUncs) < np.median(uncs)