예제 #1
0
 def setUpClass(cls) -> None:
     with contextlib.redirect_stdout(None):
         reader = api_reader.ApiReader(
             tests.TEST_DATA_DIR,
             False,
             ReadFilter(extensions={".rdvxm"}, station_ids={"0000000001"}),
         )
         cls.apim_station = reader.get_station_by_id("0000000001")[0]
         reader = api_reader.ApiReader(
             tests.TEST_DATA_DIR,
             False,
             ReadFilter(extensions={".rdvxz"}, station_ids={"1637650010"}),
         )
         cls.api900_station = reader.get_station_by_id("1637650010")[0]
예제 #2
0
 def test_read_all_station_ids_no_match(self):
     api1000_dir = os.path.join(self.input_dir, "api1000")
     reader = api_reader.ApiReader(api1000_dir, True, ReadFilter(station_ids={"1000000900"}))
     result = reader.index_summary.total_packets()
     self.assertEqual(result, 0)
     result_by_id = reader.read_files_by_id("1000000900")
     self.assertIsNone(result_by_id)
예제 #3
0
 def test_read_all_start_time_no_match(self):
     reader = api_reader.ApiReader(
         self.input_dir,
         True,
         ReadFilter(start_dt=dtu.datetime_from_epoch_seconds_utc(1700000000)),
     )
     result = reader.index_summary.total_packets()
     self.assertEqual(result, 0)
예제 #4
0
 def test_read_all_api900_in_structured_dir(self):
     reader = api_reader.ApiReader(
         self.input_dir, True, ReadFilter(extensions=self.api_900_extensions)
     )
     result = reader.index_summary.total_packets()
     self.assertEqual(result, 2)
     result_by_id = reader.read_files_by_id("1000000900")
     self.assertEqual(len(result_by_id), 2)
     self.assertEqual(
         result_by_id[0].station_information.id, "1000000900"
     )
예제 #5
0
 def test_read_all_station_ids(self):
     reader = api_reader.ApiReader(
         self.input_dir, True, ReadFilter(station_ids={"1000001000", "2000001000"})
     )
     result = reader.index_summary.total_packets()
     self.assertEqual(result, 2)
     result_by_id = reader.read_files_by_id("1000001000")
     self.assertEqual(len(result_by_id), 2)
     self.assertEqual(
         result_by_id[0].station_information.id, "1000001000"
     )
예제 #6
0
 def test_filter_loop(self):
     filter_ids = ["1000000900", "1000001000", "2000000900"]
     final_result = 0
     for f_id in filter_ids:
         reader = api_reader.ApiReader(self.input_dir, True, ReadFilter(station_ids={f_id}))
         result = reader.index_summary.total_packets()
         if result == 0:
             self.assertTrue("2000000900" in reader.filter.station_ids)
             continue  # skip failed filter result
         self.assertEqual(result, 2)
         final_result += result
     self.assertEqual(final_result, 4)
예제 #7
0
 def test_read_all_end_time(self):
     reader = api_reader.ApiReader(
         self.input_dir,
         True,
         ReadFilter(end_dt_buf=timedelta(seconds=30),
                    end_dt=dtu.datetime_from_epoch_seconds_utc(1611696100)),
     )
     result = reader.index_summary.total_packets()
     self.assertEqual(result, 2)
     result_by_id = reader.read_files_by_id("1000000900")
     self.assertEqual(len(result_by_id), 1)
     self.assertEqual(
         result_by_id[0].station_information.id, "1000000900"
     )
예제 #8
0
 def test_read_all_in_unstructured_dir(self):
     reader = api_reader.ApiReader(self.input_dir)
     result = reader.index_summary.total_packets()
     self.assertEqual(result, 2)
     result_by_id = reader.read_files_by_id("2000001000")
     self.assertEqual(len(result_by_id), 1)
     self.assertEqual(
         result_by_id[0].station_information.id, "2000001000"
     )
     result_by_id = reader.read_files_by_id("2000000900")
     self.assertEqual(len(result_by_id), 1)
     self.assertEqual(
         result_by_id[0].station_information.id, "2000000900"
     )
예제 #9
0
 def setUpClass(cls) -> None:
     with contextlib.redirect_stdout(None):
         result = api_reader.ApiReader(tests.TEST_DATA_DIR, structured_dir=False,
                                       read_filter=ReadFilter(station_ids={"1637680001"}))
         cls.timesync = ts.TimeSync().from_raw_packets(result.read_files_by_id("1637680001"))