Linear approach

The linear approach is scaling the original profile (P_{original}^t) of the current time step (t) to the mean value for the selected period (P_{mean}^{f(t)}). It is linearly interpolated using the scaling factor (S^{f(t)}). Therefore, the scaling factor and average value 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_{mean}^{f(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). Therefore the maximum of the original values (P_{original}) for all time steps in the current period (k, A) and the average value have to be determined.

S^{k} = \frac{SF \cdot \max(P_{original}^i \forall i \in A) - \overline{P_{original}^i \forall i \in A}}{\max(P_{original}^i \forall i \in A) - 
\overline{P_{original}^i \forall i \in A}}

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_linear.py
 1"""
 2example python scripts for the linear 'simple' scaling to an average value
 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 examples
11    """
12    # initialize class with a number of buildings of 202 with a simultaneity factor of 0.786
13    scaling_module = tssm(202, 0.786)
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    # calculate linear scaled values with a daily simultaneity factor and average value
17    daily_scaled_values = scaling_module.calculate_using_average_values(DAILY)
18    # print results
19    print(f"daily_scaled_values: {daily_scaled_values}")
20    # calculate linear scaled values with a weekly simultaneity factor and average value
21    weekly_scaled_values = scaling_module.calculate_using_average_values(WEEKLY)
22    # print results
23    print(f"weekly_scaled_values: {weekly_scaled_values}")
24    # calculate linear scaled values with a monthly simultaneity factor and average value
25    monthly_scaled_values = scaling_module.calculate_using_average_values(MONTHLY)
26    # print results
27    print(f"monthly_scaled_values: {monthly_scaled_values}")
28    # calculate linear scaled values with a yearly simultaneity factor and average value
29    yearly_scaled_values = scaling_module.calculate_using_average_values(YEARLY)
30    # print results
31    print(f"yearly_scaled_values: {yearly_scaled_values}")
32    # use a given scaling factor
33    # calculate linear scaled values with a daily simultaneity factor and average value using a given scaling factor
34    daily_scaled_values_given_scaling_factor = scaling_module.calculate_using_average_values(DAILY, scaling_factor=[0.861] * 365)
35    # print results
36    print(f"daily_scaled_values_given_scaling_factor: {daily_scaled_values_given_scaling_factor}")
37    # calculate linear scaled values with a weekly simultaneity factor and average value using a given scaling factor
38    weekly_scaled_values_given_scaling_factor = scaling_module.calculate_using_average_values(WEEKLY, scaling_factor=[0.861] * 53)
39    # print results
40    print(f"weekly_scaled_values_given_scaling_factor: {weekly_scaled_values_given_scaling_factor}")
41    # calculate linear scaled values with a monthly simultaneity factor and average value using a given scaling factor
42    monthly_scaled_values_given_scaling_factor = scaling_module.calculate_using_average_values(MONTHLY, scaling_factor=[0.861] * 12)
43    # print results
44    print(f"monthly_scaled_values_given_scaling_factor: {monthly_scaled_values_given_scaling_factor}")
45    # calculate linear scaled values with a yearly simultaneity factor and average value using a given scaling factor
46    yearly_scaled_values_given_scaling_factor = scaling_module.calculate_using_average_values(YEARLY, scaling_factor=[0.861])
47    # print results
48    print(f"yearly_scaled_values_given_scaling_factor: {yearly_scaled_values_given_scaling_factor}")
49    # new init module to downscale the profile to the original one
50    scaling_module_down = tssm(202, 0.786, one_2_many=False)
51    # read profile from data.csv file and use the Electricity column
52    scaling_module_down.data.read_profile_from_csv_with_date("./data.csv", "Electricity", "Date")
53    # overwrite original profile to the up-scaled values
54    scaling_module_down.data.original = daily_scaled_values
55    # calculate linear scaled values with a daily simultaneity factor and average value
56    daily_scaled_values_downscaled = scaling_module_down.calculate_using_average_values(DAILY)
57    # compare sums to show that the profiles are equal
58    print(f"Sum of original profile {scaling_module.data.original.sum():_.0f} and downscaled {daily_scaled_values_downscaled.sum():_.0f}")
59
60
61if __name__ == "__main__":
62    main()