def _load_dataset(self, dataset_name): if dataset_name == "bc-data": self._dataset = bc.load() elif dataset_name == "total-load": self._dataset = ul.total_experiment_load()[1]['Load'] else: raise RuntimeError("Invalid dataset name: %s" % dataset_name)
def _prepare_dataset(self): """Return datasets for the experiment periods containing the total load for all users in the experiment.""" load = bc.load() data = pd.DataFrame({'Load': load, 'Temperature': 0}) test_period_starts = "2010-03-15 00:00:00" (train, test) = (data[:test_period_starts], data[test_period_starts:]) return (train, test)
def _show_smoother(): import sg.data.bchydro as bchydro import matplotlib.pyplot as plt all_timeseries = bchydro.load() week = all_timeseries.data[0:24*7] sm = BSplineSmoother(week, smoothness=0) t = np.linspace(0, 1, 1000) y = sm.splev(t) plt.figure() plt.plot(t, y) plt.title("Show smoother")
def setUpModule(): np.seterr(all='raise') global bchydro_timeseries bchydro_timeseries = bchydro.load()
# Short demonstration of the utilities to load BCHydro data import sys import os from datetime import timedelta as dt import matplotlib.pyplot as plt import sg.data.bchydro as bc if __name__ == "__main__": # Option 1: load the entire dataset as a timeseries timeseries = bc.load() filtered = [x if x > 10 else 4000 for x in timeseries] plt.plot(filtered, '-') plt.title("The entire BC Hydro dataset") # Option 2: load the using the Dataset class dataset = bc.Dataset(period=dt(days=30), step_length=dt(days=7)) plt.figure() plt.plot(dataset.get_random_period(), '-') plt.title("A randomly selected 30-day period from the BC Hydro dataset") plt.show()