コード例 #1
0
    def setup(self):
        n_frequencies = 10
        params = Struct(file_fmt = "TEST_{mode}_{polarization}_{date}.h5",
                        strategy_start = "2015-01-01-00:00:00",
                        strategy_step_size = 1,
                        time_range = 5,
                        mode = 'MP',
                        polarizations = ['PXX'],
                        instrument = "hide.spectrometer.M9703A")
        
        tod = np.zeros((n_frequencies, 10))
        
        strategy_start = parse_datetime(params.strategy_start)
        self.ctx = Struct(params = params,
                          tod_vx = tod,
                          tod_vy = tod,
                          frequencies = np.arange(n_frequencies),
                          strategy_idx = 0,
                          strategy_start = strategy_start,
                          strategy_end = parse_datetime("2015-01-01-00:00:10"),
                          batch_start_date = strategy_start)

        dummy_strategy = center.load_strategy(self.ctx)
        self.ctx.strategy_coords = dummy_strategy
        
        self.plugin = write_tod_phaseswitch.Plugin(self.ctx)
コード例 #2
0
def test_scheduler():
    
    # constant elevation model
    params = Struct(scheduler_file = os.path.join(ROOT_PATH,
                                                  "schedule.txt"),
                    strategy_step_size = 60,
                    time_range = 15*60,
                    telescope_latitude = 47.344192,
                    telescope_longitude = 8.114368)
    
    strategy_start = parse_datetime("2015-12-21-02:00:00")
    strategy_end   = parse_datetime("2015-12-22-09:00:00")

    ctx = Struct(params=params,
                 strategy_start=strategy_start,
                 strategy_end=strategy_end)
    
    strategy = scheduler_virtual.load_strategy(ctx)
    
    assert len(ctx.calibration["2015-12-22"]) == 1
    calib_src = ctx.calibration["2015-12-22"][0]
    assert calib_src.src == "CygA"
    assert len(strategy) == int((strategy_end - strategy_start).total_seconds())/60
    assert strategy[0].az == np.radians(200.0)
    assert strategy[0].alt == np.radians(36.0)
    
    source = gsm_point_src.SOURCES["Virtual_%s"%calib_src.src]
    assert np.allclose(strategy[-int(4*3600/2/params.strategy_step_size)].ra, source.ra) 
    assert np.allclose(strategy[-int(4*3600/2/params.strategy_step_size)].dec, source.dec)
コード例 #3
0
def test_scheduler():

    # constant elevation model
    params = Struct(scheduler_file=os.path.join(ROOT_PATH, "schedule.txt"),
                    strategy_step_size=60,
                    time_range=15 * 60,
                    telescope_latitude=47.344192,
                    telescope_longitude=8.114368)

    strategy_start = parse_datetime("2015-12-21-02:00:00")
    strategy_end = parse_datetime("2015-12-22-09:00:00")

    ctx = Struct(params=params,
                 strategy_start=strategy_start,
                 strategy_end=strategy_end)

    strategy = scheduler.load_strategy(ctx)

    assert len(ctx.calibration["2015-12-22"]) == 1
    assert len(strategy) == int(
        (strategy_end - strategy_start).total_seconds()) / 60
    assert strategy[0].az == np.radians(200.0)
    assert strategy[-1].az == np.radians(56.1684772811)
    assert strategy[0].alt == np.radians(36.0)
    assert strategy[-1].alt == np.radians(25.0529699511)
コード例 #4
0
ファイル: test_scheduler.py プロジェクト: cosmo-ethz/hide
def test_scheduler():
    
    # constant elevation model
    params = Struct(scheduler_file = os.path.join(ROOT_PATH,
                                                  "schedule.txt"),
                    strategy_step_size = 60,
                    time_range = 15*60,
                    telescope_latitude = 47.344192,
                    telescope_longitude = 8.114368)
    
    strategy_start = parse_datetime("2015-12-21-02:00:00")
    strategy_end   = parse_datetime("2015-12-22-09:00:00")

    ctx = Struct(params=params,
                 strategy_start=strategy_start,
                 strategy_end=strategy_end)
    
    strategy = scheduler.load_strategy(ctx)
    
    assert len(ctx.calibration["2015-12-22"]) == 1
    assert len(strategy) == int((strategy_end - strategy_start).total_seconds())/60
    assert strategy[0].az == np.radians(200.0)
    assert strategy[-1].az == np.radians(56.1684772811)
    assert strategy[0].alt == np.radians(36.0)
    assert strategy[-1].alt == np.radians(25.0529699511)
