def test_add_rfi_phaseswitch(self): nf = 300 nt = 600 tod = np.zeros((nf, nt)) wn = np.arange(nf) + 1 frac = .2 * np.ones(nf) Amax = 10 * wn params = Struct(white_noise_scale = wn, rfiamplitude = Amax, rfideltaf = 1, rfideltat = 1, rfifrac = frac, load_rfi_template = False, rfiexponent = 1, rfienhance = 1) strategy = [CoordSpec(t,0,0,0,0) for t in range(nt)] strategy_start = datetime(2016,1,1) ctx = Struct(params = params, tod_vx = tod.copy(), frequencies = wn, strategy_coords = strategy, strategy_start = strategy_start) plugin = add_rfi_phaseswitch.Plugin(ctx) assert np.allclose(plugin.getTime(), np.arange(nt)/60./60.) plugin() assert np.sum(ctx.tod_vx) != 0 assert np.all(ctx.tod_vx == ctx.tod_vx_rfi) ctx.params.rfiday = (3.0,23.0) ctx.params.rfidamping = 0.0 ctx.tod_vx = tod plugin = add_rfi_phaseswitch.Plugin(ctx) plugin() assert np.isclose(np.sum(ctx.tod_vx), 0)
def testLoadCoords(self): params = Struct(telescope_latitude=47.2000007629395, telescope_longitude=8.5, telescope_elevation=500, integration_time=1) ctx = Struct(params=params) coords_path = os.path.join(COORDS_ROOT, "coord5m20141121.txt") ctx.coords_paths = {"2014-11-22": coords_path} ctx.strategy_start = datetime(2014, 11, 22, 17, 0, 0) ctx.tod_vx = np.empty((1, 3)) ctx.time_axis = np.arange(3) plugin = process_coords.Plugin(ctx) plugin() assert ctx.coords is not None assert len(ctx.coords.ra) == 3 assert len(ctx.coords.dec) == 3
def testLoadCoords(self): params = Struct(telescope_latitude = 47.2000007629395, telescope_longitude = 8.5, telescope_elevation = 500, integration_time = 1 ) ctx = Struct(params=params) coords_path = os.path.join(COORDS_ROOT, "coord5m20141121.txt") ctx.coords_paths = {"2014-11-22": coords_path} ctx.strategy_start = datetime(2014, 11, 22, 17, 0, 0) ctx.tod_vx = np.empty((1, 3)) ctx.time_axis = np.arange(3) plugin = process_coords.Plugin(ctx) plugin() assert ctx.coords is not None assert len(ctx.coords.ra) == 3 assert len(ctx.coords.dec) == 3
def test_add_rfi_phaseswitch(self): nf = 300 nt = 600 tod = np.zeros((nf, nt)) wn = np.arange(nf) + 1 frac = .2 * np.ones(nf) Amax = 10 * wn params = Struct(white_noise_scale=wn, rfiamplitude=Amax, rfideltaf=1, rfideltat=1, rfifrac=frac, load_rfi_template=False, rfiexponent=1, rfienhance=1) strategy = [CoordSpec(t, 0, 0, 0, 0) for t in range(nt)] strategy_start = datetime(2016, 1, 1) ctx = Struct(params=params, tod_vx=tod.copy(), frequencies=wn, strategy_coords=strategy, strategy_start=strategy_start) plugin = add_rfi_phaseswitch.Plugin(ctx) assert np.allclose(plugin.getTime(), np.arange(nt) / 60. / 60.) plugin() assert np.sum(ctx.tod_vx) != 0 assert np.all(ctx.tod_vx == ctx.tod_vx_rfi) ctx.params.rfiday = (3.0, 23.0) ctx.params.rfidamping = 0.0 ctx.tod_vx = tod plugin = add_rfi_phaseswitch.Plugin(ctx) plugin() assert np.isclose(np.sum(ctx.tod_vx), 0)