def test_baseline_with_temp(self): b = Loadshape(self.get_kw_data_filepath(), self.get_temp_data_filepath(), timezone='America/Los_Angeles', log_level=30) prediction = b.baseline() assert len(prediction.data()) > 0
def process_request(self, arg_set): inst_args = ["load_data", "temp_data", "timezone", "temp_units", "sq_ft"] inst_args = {a_name: arg_set[a_name] for a_name in inst_args if arg_set.get(a_name)} baseline_args = ["start_at", "end_at", "weighting_days", "modeling_interval", "step_size"] baseline_args = {a_name: arg_set[a_name] for a_name in baseline_args if arg_set.get(a_name)} ls = Loadshape(**inst_args) baseline_series = ls.baseline(**baseline_args) response = {"baseline": baseline_series.data(), "error_stats": ls.error_stats} return response
def process_request(self, arg_set): inst_args = ["load_data", "temp_data", "timezone", "temp_units", "sq_ft"] inst_args = { a_name: arg_set[a_name] for a_name in inst_args if arg_set.get(a_name)} baseline_args = ["start_at", "end_at", "weighting_days", "modeling_interval", "step_size"] baseline_args = { a_name: arg_set[a_name] for a_name in baseline_args if arg_set.get(a_name)} ls = Loadshape(**inst_args) baseline_series = ls.baseline(**baseline_args) response = { "baseline": baseline_series.data(), "error_stats": ls.error_stats } return response
load_data=LOAD_DATA, temp_data=TEMP_DATA, # tariff_schedule=tariff_schedule timezone='America/Los_Angeles', temp_units="F", sq_ft=BUILDING_SQ_FT) # ----- add exclusions as necessary ----- # my_load_shape.add_exclusion("2013-09-23 00:00:00", "2013-09-24 00:00:00") my_load_shape.add_exclusion("2013-09-27 00:00:00", "2013-09-28 00:00:00") my_load_shape.add_named_exclusion("US_HOLIDAYS") # ----- generate a 7 day baseline ----- # seven_day_baseline = my_load_shape.baseline(start_at=WEEK_START, end_at=WEEK_END, weighting_days=14, modeling_interval=900, step_size=900) # ----- assemble a payload summarizng the seven day baseline ----- # out = {"power_data": {}} out["building"] = BUILDING_NAME out["baseline_start_at"] = WEEK_START out["baseline_end_at"] = WEEK_END out["error_stats"] = my_load_shape.error_stats out["power_data"]["actual"] = my_load_shape.actual_data(WEEK_START, WEEK_END) out["power_data"]["baseline"] = my_load_shape.baseline_data( WEEK_START, WEEK_END) # ----- write output to file ----- # file_name = path.join(EXAMPLES_DIR, "output",
# ----- add exclusions as necessary ----- # my_load_shape.add_exclusion("2013-09-23 00:00:00", "2013-09-24 00:00:00") my_load_shape.add_exclusion("2013-09-27 00:00:00", "2013-09-28 00:00:00") my_load_shape.add_named_exclusion("US_HOLIDAYS") # ----- add tariff to enable cost calculations ----- # tariff = Tariff(tariff_file=TARIFF, timezone='America/Los_Angeles') tariff.add_dr_period("2013-09-23 14:00:00", "2013-09-23 16:00:00") tariff.add_dr_period("2013-09-27 14:00:00", "2013-09-27 16:15:00") my_load_shape.set_tariff(tariff) # ----- build the baseline to use as a reference for performance ----- # event_baseline = my_load_shape.baseline(weighting_days=14, modeling_interval=900, step_size=900) # ----- calculate the performance summary for the event period ----- # event_performance = my_load_shape.event_performance(DR_EVENT_START, DR_EVENT_END) # ----- calculate the performance summary for the whole day ----- # event_day_performance = my_load_shape.event_performance(DR_EVENT_DAY_START, DR_EVENT_DAY_END) out = { "power_data": {} } out["name"] = "DR Event - %s" % DR_EVENT_DAY_START out["building"] = BUILDING_NAME out["event_start_at"] = DR_EVENT_START out["event_end_at"] = DR_EVENT_END out["dr_event_stats"] = event_performance out["dr_event_day_stats"] = event_day_performance
outfile.close() # ----- build loadshape object ----- # my_load_shape = Loadshape(load_data=LOAD_DATA, temp_data=TEMP_DATA, # tariff_schedule=tariff_schedule timezone='America/Los_Angeles', temp_units="F", sq_ft=BUILDING_SQ_FT) # ----- add exclusions as necessary ----- # my_load_shape.add_exclusion("2013-09-23 00:00:00", "2013-09-24 00:00:00") my_load_shape.add_exclusion("2013-09-27 00:00:00", "2013-09-28 00:00:00") my_load_shape.add_named_exclusion("US_HOLIDAYS") # ----- generate the appropriate baseline ----- # baseline = my_load_shape.baseline(weighting_days=CUMULATIVE_SUM_WEIGHTING_DAYS, modeling_interval=900, step_size=900) # ----- set up the cumulative sum dates ----- # tz = utils.get_timezone('America/Los_Angeles') start_at = utils.str_to_datetime(CUMULATIVE_SUM_START, tz) end_at = utils.int_to_datetime(my_load_shape.baseline_series.end_at(), tz) # ----- calculate long term event performance and cumulative sum series ----- # event_performance = my_load_shape.event_performance(start_at, end_at) cumulative_sum_series = my_load_shape.cumulative_sum(start_at, end_at) # ----- assemble a payload summarizng the cumulative sum ----- # out = {} out["building"] = BUILDING_NAME out["event_name"] = CUMULATIVE_SUM_NAME
my_load_shape = Loadshape( load_data=LOAD_DATA, temp_data=TEMP_DATA, # tariff_schedule=tariff_schedule timezone='America/Los_Angeles', temp_units="F", sq_ft=BUILDING_SQ_FT) # ----- add exclusions as necessary ----- # my_load_shape.add_exclusion("2013-09-23 00:00:00", "2013-09-24 00:00:00") my_load_shape.add_exclusion("2013-09-27 00:00:00", "2013-09-28 00:00:00") my_load_shape.add_named_exclusion("US_HOLIDAYS") # ----- generate the appropriate baseline ----- # baseline = my_load_shape.baseline(weighting_days=CUMULATIVE_SUM_WEIGHTING_DAYS, modeling_interval=900, step_size=900) # ----- set up the cumulative sum dates ----- # tz = utils.get_timezone('America/Los_Angeles') start_at = utils.str_to_datetime(CUMULATIVE_SUM_START, tz) end_at = utils.int_to_datetime(my_load_shape.baseline_series.end_at(), tz) # ----- calculate long term event performance and cumulative sum series ----- # event_performance = my_load_shape.event_performance(start_at, end_at) cumulative_sum_series = my_load_shape.cumulative_sum(start_at, end_at) # ----- assemble a payload summarizng the cumulative sum ----- # out = {} out["building"] = BUILDING_NAME out["event_name"] = CUMULATIVE_SUM_NAME
load_data=LOAD_DATA, temp_data=TEMP_DATA, # tariff_schedule=tariff_schedule timezone="America/Los_Angeles", temp_units="F", sq_ft=BUILDING_SQ_FT, ) # ----- add exclusions as necessary ----- # my_load_shape.add_exclusion("2013-09-23 00:00:00", "2013-09-24 00:00:00") my_load_shape.add_exclusion("2013-09-27 00:00:00", "2013-09-28 00:00:00") my_load_shape.add_named_exclusion("US_HOLIDAYS") # ----- generate a 7 day baseline ----- # seven_day_baseline = my_load_shape.baseline( start_at=WEEK_START, end_at=WEEK_END, weighting_days=14, modeling_interval=900, step_size=900 ) # ----- assemble a payload summarizng the seven day baseline ----- # out = {"power_data": {}} out["building"] = BUILDING_NAME out["baseline_start_at"] = WEEK_START out["baseline_end_at"] = WEEK_END out["error_stats"] = my_load_shape.error_stats out["power_data"]["actual"] = my_load_shape.actual_data(WEEK_START, WEEK_END) out["power_data"]["baseline"] = my_load_shape.baseline_data(WEEK_START, WEEK_END) # ----- write output to file ----- # file_name = path.join(EXAMPLES_DIR, "output", "seven-day-baseline-example.json") write_json(data=out, file_name=file_name)