Exemple #1
0
    def test_diff(self):
        from loadshape.utils import get_timezone
        l_data = [(1379487600, 5.0), (1379488500, 5.0), (1379489400, 5.0),
                  (1379490300, 5.0), (1379491200, 5.0)]
        b_data = [(1379487600, 4.0), (1379488500, 4.0), (1379489400, 4.0),
                  (1379490300, 4.0), (1379491200, 4.0)]

        expected_kw_diff = [(1379488500, 1), (1379489400, 1), (1379490300, 1),
                            (1379491200, 1)]
        expected_cumulative_kwh_diff = [(1379487600, 0), (1379488500, 0.25),
                                        (1379489400, 0.5), (1379490300, 0.75),
                                        (1379491200, 1.0)]
        expected_cumulative_kwh_base = [(1379487600, 0), (1379488500, 1.0),
                                        (1379489400, 2.0), (1379490300, 3.0),
                                        (1379491200, 4.0)]

        b = Loadshape(l_data, timezone='America/Los_Angeles', log_level=30)
        b.baseline_series = Series(b_data, get_timezone('America/Los_Angeles'))

        kw_diff, kw_base, cumulative_kwh_diff, cumulative_kwh_base = b.diff()

        assert kw_diff.data() == expected_kw_diff
        assert cumulative_kwh_diff.data() == expected_cumulative_kwh_diff
        assert kw_base.data() == b_data[1:]
        assert cumulative_kwh_base.data() == expected_cumulative_kwh_base
    def test_diff(self):
        from loadshape.utils import get_timezone
        l_data   = [(1379487600, 5.0), (1379488500, 5.0), (1379489400, 5.0), (1379490300, 5.0), (1379491200, 5.0)]
        b_data   = [(1379487600, 4.0), (1379488500, 4.0), (1379489400, 4.0), (1379490300, 4.0), (1379491200, 4.0)]
        
        expected_kw_diff                = [(1379488500, 1), (1379489400, 1), (1379490300, 1), (1379491200, 1)]
        expected_cumulative_kwh_diff    = [(1379487600, 0), (1379488500, 0.25), (1379489400, 0.5), (1379490300, 0.75), (1379491200, 1.0)]
        expected_cumulative_kwh_base    = [(1379487600, 0), (1379488500, 1.0), (1379489400, 2.0), (1379490300, 3.0), (1379491200, 4.0)]

        b = Loadshape(l_data, timezone='America/Los_Angeles', log_level=30)
        b.baseline_series = Series(b_data, get_timezone('America/Los_Angeles'))
        
        kw_diff, kw_base, cumulative_kwh_diff, cumulative_kwh_base = b.diff()

        assert kw_diff.data() == expected_kw_diff
        assert cumulative_kwh_diff.data() == expected_cumulative_kwh_diff
        assert kw_base.data() == b_data[1:]
        assert cumulative_kwh_base.data() == expected_cumulative_kwh_base
Exemple #3
0
						  # 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
out["sum_start_at"]         = start_at.strftime("%Y-%m-%d %H:%M:%S")
out["sum_end_at"]           = end_at.strftime("%Y-%m-%d %H:%M:%S")
out["event_performance"]    = event_performance
out["cumulative_sum_data"] 	= cumulative_sum_series.data()
Exemple #4
0
    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
out["sum_start_at"] = start_at.strftime("%Y-%m-%d %H:%M:%S")
out["sum_end_at"] = end_at.strftime("%Y-%m-%d %H:%M:%S")
out["event_performance"] = event_performance
out["cumulative_sum_data"] = cumulative_sum_series.data()