def test_extreme_week_2d(self, model_national): data = model_national._model_data_original.copy() with pytest.raises(ValueError): mask = masks.extreme( data, "csp", var="resource", how="max", length="2D", n=1, padding="calendar_week", )
def test_extreme_week_1d(self, model_national): data = model_national._model_data_original.copy() mask = masks.extreme( data, "csp", var="resource", how="max", length="1D", n=1, padding="calendar_week", ) found_days = list(mask.dayofyear.unique()) days = [18, 19, 20, 21, 22, 23, 24] assert days == found_days
def test_15min_to_2h_masking_1D(self): # The data is identical for '2005-01-01' and '2005-01-03' timesteps, # it is only different for '2005-01-02' override = { "techs.test_demand_elec.constraints.resource": "file=demand_elec_15T_to_2h.csv", "model.subset_time": None, } model = build_test_model(override, scenario="simple_supply,one_day") data = model._model_data mask = masks.extreme(data, "test_demand_elec", var="resource", how="max", length="1D") dtindex = pd.DatetimeIndex([ "2005-01-02 00:00:00", "2005-01-02 00:15:00", "2005-01-02 00:30:00", "2005-01-02 00:45:00", "2005-01-02 01:00:00", "2005-01-02 01:30:00", "2005-01-02 02:00:00", "2005-01-02 02:30:00", "2005-01-02 03:00:00", "2005-01-02 04:00:00", "2005-01-02 05:00:00", "2005-01-02 06:00:00", "2005-01-02 08:00:00", "2005-01-02 10:00:00", "2005-01-02 12:00:00", "2005-01-02 14:00:00", "2005-01-02 16:00:00", "2005-01-02 17:00:00", "2005-01-02 18:00:00", "2005-01-02 20:00:00", "2005-01-02 22:00:00", ]) assert dtindex.equals(mask)
def test_extreme(self, model_national): data = model_national._model_data_original.copy() mask = masks.extreme(data, "csp", var="resource", how="max", length="2D", n=1, padding="2H") dtindex = pd.DatetimeIndex([ "2005-01-18 22:00:00", "2005-01-18 23:00:00", "2005-01-19 00:00:00", "2005-01-19 01:00:00", "2005-01-19 02:00:00", "2005-01-19 03:00:00", "2005-01-19 04:00:00", "2005-01-19 05:00:00", "2005-01-19 06:00:00", "2005-01-19 07:00:00", "2005-01-19 08:00:00", "2005-01-19 09:00:00", "2005-01-19 10:00:00", "2005-01-19 11:00:00", "2005-01-19 12:00:00", "2005-01-19 13:00:00", "2005-01-19 14:00:00", "2005-01-19 15:00:00", "2005-01-19 16:00:00", "2005-01-19 17:00:00", "2005-01-19 18:00:00", "2005-01-19 19:00:00", "2005-01-19 20:00:00", "2005-01-19 21:00:00", "2005-01-19 22:00:00", "2005-01-19 23:00:00", "2005-01-20 00:00:00", "2005-01-20 01:00:00", "2005-01-20 02:00:00", "2005-01-20 03:00:00", "2005-01-20 04:00:00", "2005-01-20 05:00:00", "2005-01-20 06:00:00", "2005-01-20 07:00:00", "2005-01-20 08:00:00", "2005-01-20 09:00:00", "2005-01-20 10:00:00", "2005-01-20 11:00:00", "2005-01-20 12:00:00", "2005-01-20 13:00:00", "2005-01-20 14:00:00", "2005-01-20 15:00:00", "2005-01-20 16:00:00", "2005-01-20 17:00:00", "2005-01-20 18:00:00", "2005-01-20 19:00:00", "2005-01-20 20:00:00", "2005-01-20 21:00:00", "2005-01-20 22:00:00", "2005-01-20 23:00:00", "2005-01-21 00:00:00", "2005-01-21 01:00:00", ]) assert dtindex.equals(mask)