コード例 #5
0
def test_scheduler():

    # constant elevation model
    params = Struct(scheduler_file=os.path.join(ROOT_PATH, "schedule.txt"),
                    strategy_step_size=60,
                    time_range=15 * 60,
                    telescope_latitude=47.344192,
                    telescope_longitude=8.114368)

    strategy_start = parse_datetime("2015-12-21-02:00:00")
    strategy_end = parse_datetime("2015-12-22-09:00:00")

    ctx = Struct(params=params,
                 strategy_start=strategy_start,
                 strategy_end=strategy_end)

    strategy = scheduler_virtual.load_strategy(ctx)

    assert len(ctx.calibration["2015-12-22"]) == 1
    calib_src = ctx.calibration["2015-12-22"][0]
    assert calib_src.src == "CygA"
    assert len(strategy) == int(
        (strategy_end - strategy_start).total_seconds()) / 60
    assert strategy[0].az == np.radians(200.0)
    assert strategy[0].alt == np.radians(36.0)

    source = gsm_point_src.SOURCES["Virtual_%s" % calib_src.src]
    assert np.allclose(
        strategy[-int(4 * 3600 / 2 / params.strategy_step_size)].ra, source.ra)
    assert np.allclose(
        strategy[-int(4 * 3600 / 2 / params.strategy_step_size)].dec,
        source.dec)
コード例 #6
0
    def setup(self):
        n_frequencies = 10
        params = Struct(file_fmt="TEST_{mode}_{polarization}_{date}.h5",
                        strategy_start="2015-01-01-00:00:00",
                        strategy_step_size=1,
                        time_range=5,
                        mode='MP',
                        polarizations=['PXX'],
                        instrument="hide.spectrometer.M9703A")

        tod = np.zeros((n_frequencies, 10))

        strategy_start = parse_datetime(params.strategy_start)
        self.ctx = Struct(params=params,
                          tod_vx=tod,
                          tod_vy=tod,
                          frequencies=np.arange(n_frequencies),
                          strategy_idx=0,
                          strategy_start=strategy_start,
                          strategy_end=parse_datetime("2015-01-01-00:00:10"),
                          batch_start_date=strategy_start)

        dummy_strategy = center.load_strategy(self.ctx)
        self.ctx.strategy_coords = dummy_strategy

        self.plugin = write_tod_phaseswitch.Plugin(self.ctx)
コード例 #7
0
 def test_load_strategy(self):
     params = Struct(scanning_strategy_provider = "hide.strategy.center",
                     strategy_step_size = 1)
     
     ctx = Struct(params = params,
                  strategy_start = parse_datetime("2015-01-01-00:00:00"),
                  strategy_end   = parse_datetime("2015-01-01-00:00:10"))
     
     plugin = scanning_strategy.Plugin(ctx)
     plugin()
     
     assert ctx.strategy is not None
     assert len(ctx.strategy) == 10
コード例 #8
0
    def test_load_strategy(self):
        params = Struct(scanning_strategy_provider="hide.strategy.center",
                        strategy_step_size=1)

        ctx = Struct(params=params,
                     strategy_start=parse_datetime("2015-01-01-00:00:00"),
                     strategy_end=parse_datetime("2015-01-01-00:00:10"))

        plugin = scanning_strategy.Plugin(ctx)
        plugin()

        assert ctx.strategy is not None
        assert len(ctx.strategy) == 10
