Esempio n. 1
0
    def __init__(self,
                 data: DataInput = "CREST",
                 initial_clearness: float = 0.99,
                 start_datetime=datetime.datetime(2014, 1, 1, 0, 0, 0),
                 **kwargs) -> None:
        """Initialize the Crest climate simulator.

        Args:
            data: the data to be used
            initial_clearness: the clearness at the start of the simulation
                It will not be used during the initialization
            start_datetime: the start of the simuulation
        """
        if data == "CREST":
            data = Crest()

        geo_dict = data.load_geographic_data()

        self.longitude = geo_dict["longitude"]
        self.latitude = geo_dict["latitude"]
        self.meridian = geo_dict["meridian"]

        # summer time is the french version of daylight saving time, sry
        self._use_summer_time = geo_dict["use_daylight_saving_time"]

        clearness_tpm, clearness_values, step_size = data.load_clearness_tpms()
        self.clearness_cdf = np.cumsum(clearness_tpm, axis=1)
        self.clearness_values = clearness_values

        check_valid_cdf(self.clearness_cdf)

        if 'step_size' in kwargs:

            if step_size != kwargs['step_size']:
                raise ValueError("'step_size' = {} was specified in {}'"
                                 ". It uses the step_size = {} from {} "
                                 " which are not the same.".format(
                                     kwargs['step_size'], self, step_size,
                                     data.load_clearness_tpms))

            kwargs = kwargs.copy()
            kwargs.pop('step_size')

        super().__init__(step_size=step_size,
                         start_datetime=start_datetime,
                         **kwargs)

        self.initialize_starting_state(initial_clearness)
Esempio n. 2
0
 def test_smaller1(self):
     # check that cdf is not decreasing
     decreasingcdf = np.array([[-0.2, 0.4, 1.], [0.2, 0.9, 1.],
                               [0.0, 0.3, 1.]])
     with self.assertRaises(ValueError):
         check_valid_cdf(decreasingcdf)
Esempio n. 3
0
 def test_invalidEnd(self):
     # check that fails if the last value is not 1
     constantcdf = np.array([[0.0, 0.2], [1., 1.]])
     with self.assertRaises(ValueError):
         check_valid_cdf(constantcdf)
Esempio n. 4
0
 def test_constant(self):
     constantcdf = np.array([[0.0, 1.], [1., 1.]])
     self.assertTrue(check_valid_cdf(constantcdf))
Esempio n. 5
0
 def test_valid(self):
     validcdf = np.array([[0.2, 1.], [0.7, 1.]])
     self.assertTrue(check_valid_cdf(validcdf))