def prism_outputs_1(request): model = TemperatureSensitivityModel(cooling=True,heating=True) params = { "base_consumption": request.param[0][0], "heating_slope": request.param[0][1], "heating_reference_temperature": request.param[0][2], "cooling_slope": request.param[0][3], "cooling_reference_temperature": request.param[0][4] } start = datetime(2012,1,1) end = datetime(2014,12,31) retrofit_start_date = datetime(2013,6,1) retrofit_completion_date = datetime(2013,8,1) periods = generate_periods(start,end,jitter_intensity=0) gen = ConsumptionGenerator("electricity", "kWh", request.param[4], model, params) consumptions = gen.generate(gsod_722880_2012_2014_weather_source(), periods) consumption_kWh_per_day = [c.kWh / c.timedelta.days for c in consumptions] consumption_n_days = [p.timedelta.days for p in periods] fixture = ConsumptionHistory(consumptions), model.param_dict_to_list(params), \ request.param[1], request.param[2], \ request.param[3], request.param[4], \ retrofit_start_date, retrofit_completion_date, \ request.param[5], request.param[6], \ request.param[7], request.param[8], \ request.param[9], request.param[10], \ consumption_kWh_per_day, consumption_kWh_per_day, \ consumption_n_days, \ request.param[11] return fixture
def generated_consumption_history_pre_post_1(request): model = TemperatureSensitivityModel(cooling=True,heating=True) pre_params = { "base_consumption": request.param[0][0], "heating_slope": request.param[0][1], "heating_reference_temperature": request.param[0][2], "cooling_slope": request.param[0][3], "cooling_reference_temperature": request.param[0][4] } post_params = { "base_consumption": request.param[1][0], "heating_slope": request.param[1][1], "heating_reference_temperature": request.param[1][2], "cooling_slope": request.param[1][3], "cooling_reference_temperature": request.param[1][4] } start = datetime(2012,1,1) retrofit = datetime(2013,6,15) end = datetime(2014,12,31) pre_periods = generate_periods(start,retrofit,jitter_intensity=0) post_periods = generate_periods(retrofit,end,jitter_intensity=0) pre_gen = ConsumptionGenerator("electricity", "kWh", "degF", model, pre_params) post_gen = ConsumptionGenerator("electricity", "kWh", "degF", model, post_params) pre_consumptions = pre_gen.generate(gsod_722880_2012_2014_weather_source(), pre_periods) post_consumptions = post_gen.generate(gsod_722880_2012_2014_weather_source(), post_periods) ch = ConsumptionHistory(pre_consumptions + post_consumptions) return ch, model.param_dict_to_list(pre_params), model.param_dict_to_list(post_params), retrofit
def generated_consumption_history_with_annualized_usage_1(request): model = TemperatureSensitivityModel(cooling=True,heating=True) params = { "base_consumption": request.param[0][0], "heating_slope": request.param[0][1], "heating_reference_temperature": request.param[0][2], "cooling_slope": request.param[0][3], "cooling_reference_temperature": request.param[0][4] } start = datetime(2012,1,1) end = datetime(2014,12,31) periods = generate_periods(start,end,jitter_intensity=0) gen = ConsumptionGenerator("electricity", "kWh", "degF", model, params) consumptions = gen.generate(gsod_722880_2012_2014_weather_source(), periods) return ConsumptionHistory(consumptions), model.param_dict_to_list(params), request.param[1]
def bpi_2400_1(request): elec_params = { "base_consumption": request.param[0][0], "heating_slope": request.param[0][1], "heating_reference_temperature": request.param[0][2], "cooling_slope": request.param[0][3], "cooling_reference_temperature": request.param[0][4] } gas_params = { "base_consumption": request.param[1][0], "heating_slope": request.param[1][1], "heating_reference_temperature": request.param[1][2], } normal_cdd = request.param[2] normal_hdd = request.param[3] cvrmse_electricity = request.param[4] cvrmse_natural_gas = request.param[5] n_periods = request.param[6] time_span = request.param[7] total_cdd = request.param[8] total_hdd = request.param[9] temp_unit = request.param[10] start = datetime(2012,1,1) end = datetime(2014,12,31) periods = generate_periods(start,end,jitter_intensity=0) elec_model = TemperatureSensitivityModel(cooling=True,heating=True) gas_model = TemperatureSensitivityModel(cooling=False,heating=True) gen_elec = ConsumptionGenerator("electricity", "kWh", temp_unit, elec_model, elec_params) gen_gas = ConsumptionGenerator("natural_gas", "therms", temp_unit, gas_model, gas_params) elec_consumptions = gen_elec.generate(gsod_722880_2012_2014_weather_source(), periods) gas_consumptions = gen_gas.generate(gsod_722880_2012_2014_weather_source(), periods) ch = ConsumptionHistory(elec_consumptions + gas_consumptions) elec_param_list = elec_model.param_dict_to_list(elec_params) gas_param_list = gas_model.param_dict_to_list(gas_params) average_daily_usages_elec = [c.kWh/c.timedelta.days for c in elec_consumptions] average_daily_usages_gas = [c.therms/c.timedelta.days for c in gas_consumptions] return ch, elec_param_list, gas_param_list, normal_cdd, normal_hdd, \ cvrmse_electricity, cvrmse_natural_gas, \ n_periods, time_span, total_cdd, total_hdd, temp_unit, \ average_daily_usages_elec, average_daily_usages_gas
def time_span_1(request): model = TemperatureSensitivityModel(cooling=True,heating=True) params = { "base_consumption": request.param[0][0], "heating_slope": request.param[0][1], "heating_reference_temperature": request.param[0][2], "cooling_slope": request.param[0][3], "cooling_reference_temperature": request.param[0][4] } fuel_type = request.param[1] start, end = request.param[2] n_days = request.param[3] periods = generate_periods(start,end,jitter_intensity=0) gen = ConsumptionGenerator(fuel_type, "kWh", "degF", model, params) consumptions = gen.generate(gsod_722880_2012_2014_weather_source(), periods) param_list = model.param_dict_to_list(params) return ConsumptionHistory(consumptions), fuel_type, n_days
def test_TemperatureSensitivityModel_with_cooling(): initial_params = { "base_consumption": 0, "cooling_slope": 0, "cooling_reference_temperature": 57, } param_bounds = { "base_consumption": [0,100], "cooling_slope": [0,100], "cooling_reference_temperature": [52,72], } model = TemperatureSensitivityModel(heating=False,cooling=True,initial_params=initial_params,param_bounds=param_bounds) params = [1,1,60] observed_temps = np.array([[i] for i in range(50,70)]) usages = model.compute_usage_estimates(params,observed_temps) assert_almost_equal(usages[8:13],[1,1,1,2,3]) opt_params = model.parameter_optimization(usages, observed_temps) assert_almost_equal(params,opt_params,decimal=3)
def test_model_weather_input_not_np_array(): model = TemperatureSensitivityModel(heating=False,cooling=False) params = [1] observed_temps = [[70],[65,60]] usages = model.compute_usage_estimates(params,observed_temps) assert_almost_equal(usages,[1,2])