コード例 #9
0
 def test_write_coords(self):
     path = tempfile.mkdtemp()
     
     params = Struct(telescope_latitude = 47.344192,
                     telescope_longitude = 8.114368,
                     alt_delta = 3.5,
                     azimuth_pointing = 181,
                     altitude_start_pos = 41.0,
                     altitude_max_pos = 90.0,
                     strategy_step_size = 1,
                     
                     coord_step_size = 1,
                     output_path = path,
                     coordinate_file_fmt = "coord7m%s.txt"
                     )
     
     ctx = Struct(params=params,
                  strategy_start = parse_datetime("2015-01-01-00:00:00"),
                  strategy_end   = parse_datetime("2015-01-02-00:01:00")
                  )
     
     strategy = drift_scan.load_strategy(ctx)
     
     ctx.strategy = strategy
     plugin = write_coords.Plugin(ctx)
     plugin()
     
     coord_path =  os.path.join(params.output_path, 
                                "2015",
                                "01",
                                "01",
                                "coord7m20150101.txt")
     
     coords = np.genfromtxt(coord_path, delimiter = ',', names = True)
     assert len(coords) == write_coords.SEC_PER_DAY / int(params.coord_step_size)
     
     strategy_arr = np.asarray(strategy)
     N = len(coords)
     assert np.allclose(strategy_arr[:N, 1], np.radians(coords["ElAntenna"]))
     
     coord_path =  os.path.join(params.output_path, 
                                "2015",
                                "01",
                                "02",
                                "coord7m20150102.txt")
     
     coords = np.genfromtxt(coord_path, delimiter = ',', names = True)
     assert len(coords) == 60 / int(params.coord_step_size)
     
コード例 #10
0
ファイル: test_write_rfi.py プロジェクト: cosmo-ethz/hide
def test_write():
    output_path = tempfile.mkdtemp()
    n_frequencies, n_time = 10, 10
    params = Struct(file_fmt = "TEST_{mode}_{polarization}_{date}.h5",
                    strategy_start = "2015-01-01-00:00:00",
                    strategy_step_size = 1,
                    time_range = 5,
                    mode = 'MP',
                    polarizations = ['PXX'],
                    output_path = output_path,
                    instrument = "hide.spectrometer.M9703A")
        
    tod = np.zeros((n_frequencies, n_time))
    strategy = range(n_time)
    strategy_start = parse_datetime(params.strategy_start)
    ctx = Struct(params = params,
                 tod_vx = tod,
                 tod_vx_rfi = tod,
                 frequencies = np.arange(n_frequencies),
                 strategy_start = strategy_start,
                 batch_start_date = strategy_start,
                 strategy_coords = strategy)

    todplugin = write_tod_phaseswitch.Plugin(ctx)
    f = write_tod_phaseswitch.get_path(ctx, 'PXX')
    todplugin()
    rfiplugin = write_rfi.Plugin(ctx)
    rfiplugin()
    assert os.path.isfile(f)
    with h5py.File(f) as F:
        t = F[write_tod_phaseswitch.H5_P_GROUP_NAME][write_tod_phaseswitch.H5_PHASE0_NAME][:]
        r = F[write_rfi.H5_RFI_GROUP_NAME][write_tod_phaseswitch.H5_PHASE0_NAME][:]
        assert np.all(t == r)
コード例 #11
0
    def test_load_strategy(self):
        params = Struct(telescope_latitude=47.344192,
                        telescope_longitude=8.114368,
                        strategy_step_size=1)

        ctx = Struct(params=params,
                     strategy_start=parse_datetime("2015-01-01-00:00:00"),
                     strategy_end=parse_datetime("2015-01-01-00:00:10"))

        strategy = crosshair.load_strategy(ctx)

        assert strategy is not None
        assert len(strategy) == 10

        for coord in strategy:
            assert 0 <= coord.alt <= 2 * np.pi
            assert 0 <= coord.az <= 2 * np.pi
