Esempio n. 1
0
 def test_clearsky_cache_key(self):
     cs = csd.Clearsky()
     target_datetime = datetime(2010, 6, 19, 22, 15)
     config = read_configuration_file(config_test.DUMMY_TEST_CFG_PATH)
     key = cs._generate_cache_key(target_datetime,
                                  config.stations[Station.BND])
     self.assertEqual(key, "40.0519;-88.3731;230.00;2010-06-19 22:15:00")
Esempio n. 2
0
 def test_clearsky_prediction_function(self):
     target_datetime = datetime(2010, 6, 19, 22, 15)
     config = read_configuration_file(config_test.DUMMY_TEST_CFG_PATH)
     preditions = csd.Clearsky().calculate_clearsky_values(
         config.stations[Station.BND], target_datetime)
     self.assertCloseTo(preditions[csd.CSMDOffset.GHI_T], 471.675670)
     self.assertCloseTo(preditions[csd.CSMDOffset.GHI_T_1h], 280.165857)
     self.assertCloseTo(preditions[csd.CSMDOffset.GHI_T_3h], 0.397029)
     self.assertCloseTo(preditions[csd.CSMDOffset.GHI_T_6h], 0.0)
Esempio n. 3
0
 def test_clearsky_prediction_uncached_performance(self):
     target_datetime = datetime(2010, 6, 19, 22, 15)
     config = read_configuration_file(config_test.DUMMY_TEST_CFG_PATH)
     start_time = time.time()
     iterations = 100
     for i in range(0, iterations):
         csd.Clearsky(clear_cache=True).calculate_clearsky_values(
             config.stations[Station.BND], target_datetime)
     delta = time.time() - start_time
     iterations_per_seconde = iterations / delta
     self.assertLess(delta, 4)  # 3.59s on i5 8600k
     self.assertGreater(iterations_per_seconde, 25)  # 27.57 IPS. Too slow!
Esempio n. 4
0
 def test_clearsky_prediction_cached_performance(self):
     target_datetime = datetime(2010, 6, 19, 22, 15)
     config = read_configuration_file(config_test.DUMMY_TEST_CFG_PATH)
     start_time = time.time()
     iterations = 1000
     cs = csd.Clearsky()
     for i in range(0, iterations):
         cs.calculate_clearsky_values(config.stations[Station.BND],
                                      target_datetime)
     delta = time.time() - start_time
     iterations_per_seconde = iterations / delta
     self.assertLess(delta, 0.1)  # 0.058s on i5 8600k
     self.assertGreater(iterations_per_seconde, 25)  # 17 196 IPS. Ok!
Esempio n. 5
0
 def test_precompute(self):
     meta_config = config.read_configuration_file(
         "tests/data/samples/train_config_raphael.json")
     target_datetimes = pd.Series(meta_config.target_datetimes)
     stations = meta_config.stations
     clearsky = csd.Clearsky()
     clearsky._precompute_clearsky_values(target_datetimes, stations)
     self.assertCloseTo(
         clearsky.cache["40.0519;-88.3731;230.00;2015-01-04 19:15:00"][0],
         414.271049)
     self.assertCloseTo(
         clearsky.cache["40.0519;-88.3731;230.00;2014-07-10 00:15:00"][0],
         98.633557)
Esempio n. 6
0
    def _create_data_loader(self, target_datetimes=None):
        config = read_configuration_file(DUMMY_TRAIN_CFG_PATH)

        if target_datetimes is None:
            target_datetimes = config.target_datetimes

        station = Station.BND

        return csd.prepare_dataloader(
            config.catalog,
            target_datetimes,
            station,
            config.stations[station],
            config.target_time_offsets,
            {},
        )
    def test_metadata_format(self):
        config = cf.read_configuration_file(config_test.DUMMY_TEST_CFG_PATH)
        metadata = Metadata(
            "",
            [],
            False,
            "",
            0,
            datetime=datetime(2010, 6, 19, 22, 15),
            coordinates=config.stations[cf.Station.BND],
        )

        self.dataloader = DataLoader(
            lambda: [metadata],
            self.image_reader,
            DataloaderConfig(features=[Feature.metadata]),
        )

        for (meta, ) in self.dataloader.generator():
            self.assertCloseTo(meta[MetadataFeatureIndex.GHI_T], 471.675670)
            self.assertCloseTo(meta[MetadataFeatureIndex.GHI_T_1h], 280.165857)
            self.assertCloseTo(meta[MetadataFeatureIndex.GHI_T_3h], 0.397029)
            self.assertCloseTo(meta[MetadataFeatureIndex.GHI_T_6h], 0.0)
 def setUp(self):
     self.config = read_configuration_file(DUMMY_TEST_CFG_PATH)