1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# License: MIT
# Copyright © 2024 Frequenz Energy-as-a-Service GmbH
= , , , ,
"""
The ResamplingFunction enum represents the different resampling functions
that can be used to resample a time series.
"""
= 0
"""Calculates the average of all samples in the time step (ignoring None values)"""
= 1
"""Calculates the sum of all samples in the time step (ignoring None values)"""
= 2
"""Calculates the maximum of all samples in the time step"""
= 3
"""Calculates the minimum of all samples in the time step"""
= 4
"""Returns the last sample in the time step"""
= 5
"""Counts the number of samples in the time step"""
= 6
"""Returns the first sample in the time step"""
= 7
"""Returns the first non-None sample in the time step"""
"""
Returns a list of all values of the enum.
Returns:
A list of all values of the enum.
"""
"""
Returns a list of all members of the enum.
Returns:
A list of all members of the enum.
"""
"""Controls which edge of an interval is closed for sample membership."""
= 0
"""Left-closed, right-open intervals: `[start, end)`"""
= 1
"""Left-open, right-closed intervals: `(start, end]`"""
"""Returns a list of all values of the enum."""
"""Returns a list of all members of the enum."""
"""Controls which edge of an interval is used as the output timestamp."""
= 0
"""Use the interval start as the output timestamp"""
= 1
"""Use the interval end as the output timestamp"""
"""Returns a list of all values of the enum."""
"""Returns a list of all members of the enum."""
"""
The Resampler class is used to resample a time series of samples.
It stores the samples in a buffer and resamples the samples in the buffer when the
resample method is called.
A resampler can be configured with a resampling function and a resampling interval.
"""
"""
Initializes a new Resampler object.
Args:
interval: The resampling interval.
resampling_function: The resampling function.
max_age_in_intervals: The maximum age of a sample in intervals.
start: The start time of the resampling.
closed: Which interval edge is closed for sample membership. Use
`"left"` for left-closed, right-open intervals `[start, end)`
and `"right"` for right-closed, left-open intervals
`(start, end]`.
label: Which interval edge to use for output timestamps. Use
`"left"` for the left bin edge and `"right"` for the right
bin edge.
"""
"""
Pushes a new sample into the resampler buffer.
Args:
timestamp: The timestamp of the sample.
value: The value of the sample.
"""
"""
Resamples the samples in the buffer until the given end time.
Args:
end: The end time of the resampling. If `None` the samples in the buffer will be
resampled until the current date/time.
Returns:
A list of tuples with the resampled samples.
"""
"""
Resamples a list of timestamp/value pairs in a single call.
This is a convenience function for one-shot resampling without needing to
manage a `Resampler` instance.
Args:
data: A list of (timestamp, value) tuples to resample. Must be sorted by timestamp.
interval: The resampling interval.
method: The resampling function to use for aggregating values within each interval.
closed: Which interval edge is closed for sample membership. Use
`"left"` for left-closed, right-open intervals `[start, end)`
and `"right"` for right-closed, left-open intervals `(start, end]`.
label: Which interval edge to use for output timestamps. Use `"left"`
for the left bin edge and `"right"` for the right bin edge.
Returns:
A list of (timestamp, value) tuples representing the resampled data.
"""