コード例 #12
0
ファイル: test_drift_scan.py プロジェクト: cosmo-ethz/hide
 def test_load_strategy(self):
     params = Struct(telescope_latitude = 47.344192,
                     telescope_longitude = 8.114368,
                     alt_delta = 3.5,
                     azimuth_pointing = 181,
                     altitude_start_pos = 41.0,
                     altitude_max_pos = 90.0,
                     strategy_step_size = 1,
                     )
     
     ctx = Struct(params=params,
                  strategy_start = parse_datetime("2015-01-01-00:00:00"),
                  strategy_end   = parse_datetime("2015-01-01-00:01:00"))
     
     strategy = drift_scan.load_strategy(ctx)
     
     assert len(strategy) == 60 / params.strategy_step_size
コード例 #13
0
    def test_load_strategy(self):
        params = Struct(
            telescope_latitude=47.344192,
            telescope_longitude=8.114368,
            alt_delta=3.5,
            azimuth_pointing=181,
            altitude_start_pos=41.0,
            altitude_max_pos=90.0,
            strategy_step_size=1,
        )

        ctx = Struct(params=params,
                     strategy_start=parse_datetime("2015-01-01-00:00:00"),
                     strategy_end=parse_datetime("2015-01-01-00:01:00"))

        strategy = drift_scan.load_strategy(ctx)

        assert len(strategy) == 60 / params.strategy_step_size
コード例 #14
0
 def test_load_strategy(self):
     params = Struct(telescope_latitude = 47.344192,
                     telescope_longitude = 8.114368,
                     strategy_step_size = 1)
     
     ctx = Struct(params = params,
                  strategy_start = parse_datetime("2015-01-01-00:00:00"),
                  strategy_end   = parse_datetime("2015-01-01-00:00:10"))
     
     strategy = crosshair.load_strategy(ctx)
     
     assert strategy is not None
     assert len(strategy) == 10
     
     for coord in strategy:
         assert 0 <= coord.alt <= 2 * np.pi
         assert 0 <= coord.az  <= 2 * np.pi
         
コード例 #15
0
    def test_write_coords(self):
        path = tempfile.mkdtemp()

        params = Struct(telescope_latitude=47.344192,
                        telescope_longitude=8.114368,
                        alt_delta=3.5,
                        azimuth_pointing=181,
                        altitude_start_pos=41.0,
                        altitude_max_pos=90.0,
                        strategy_step_size=1,
                        coord_step_size=1,
                        output_path=path,
                        coordinate_file_fmt="coord7m%s.txt")

        ctx = Struct(params=params,
                     strategy_start=parse_datetime("2015-01-01-00:00:00"),
                     strategy_end=parse_datetime("2015-01-02-00:01:00"))

        strategy = drift_scan.load_strategy(ctx)

        ctx.strategy = strategy
        plugin = write_coords.Plugin(ctx)
        plugin()

        coord_path = os.path.join(params.output_path, "2015", "01", "01",
                                  "coord7m20150101.txt")

        coords = np.genfromtxt(coord_path, delimiter=',', names=True)
        assert len(coords) == write_coords.SEC_PER_DAY / int(
            params.coord_step_size)

        strategy_arr = np.asarray(strategy)
        N = len(coords)
        assert np.allclose(strategy_arr[:N, 1],
                           np.radians(coords["ElAntenna"]))

        coord_path = os.path.join(params.output_path, "2015", "01", "02",
                                  "coord7m20150102.txt")

        coords = np.genfromtxt(coord_path, delimiter=',', names=True)
        assert len(coords) == 60 / int(params.coord_step_size)
コード例 #16
0
    def setup(self):
        n_frequencies = 10
        params = Struct(file_fmt = "SKYMAP_%s.hdf",
                        strategy_start = "2015-01-01-00:00:00",
                        strategy_step_size = 1,
                        time_range = 5)
        
        tod = np.zeros((n_frequencies, 10))
        
        strategy_start = parse_datetime(params.strategy_start)
        self.ctx = Struct(params = params,
                          tod_vx=tod,
                          tod_vy=tod,
                          frequencies = np.arange(n_frequencies),
                          strategy_idx = 0,
                          strategy_start = strategy_start,
                          strategy_end   = parse_datetime("2015-01-01-00:00:10"),
                          batch_start_date = strategy_start)

        dummy_strategy = center.load_strategy(self.ctx)
        self.ctx.strategy_coords = dummy_strategy
        
        self.plugin = write_tod.Plugin(self.ctx)
コード例 #17
0
ファイル: test_full_sky.py プロジェクト: cosmo-ethz/hide
 def test_load_strategy(self):
     params = Struct(telescope_latitude = 47.344192,
                     telescope_longitude = 8.114368,
                     beam_nside = 32,
                     strategy_step_size = 1)
     
     ctx = Struct(params = params,
                  strategy_start = parse_datetime("2015-01-01-00:00:00"),
                  )
     
     strategy = full_sky.load_strategy(ctx)
     
     assert strategy is not None
     assert len(strategy) == hp.nside2npix(params.beam_nside)
     
     for coord in strategy:
         assert 0 <= coord.alt <= 2 * np.pi
         assert 0 <= coord.az  <= 2 * np.pi
         
コード例 #18
0
ファイル: test_full_sky.py プロジェクト: chrisfinlay/hide
    def test_load_strategy(self):
        params = Struct(telescope_latitude=47.344192,
                        telescope_longitude=8.114368,
                        beam_nside=32,
                        strategy_step_size=1)

        ctx = Struct(
            params=params,
            strategy_start=parse_datetime("2015-01-01-00:00:00"),
        )

        strategy = full_sky.load_strategy(ctx)

        assert strategy is not None
        assert len(strategy) == hp.nside2npix(params.beam_nside)

        for coord in strategy:
            assert 0 <= coord.alt <= 2 * np.pi
            assert 0 <= coord.az <= 2 * np.pi
コード例 #19
0
    def test_map_strategies(self):
        durration = 10
        time_range = 5
        params = Struct(time_range=time_range,
                        strategy_step_size=1,
                        verbose=False)
        ctx = Struct(
            params=params,
            strategy_start=parse_datetime("2015-01-01-00:00:00"),
            strategy=[CoordSpec(t, 0, 0, 0, 0) for t in xrange(durration)])

        plugin = map_strategy_plugin.Plugin(ctx)

        for idx, ctx in enumerate(plugin.getWorkload()):
            assert ctx is not None
            assert ctx.strategy_idx == idx
            assert ctx.strategy_coords is not None
            assert ctx.batch_start_date is not None
            assert len(ctx.strategy_coords) == time_range

        assert idx == (durration / time_range) - 1
コード例 #20
0
 def test_map_strategies(self):
     durration = 10
     time_range = 5
     params = Struct(time_range = time_range,
                     strategy_step_size=1,
                     verbose=False
                     )
     ctx = Struct(params = params,
                  strategy_start = parse_datetime("2015-01-01-00:00:00"),
                  strategy=[CoordSpec(t, 0, 0, 0, 0) for t in xrange(durration)])
     
     plugin = map_strategy_plugin.Plugin(ctx)
     
     
     for idx, ctx in enumerate(plugin.getWorkload()):
         assert ctx is not None
         assert ctx.strategy_idx == idx
         assert ctx.strategy_coords is not None
         assert ctx.batch_start_date is not None
         assert len(ctx.strategy_coords) == time_range
     
     assert idx == (durration / time_range)-1
コード例 #21
0
ファイル: initialize.py プロジェクト: chrisfinlay/hide
 def __call__(self):
     np.random.seed(self.ctx.params.seed)
     self.ctx.strategy_start = parse_datetime(
         self.ctx.params.strategy_start)
     self.ctx.strategy_end = parse_datetime(self.ctx.params.strategy_end)
コード例 #22
0
ファイル: initialize.py プロジェクト: cosmo-ethz/hide
 def __call__(self):
     np.random.seed(self.ctx.params.seed)
     self.ctx.strategy_start = parse_datetime(self.ctx.params.strategy_start)
     self.ctx.strategy_end   = parse_datetime(self.ctx.params.strategy_end)