Bin by time
el_paso.processing.bin_by_time
Classes
el_paso.processing.bin_by_time.TimeBinMethod
Bases: Enum
Enum for time binning methods.
Attributes:
| Name | Type | Description |
|---|---|---|
Mean |
str
|
Calculates the mean of the data. |
NanMean |
str
|
Calculates the mean of the data, ignoring NaNs. |
Median |
str
|
Calculates the median of the data. |
NanMedian |
str
|
Calculates the median of the data, ignoring NaNs. |
Merge |
str
|
Concatenates the data. |
NanMax |
str
|
Calculates the maximum of the data, ignoring NaNs. |
NanMin |
str
|
Calculates the minimum of the data, ignoring NaNs. |
NoBinning |
str
|
Applies no binning. |
Repeat |
str
|
Repeats the data. |
Unique |
str
|
Returns unique values from the data. |
Source code in el_paso/processing/bin_by_time.py
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 | |
Methods:
__call__
__call__
Applies the binning method to the provided data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
NDArray[generic]
|
The input data array to be binned or aggregated. |
required |
drop_percent
|
float
|
The percentage of the lowest and highest values to drop before performing a statistical aggregation. Defaults to 0. |
0
|
Returns:
| Type | Description |
|---|---|
NDArray[generic]
|
NDArray[np.generic]: The resulting array after applying the selected binning or aggregation method. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the selected binning method requires numeric types and the input data is not numeric. |
Source code in el_paso/processing/bin_by_time.py
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 | |
Functions:
el_paso.processing.bin_by_time.bin_by_time
bin_by_time
Bins one or more variables by time according to specified methods and cadence.
This function takes a time variable and a dictionary of other variables, then bins these variables over time. Each variable can have a specific binning method applied (e.g., mean, median, sum). The binning is performed over defined time intervals (cadence) with a specified alignment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_variable
|
Variable
|
The master time variable that defines the
time basis for all other variables. Its data should be in a time
unit (e.g., |
required |
variables
|
dict[str, Variable]
|
A dictionary where keys are variable names (str) and values
are the |
required |
time_bin_method_dict
|
dict[str, TimeBinMethod]
|
A dictionary mapping variable names (str) to
|
required |
time_binning_cadence
|
timedelta
|
A |
required |
window_alignement
|
Literal['center', 'left', 'right']
|
Determines how the time windows are aligned. Defaults to "center". * "center": The time bin represents the center of the window. * "left": The time bin represents the left (start) of the window. * "right": The time bin represents the right (end) of the window. |
'center'
|
start_time
|
datetime | None
|
Optional. A |
None
|
end_time
|
datetime | None
|
Optional. A |
None
|
drop_percent
|
float
|
Optional. The percentage of the lowest and highest values to drop from each time bin before calculating statistical aggregates like mean or median. Defaults to 0. |
0
|
Returns:
| Type | Description |
|---|---|
Variable
|
ep.Variable: An |
Variable
|
|
Variable
|
each variables's data updated to its binned values. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the first dimension size of any variable's data does not
match the length of the |
Source code in el_paso/processing/bin_by_time.py
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 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |