def test_bandpass(self): wave = np.arange(1, 101.) flux = util.gaussian(wave, 50, 3) fw = wave ft = np.zeros(100) ft[40:60] = 1 w, f = util.bandpass(wave, flux, fw=fw, ft=ft) flux_analytical = util.sigma(10 / 3.) * 0.05 assert allclose(f, flux_analytical, 1e-4) w, f, e = util.bandpass(wave, flux, np.ones(100), fw=fw, ft=ft) assert allclose(f, flux_analytical, 1e-4) fw = [1, 39.9, 40, 59, 59.1, 100] ft = [0, 0, 1, 1, 0, 0] w, f = util.bandpass(wave, flux, fw=fw, ft=ft, k=1) assert allclose(f, flux_analytical, 1e-4) flux = np.zeros(100) flux[50] = 1.0 fw = wave ft = np.zeros(100) ft[40:60] = 1 w, f = util.bandpass(wave, flux, fw=fw, ft=ft) assert allclose(f, 0.05)
def test_gaussian(self): assert util.gaussian(0, 0, 1) == 1 / np.sqrt(2 * pi) assert (util.gaussian(2 * np.sqrt(2 * np.log(2)) / 2.0, 0, 1) == util.gaussian(0, 0, 2)) assert util.gaussian(1, 1, 1) == 1 / np.sqrt(2 * pi)