Skip to content
Snippets Groups Projects
data_constants_2d.py 1.01 KiB
Newer Older
from source.data_source import *


class DataConstants2D(DataSource):

    def download(self, start_date: datetime, end_date: datetime) -> bool:
        """Generate constants

        :param Source self: mock source
        :param datetime start_date: start date
        :param datetime end_date: end date
        :returns: bool
        """
        real_start_date, real_end_date, mode = self.compute_real_dates(start_date, end_date)
        duration_seconds = (real_end_date - real_start_date).total_seconds()
        nr_time_steps = int(duration_seconds // self.constants_time_step) + 1

        self.variables[0].values = 2.0 * np.ones(nr_time_steps)
        self.variables[1].values = 25.0 * np.ones(nr_time_steps)

        timestep_seconds = timedelta(seconds=self.constants_time_step)
        times: np.ndarray = np.arange(
            real_start_date, real_end_date + timestep_seconds, timestep_seconds
        )
        for idx in range(len(self.variables)):
            self.variables[idx].times = times

        return True