def test_project_generator(gsod_722880_2012_2014_weather_source, tmy3_722880_weather_source): electricity_model = AverageDailyTemperatureSensitivityModel(cooling=True, heating=True) gas_model = AverageDailyTemperatureSensitivityModel(cooling=False, heating=True) electricity_param_distributions = { "cooling_slope": uniform(loc=1, scale=.5), "heating_slope": uniform(loc=1, scale=.5), "base_daily_consumption": uniform(loc=5, scale=5), "cooling_balance_temperature": uniform(loc=70, scale=5), "heating_balance_temperature": uniform(loc=60, scale=5) } electricity_param_delta_distributions = { "cooling_slope": uniform(loc=-.2, scale=.3), "heating_slope": uniform(loc=-.2, scale=.3), "base_daily_consumption": uniform(loc=-2, scale=3), "cooling_balance_temperature": uniform(loc=0, scale=0), "heating_balance_temperature": uniform(loc=0, scale=0) } gas_param_distributions = { "heating_slope": uniform(loc=1, scale=.5), "base_daily_consumption": uniform(loc=5, scale=5), "heating_balance_temperature": uniform(loc=60, scale=5) } gas_param_delta_distributions = { "heating_slope": uniform(loc=-.2, scale=.3), "base_daily_consumption": uniform(loc=-2, scale=3), "heating_balance_temperature": uniform(loc=0, scale=0) } generator = ProjectGenerator(electricity_model, gas_model, electricity_param_distributions, electricity_param_delta_distributions, gas_param_distributions, gas_param_delta_distributions) location = Location(station="722880") period = Period(datetime(2012, 1, 1), datetime(2013, 1, 1)) baseline_period = Period(datetime(2012, 1, 1), datetime(2012, 4, 1)) reporting_period = Period(datetime(2012, 5, 1), datetime(2013, 1, 1)) results = generator.generate(location, period, period, baseline_period, reporting_period) project = results["project"] elec_data = project.consumption[0].data.values gas_data = project.consumption[1].data.values assert project.location == location assert results.get("electricity_estimated_savings") is not None assert results.get("natural_gas_estimated_savings") is not None assert results.get("electricity_pre_params") is not None assert results.get("natural_gas_pre_params") is not None assert results.get("electricity_post_params") is not None assert results.get("natural_gas_post_params") is not None assert len(elec_data) in range(9, 16) assert len(gas_data) in range(9, 16) assert elec_data[0] < 750 # could probably lower this upper bound assert gas_data[0] < 750 # could probably lower this upper bound
def test_project_generator(gsod_722880_2012_2014_weather_source,tmy3_722880_weather_source): electricity_model = TemperatureSensitivityModel(cooling=True,heating=True) gas_model = TemperatureSensitivityModel(cooling=False,heating=True) electricity_param_distributions = { "cooling_slope": uniform(loc=1, scale=.5), "heating_slope": uniform(loc=1, scale=.5), "base_consumption": uniform(loc=5, scale=5), "cooling_reference_temperature": uniform(loc=70, scale=5), "heating_reference_temperature": uniform(loc=60, scale=5)} electricity_param_delta_distributions = { "cooling_slope": uniform(loc=-.2, scale=.3), "heating_slope": uniform(loc=-.2, scale=.3), "base_consumption": uniform(loc=-2, scale=3), "cooling_reference_temperature": uniform(loc=0, scale=0), "heating_reference_temperature": uniform(loc=0, scale=0)} gas_param_distributions = { "heating_slope": uniform(loc=1, scale=.5), "base_consumption": uniform(loc=5, scale=5), "heating_reference_temperature": uniform(loc=60, scale=5)} gas_param_delta_distributions = { "heating_slope": uniform(loc=-.2, scale=.3), "base_consumption": uniform(loc=-2, scale=3), "heating_reference_temperature": uniform(loc=0, scale=0)} generator = ProjectGenerator(electricity_model, gas_model, electricity_param_distributions, electricity_param_delta_distributions, gas_param_distributions, gas_param_delta_distributions) periods = generate_periods(datetime(2012,1,1),datetime(2013,1,1),period_jitter=timedelta(days=0)) retrofit_start_date = datetime(2012,4,1) retrofit_completion_date = datetime(2012,5,1) results = generator.generate(gsod_722880_2012_2014_weather_source, tmy3_722880_weather_source, periods, periods, retrofit_start_date, retrofit_completion_date, electricity_noise=None,gas_noise=None) elec_kwh = [c.to("kWh") for c in results["electricity_consumptions"]] gas_therms = [c.to("therms") for c in results["natural_gas_consumptions"]] assert results.get("electricity_estimated_savings") is not None assert results.get("natural_gas_estimated_savings") is not None assert results.get("electricity_pre_params") is not None assert results.get("natural_gas_pre_params") is not None assert results.get("electricity_post_params") is not None assert results.get("natural_gas_post_params") is not None assert len(elec_kwh) == 12 assert len(gas_therms) == 12 assert elec_kwh[0] > elec_kwh[5] assert gas_therms[0] > gas_therms[5] assert elec_kwh[0] < 700 # could probably lower this upper bound assert gas_therms[0] < 700 # could probably lower this upper bound
def test_project_generator(gsod_722880_2012_2014_weather_source,tmy3_722880_weather_source): electricity_model = AverageDailyTemperatureSensitivityModel(cooling=True, heating=True) gas_model = AverageDailyTemperatureSensitivityModel(cooling=False, heating=True) electricity_param_distributions = { "cooling_slope": uniform(loc=1, scale=.5), "heating_slope": uniform(loc=1, scale=.5), "base_daily_consumption": uniform(loc=5, scale=5), "cooling_balance_temperature": uniform(loc=70, scale=5), "heating_balance_temperature": uniform(loc=60, scale=5)} electricity_param_delta_distributions = { "cooling_slope": uniform(loc=-.2, scale=.3), "heating_slope": uniform(loc=-.2, scale=.3), "base_daily_consumption": uniform(loc=-2, scale=3), "cooling_balance_temperature": uniform(loc=0, scale=0), "heating_balance_temperature": uniform(loc=0, scale=0)} gas_param_distributions = { "heating_slope": uniform(loc=1, scale=.5), "base_daily_consumption": uniform(loc=5, scale=5), "heating_balance_temperature": uniform(loc=60, scale=5)} gas_param_delta_distributions = { "heating_slope": uniform(loc=-.2, scale=.3), "base_daily_consumption": uniform(loc=-2, scale=3), "heating_balance_temperature": uniform(loc=0, scale=0)} generator = ProjectGenerator(electricity_model, gas_model, electricity_param_distributions, electricity_param_delta_distributions, gas_param_distributions, gas_param_delta_distributions) location = Location(station="722880") period = Period(datetime(2012,1,1),datetime(2013,1,1)) baseline_period = Period(datetime(2012,1,1),datetime(2012,4,1)) reporting_period = Period(datetime(2012,5,1),datetime(2013,1,1)) results = generator.generate(location, period, period, baseline_period, reporting_period) project = results["project"] elec_data = project.consumption[0].data.values gas_data = project.consumption[1].data.values assert project.location == location assert results.get("electricity_estimated_savings") is not None assert results.get("natural_gas_estimated_savings") is not None assert results.get("electricity_pre_params") is not None assert results.get("natural_gas_pre_params") is not None assert results.get("electricity_post_params") is not None assert results.get("natural_gas_post_params") is not None assert len(elec_data) in range(9,16) assert len(gas_data) in range(9,16) assert elec_data[0] < 750 # could probably lower this upper bound assert gas_data[0] < 750 # could probably lower this upper bound
uniform(loc=-.2,scale=.3), uniform(loc=-.2, scale=.3), uniform(loc=-2, scale=3), uniform(loc=0, scale=0), uniform(loc=0, scale=0)) gas_param_distributions = ( uniform(loc=62, scale=3), uniform(loc=5, scale=5), uniform(loc=1, scale=.5)) gas_param_delta_distributions = ( uniform(loc=0, scale=0), uniform(loc=-2, scale=3), uniform(loc=-.2,scale=.3)) generator = ProjectGenerator(electricity_model, gas_model, electricity_param_distributions,electricity_param_delta_distributions, gas_param_distributions,gas_param_delta_distributions) start_date = datetime.strptime(args.start_date,"%Y-%m-%d") n_days = (datetime.now() - start_date).days if n_days < 30: message = "start_date ({}) must be at least 30 days before today".format(start_date) raise ValueError(message) weather_source = GSODWeatherSource(args.weather_station,start_date.year,datetime.now().year) weather_normal_source = TMY3WeatherSource(args.weather_station) project_data = [] consumption_data = [] for _ in range(args.n_projects): elec_periods = generate_periods(start_date,datetime.now())