Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def generated_consumption_data_with_n_periods_cdd_1(request,
gsod_722880_2012_2014_weather_source):
model_params, period, n_periods_1, n_periods_2, n_periods_3 = request.param
model = AverageDailyTemperatureSensitivityModel(cooling=True,heating=True)
params = {
"base_daily_consumption": model_params[0],
"heating_slope": model_params[1],
"heating_balance_temperature": model_params[2],
"cooling_slope": model_params[3],
"cooling_balance_temperature": model_params[4]
}
gen = MonthlyBillingConsumptionGenerator("electricity", "kWh", "degF",
model, params)
datetimes = generate_monthly_billing_datetimes(period, dist=randint(30,31))
consumption_data = gen.generate(gsod_722880_2012_2014_weather_source,
datetimes)
return consumption_data, n_periods_1, n_periods_2, n_periods_3
def generated_consumption_data_with_n_periods_hdd_1(request,
gsod_722880_2012_2014_weather_source):
model_params, period, n_periods_1, n_periods_2, n_periods_3 = request.param
model = AverageDailyTemperatureSensitivityModel(cooling=True,heating=True)
params = {
"base_daily_consumption": model_params[0],
"heating_slope": model_params[1],
"heating_balance_temperature": model_params[2],
"cooling_slope": model_params[3],
"cooling_balance_temperature": model_params[4]
}
gen = MonthlyBillingConsumptionGenerator("electricity", "kWh", "degF",
model, params)
datetimes = generate_monthly_billing_datetimes(period, dist=randint(30,31))
consumption_data = gen.generate(gsod_722880_2012_2014_weather_source,
datetimes)
return consumption_data, n_periods_1, n_periods_2, n_periods_3
def consumption_generator_no_base_load():
model = AverageDailyTemperatureSensitivityModel(heating=True, cooling=True)
params = {
"base_daily_consumption": 0.0,
"heating_slope": 1.0,
"heating_balance_temperature": 65.0,
"cooling_slope": 1.0,
"cooling_balance_temperature": 75.0
}
generator = MonthlyBillingConsumptionGenerator("electricity", "kWh", "degF",
model, params)
return generator
def generated_consumption_data_with_hdd_1(request,
gsod_722880_2012_2014_weather_source):
model_params, period, total_hdd, base, temp_unit = request.param
model = AverageDailyTemperatureSensitivityModel(cooling=True,heating=True)
params = {
"base_daily_consumption": model_params[0],
"heating_slope": model_params[1],
"heating_balance_temperature": model_params[2],
"cooling_slope": model_params[3],
"cooling_balance_temperature": model_params[4]
}
gen = MonthlyBillingConsumptionGenerator("electricity", "kWh", "degF",
model, params)
datetimes = generate_monthly_billing_datetimes(period, dist=randint(30,31))
consumption_data = gen.generate(gsod_722880_2012_2014_weather_source,
datetimes)
return consumption_data, total_hdd, base, temp_unit
"cooling_slope": elec_param_list[4],
}
gas_params = {
"base_daily_consumption": gas_param_list[0],
"heating_balance_temperature": gas_param_list[1],
"heating_slope": gas_param_list[2],
}
period = Period(datetime(2012, 1, 1, tzinfo=pytz.utc),
datetime(2014, 12, 31, tzinfo=pytz.utc))
datetimes = generate_monthly_billing_datetimes(period, randint(30,31))
elec_model = AverageDailyTemperatureSensitivityModel(cooling=True, heating=True)
gas_model = AverageDailyTemperatureSensitivityModel(cooling=False, heating=True)
gen_elec = MonthlyBillingConsumptionGenerator("electricity", "kWh", temp_unit, elec_model, elec_params)
gen_gas = MonthlyBillingConsumptionGenerator("natural_gas", "therm", temp_unit, gas_model, gas_params)
elec_consumptions = gen_elec.generate(gsod_722880_2012_2014_weather_source, datetimes)
gas_consumptions = gen_gas.generate(gsod_722880_2012_2014_weather_source, datetimes)
average_daily_usages_elec = elec_consumptions.average_daily_consumptions()[0]
average_daily_usages_gas = gas_consumptions.average_daily_consumptions()[0]
return elec_consumptions, gas_consumptions, 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
}
elec_gen = MonthlyBillingConsumptionGenerator("electricity", "kWh", temp_unit,
elec_model, elec_params)
elec_consumption_data = elec_gen.generate(gsod_722880_2012_2014_weather_source, datetimes)
elec_consumption_kWh_per_day, elec_consumption_n_days = \
elec_consumption_data.average_daily_consumptions()
elec_params = elec_model.param_type(elec_params)
# generate natural_gas consumption
gas_model = AverageDailyTemperatureSensitivityModel(cooling=False,heating=True)
gas_params = {
"base_daily_consumption": gas_model_params[0],
"heating_balance_temperature": gas_model_params[1],
"heating_slope": gas_model_params[2],
}
gas_gen = MonthlyBillingConsumptionGenerator("natural_gas", "therm", temp_unit,
gas_model, gas_params)
gas_consumption_data = gas_gen.generate(gsod_722880_2012_2014_weather_source, datetimes)
gas_consumption_kWh_per_day, gas_consumption_n_days = \
gas_consumption_data.average_daily_consumptions()
gas_params = gas_model.param_type(gas_params)
fixture = elec_consumption_data, gas_consumption_data, \
elec_params, gas_params, \
elec_annualized_usage, gas_annualized_usage, \
elec_gross_savings, gas_gross_savings, \
elec_rmse, gas_rmse, \
elec_r_squared, gas_r_squared, \
elec_consumption_kWh_per_day, gas_consumption_kWh_per_day, \
elec_consumption_n_days, gas_consumption_n_days, \
temp_unit, retrofit_start_date, retrofit_completion_date, \
cdd_tmy, hdd_tmy, total_cdd, total_hdd
"heating_balance_temperature": 68,
}
params_g_r = {
"heating_slope": .1,
"base_daily_consumption": 1,
"heating_balance_temperature": 68,
}
#generators
gen_e_b = MonthlyBillingConsumptionGenerator("electricity", "kWh", "degF",
model_e, params_e_b)
gen_e_r = MonthlyBillingConsumptionGenerator("electricity", "kWh", "degF",
model_e, params_e_r)
gen_g_b = MonthlyBillingConsumptionGenerator("natural_gas", "therm", "degF",
model_g, params_g_b)
gen_g_r = MonthlyBillingConsumptionGenerator("natural_gas", "therm", "degF",
model_g, params_g_r)
# time periods
period = Period(datetime(2011,1,1,tzinfo=pytz.utc), datetime(2015,1,1,tzinfo=pytz.utc))
datetimes = generate_monthly_billing_datetimes(period, dist=randint(30,31))
# consumption data
cd_e_b = gen_e_b.generate(weather_source, datetimes, daily_noise_dist=None)
cd_e_r = gen_e_r.generate(weather_source, datetimes, daily_noise_dist=None)
cd_g_b = gen_g_b.generate(weather_source, datetimes, daily_noise_dist=None)
cd_g_r = gen_g_r.generate(weather_source, datetimes, daily_noise_dist=None)
# periods
periods = cd_e_b.periods()
reporting_period = Period(datetime(2013,1,1,tzinfo=pytz.utc), datetime(2015,1,1,tzinfo=pytz.utc))
baseline_period = Period(datetime(2011,1,1,tzinfo=pytz.utc), datetime(2013,1,1,tzinfo=pytz.utc))
annualized_usage_meter = AnnualizedUsageMeter(temperature_unit_name,
model)
baseline_annualized_usage = annualized_usage_meter.evaluate_raw(
model_params=baseline_params,
weather_normal_source=weather_normal_source)["annualized_usage"]
reporting_annualized_usage = annualized_usage_meter.evaluate_raw(
model_params=reporting_params,
weather_normal_source=weather_normal_source)["annualized_usage"]
estimated_annualized_savings = baseline_annualized_usage - \
reporting_annualized_usage
baseline_generator = MonthlyBillingConsumptionGenerator(fuel_type,
consumption_unit_name, temperature_unit_name, model,
baseline_params)
reporting_generator = MonthlyBillingConsumptionGenerator(fuel_type,
consumption_unit_name, temperature_unit_name, model,
reporting_params)
datetimes = generate_monthly_billing_datetimes(period, dist=None)
baseline_consumption_data = baseline_generator.generate(
weather_source, datetimes, daily_noise_dist=noise)
reporting_consumption_data = reporting_generator.generate(
weather_source, datetimes, daily_noise_dist=noise)
baseline_data = baseline_consumption_data.data
reporting_data = reporting_consumption_data.data
periods = baseline_consumption_data.periods()
records = []
for bl_data, rp_data, period in zip(baseline_data, reporting_data,
"heating_slope": .2,
"base_daily_consumption": 2,
"heating_balance_temperature": 68,
}
params_g_r = {
"heating_slope": .1,
"base_daily_consumption": 1,
"heating_balance_temperature": 68,
}
#generators
gen_e_b = MonthlyBillingConsumptionGenerator("electricity", "kWh", "degF",
model_e, params_e_b)
gen_e_r = MonthlyBillingConsumptionGenerator("electricity", "kWh", "degF",
model_e, params_e_r)
gen_g_b = MonthlyBillingConsumptionGenerator("natural_gas", "therm", "degF",
model_g, params_g_b)
gen_g_r = MonthlyBillingConsumptionGenerator("natural_gas", "therm", "degF",
model_g, params_g_r)
# time periods
period = Period(datetime(2011,1,1,tzinfo=pytz.utc), datetime(2015,1,1,tzinfo=pytz.utc))
datetimes = generate_monthly_billing_datetimes(period, dist=randint(30,31))
# consumption data
cd_e_b = gen_e_b.generate(weather_source, datetimes, daily_noise_dist=None)
cd_e_r = gen_e_r.generate(weather_source, datetimes, daily_noise_dist=None)
cd_g_b = gen_g_b.generate(weather_source, datetimes, daily_noise_dist=None)
cd_g_r = gen_g_r.generate(weather_source, datetimes, daily_noise_dist=None)
# periods
periods = cd_e_b.periods()
baseline_params = model.param_type([param.rvs() for param in param_dists.to_list()])
reporting_params = model.param_type([bl_param + param_delta.rvs()
for bl_param, param_delta in zip(baseline_params.to_list(), param_delta_dists.to_list())])
annualized_usage_meter = AnnualizedUsageMeter(temperature_unit_name,
model)
baseline_annualized_usage = annualized_usage_meter.evaluate_raw(
model_params=baseline_params,
weather_normal_source=weather_normal_source)["annualized_usage"]
reporting_annualized_usage = annualized_usage_meter.evaluate_raw(
model_params=reporting_params,
weather_normal_source=weather_normal_source)["annualized_usage"]
estimated_annualized_savings = baseline_annualized_usage - \
reporting_annualized_usage
baseline_generator = MonthlyBillingConsumptionGenerator(fuel_type,
consumption_unit_name, temperature_unit_name, model,
baseline_params)
reporting_generator = MonthlyBillingConsumptionGenerator(fuel_type,
consumption_unit_name, temperature_unit_name, model,
reporting_params)
datetimes = generate_monthly_billing_datetimes(period, dist=None)
baseline_consumption_data = baseline_generator.generate(
weather_source, datetimes, daily_noise_dist=noise)
reporting_consumption_data = reporting_generator.generate(
weather_source, datetimes, daily_noise_dist=noise)
baseline_data = baseline_consumption_data.data
reporting_data = reporting_consumption_data.data
periods = baseline_consumption_data.periods()