def __init__(self, path, time_interval=timedelta(minutes=5), gridvalueClass=GridStateFromFile, sep=";", max_iter=-1, chunk_size=None): GridValue.__init__(self, time_interval=time_interval, max_iter=max_iter, chunk_size=chunk_size) self.gridvalueClass = gridvalueClass self.data = None self.path = os.path.abspath(path) self.sep = sep try: self.subpaths = [ os.path.join(self.path, el) for el in os.listdir(self.path) if os.path.isdir(os.path.join(self.path, el)) ] self.subpaths.sort() self.subpaths = np.array(self.subpaths) except FileNotFoundError: raise ChronicsError("Path \"{}\" doesn't exists.".format( self.path)) from None if len(self.subpaths) == 0: raise ChronicsNotFoundError( "Not chronics are found in \"{}\". Make sure there are at least " "1 chronics folder there.".format(self.path)) # np.random.shuffle(self.subpaths) self.id_chron_folder_current = 0 self.chunk_size = chunk_size
def __init__(self, path, sep=";", time_interval=timedelta(minutes=5), max_iter=-1, start_datetime=datetime(year=2019, month=1, day=1), chunk_size=None): """ Build an instance of GridStateFromFile. Such an instance should be built before an :class:`grid2op.Environment` is created. Parameters ---------- path: ``str`` Used to initialize :attr:`GridStateFromFile.path` sep: ``str``, optional Used to initialize :attr:`GridStateFromFile.sep` time_interval: ``datetime.timedelta`` Used to initialize :attr:`GridValue.time_interval` max_iter: int, optional Used to initialize :attr:`GridValue.max_iter` """ GridValue.__init__(self, time_interval=time_interval, max_iter=max_iter, start_datetime=start_datetime, chunk_size=chunk_size) self.path = path self.n_ = None # maximum number of rows of the array self.tmp_max_index = None # size maximum of the current tables in memory self.load_p = None # numpy array corresponding to the current active load values in the power _grid. It has the same size as the number of loads self.load_q = None # numpy array corresponding to the current reactive load values in the power _grid. It has the same size as the number of loads self.prod_p = None # numpy array corresponding to the current active production values in the power _grid. It has the same size as the number of generators self.prod_v = None # numpy array corresponding to the current voltage production setpoint values in the power _grid. It has the same size as the number of generators # for the two following vector, the convention is the following: False(line is disconnected) / True(line is connected) self.hazards = None # numpy array representing the outage (unplanned), same size as the number of powerlines on the _grid. self.maintenance = None # numpy array representing the _maintenance (planned withdrawal of a powerline), same size as the number of powerlines on the _grid. self.current_index = -1 self.sep = sep self.names_chronics_to_backend = None # added to provide an easier access to read data in chunk self.chunk_size = chunk_size self._data_chunk = {} self._order_load_p = None self._order_load_q = None self._order_prod_p = None self._order_prod_v = None self._order_hazards = None self._order_maintenance = None # order of the names in the backend self._order_backend_loads = None self._order_backend_prods = None self._order_backend_lines = None
def __init__(self, time_interval=timedelta(minutes=5), max_iter=-1, start_datetime=datetime(year=2019, month=1, day=1), chunk_size=None, **kargs): GridValue.__init__(self, time_interval=time_interval, max_iter=max_iter, start_datetime=start_datetime, chunk_size=chunk_size)
def __init__(self, path, time_interval=timedelta(minutes=5), start_datetime=datetime(year=2019, month=1, day=1), gridvalueClass=GridStateFromFile, sep=";", max_iter=-1, chunk_size=None): GridValue.__init__(self, time_interval=time_interval, max_iter=max_iter, chunk_size=chunk_size, start_datetime=start_datetime) self.gridvalueClass = gridvalueClass self.data = None self.path = os.path.abspath(path) self.sep = sep try: self.subpaths = [ os.path.join(self.path, el) for el in os.listdir(self.path) if os.path.isdir(os.path.join(self.path, el)) ] self.subpaths.sort() self.subpaths = np.array(self.subpaths) except FileNotFoundError: raise ChronicsError("Path \"{}\" doesn't exists.".format( self.path)) from None if len(self.subpaths) == 0: raise ChronicsNotFoundError( "Not chronics are found in \"{}\". Make sure there are at least " "1 chronics folder there.".format(self.path)) # TODO clarify that # np.random.shuffle(self.subpaths) self.chunk_size = chunk_size # for saving self._order_backend_loads = None self._order_backend_prods = None self._order_backend_lines = None self._order_backend_subs = None self._names_chronics_to_backend = None # improving looping strategy self._filter = self._default_filter self._prev_cache_id = 0 self._order = None