def test_init(self): t = Tariff(tariff_file=self.get_test_tariff(), timezone='America/Los_Angeles') assert t.tariff_file != None assert t.tariff_json != None assert t.rate_structure != None assert t.rate_schedule != None
def test_cost(self): l_data = [(1379487600, 5.0), (1379488500, 5.0), (1379489400, 5.0), (1379490300, 5.0), (1379491200, 5.0)] cost = [(1379487600, 0.0), (1379488500, 0.17), (1379489400, 0.17), (1379490300, 0.17), (1379491200, 0.17)] cumulative_cost = [(1379487600, 0.0), (1379488500, 0.17), (1379489400, 0.34), (1379490300, 0.52), (1379491200, 0.69)] tariff = Tariff(tariff_file=self.get_test_tariff(), timezone='America/Los_Angeles') ls = Loadshape(l_data, timezone='America/Los_Angeles', log_level=30, tariff=tariff) cost_out, cumulative_cost_out = ls.cost() assert cost_out.data() == cost assert cumulative_cost_out.data() == cumulative_cost
with open(file_name, 'w') as outfile: json.dump(data, outfile) outfile.close() # ----- build loadshape object ----- # my_load_shape = Loadshape(load_data=LOAD_DATA, temp_data=TEMP_DATA, 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") # ----- 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)
def test_parse_rate_schedule(self): t = Tariff(timezone='America/Los_Angeles') t.read_tariff_file(tariff_file=self.get_test_tariff()) t.parse_rate_schedule() assert t.rate_schedule != None
def test_read_tariff_file(self): t = Tariff(timezone='America/Los_Angeles') t.read_tariff_file(tariff_file=self.get_test_tariff()) assert t.tariff_file != None assert t.tariff_json != None