Reference profile approach

The scaling profile approach is scaling the original profile (P_{original}^t) of the current time step (t) to the reference profile for the selected period (P_{ref}^{t}). It is linearly interpolated using the scaling factor (S^{f(t)}). Therefore, the scaling factor have to be assigned to the current time step. This is illustrated by f(t). For Example if a monthly period is considered the average value array has 12 entries. So one of these 12 entries has to be assigned to the current time step. All time steps in january are referred to the first entry, all time steps in february to the second entry, and so on.

P_{new}^t = P_{original}^t  \cdot S^{f(t)} + P_{ref}^t \cdot \left(1 - S^{f(t)}\right)

The scaling factor (S^{k}) can either be provided by the user or calculated based on the simultaneity factor (SF). This is determined by an algorithm which minimizes the error of the scaling factor time the maximum value for the current period and the maximum of scaled profile.

As periods can be selected a daily (1), a weekly (2), a monthly (3) or a yearly (4) one. An example code is shown below:

../../examples/example_reference.py
 1"""
 2example python scripts for the linear scaling to a scaling time series
 3"""
 4from tssm import DAILY, MONTHLY, WEEKLY, YEARLY
 5from tssm import TimeSeriesScalingModule as tssm
 6
 7
 8def main() -> None:
 9    """
10    main function to show linear scaling approach
11    """
12    # initialize class with a number of buildings of 20 with a simultaneity factor of 0.86
13    scaling_module = tssm(20, 0.95)
14    # read profile from data.csv file and use the Electricity column
15    scaling_module.data.read_profile_from_csv_with_date("./data.csv", "Electricity", "Date")
16    # set scaling profile from Profile_1h_scaling.csv and use H0 column
17    scaling_module.data.read_scaling_profile_from_csv("./Profile_1h_scaling.csv", "H0", separator=",", decimal=".")
18    # calculate scaling with a daily simultaneity factor
19    daily_scaled_values = scaling_module.calculate_using_scaling_profile(DAILY, same_sum=True)
20    # print results
21    print(f"daily_scaled_values: {daily_scaled_values}")
22    # calculate scaling with a weekly simultaneity factor
23    weekly_scaled_values = scaling_module.calculate_using_scaling_profile(WEEKLY, same_sum=True)
24    # print results
25    print(f"weekly_scaled_values: {weekly_scaled_values}")
26    # calculate scaling with a monthly simultaneity factor
27    monthly_scaled_values = scaling_module.calculate_using_scaling_profile(MONTHLY, same_sum=True)
28    # print results
29    print(f"monthly_scaled_values: {monthly_scaled_values}")
30    # calculate scaling with a yearly simultaneity factor
31    yearly_scaled_values = scaling_module.calculate_using_scaling_profile(YEARLY, same_sum=False)
32    # print results
33    print(f"yearly_scaled_values: {yearly_scaled_values}")
34    # use a given scaling factor
35    # calculate scaling with a daily simultaneity factor using a given scaling factor
36    daily_scaled_values_given_scaling_factor = scaling_module.calculate_using_scaling_profile(DAILY, scaling_factor=[0.861] * 365)
37    # print results
38    print(f"daily_scaled_values_given_scaling_factor: {daily_scaled_values_given_scaling_factor}")
39    # calculate scaling with a weekly simultaneity factor using a given scaling factor
40    weekly_scaled_values_given_scaling_factor = scaling_module.calculate_using_scaling_profile(WEEKLY, scaling_factor=[0.861] * 53)
41    # print results
42    print(f"weekly_scaled_values_given_scaling_factor: {weekly_scaled_values_given_scaling_factor}")
43    # calculate scaling with a monthly simultaneity factor using a given scaling factor
44    monthly_scaled_values_given_scaling_factor = scaling_module.calculate_using_scaling_profile(MONTHLY, scaling_factor=[0.861] * 12)
45    # print results
46    print(f"monthly_scaled_values_given_scaling_factor: {monthly_scaled_values_given_scaling_factor}")
47    # calculate scaling with a yearly simultaneity factor using a given scaling factor
48    yearly_scaled_values_given_scaling_factor = scaling_module.calculate_using_scaling_profile(YEARLY, scaling_factor=[0.861])
49    # print results
50    print(f"yearly_scaled_values_given_scaling_factor: {yearly_scaled_values_given_scaling_factor}")
51    # new init module to downscale the profile to the original one
52    scaling_module_down = tssm(20, 0.95, one_2_many=False)
53    # read profile from data.csv file and use the Electricity column
54    scaling_module_down.data.read_profile_from_csv_with_date("./data.csv", "Electricity", "Date")
55    # set scaling profile from Profile_1h_scaling.csv and use H0 column
56    scaling_module_down.data.scaling = scaling_module.data.scaling
57    # overwrite original profile to the up-scaled values
58    scaling_module_down.data.original = monthly_scaled_values
59    # calculate linear scaled values with a daily simultaneity factor and average value
60    daily_scaled_values_downscaled = scaling_module_down.calculate_using_scaling_profile(MONTHLY)
61    # compare sums to show that the profiles are equal
62    print(f"Sum of original profile {scaling_module.data.original.sum():_.0f} and downscaled {daily_scaled_values_downscaled.sum():_.0f}")
63
64
65if __name__ == "__main__":
66    main()