Ejemplo 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")
Ejemplo n.º 2
0
    def __init__(
            self,
            metadata: Callable[[], Iterable[Metadata]],
            image_reader: image.ImageReader,
            config: DataloaderConfig = DataloaderConfig(),
    ):
        """Load the config with the image_reader from the metadata."""
        self.metadata = metadata
        self.image_reader = image_reader
        self.config = config
        enable_clearsky_caching = False

        if config.precompute_clearsky:
            enable_clearsky_caching = True

        self.csd = csd.Clearsky(enable_caching=enable_clearsky_caching)

        if config.precompute_clearsky:
            self.csd._precompute_clearsky_values(config.target_datetimes,
                                                 config.stations)

        self.ok = 0
        self.skipped = 0

        self._readers = {
            Feature.image: self._read_image,
            Feature.target_ghi: self._read_target,
            Feature.metadata: self._read_metadata,
            Feature.target_cloud: self._read_cloudiness,
        }
Ejemplo n.º 3
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)
Ejemplo n.º 4
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!
Ejemplo n.º 5
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!
Ejemplo n.º 6
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)