PyPAM support
PypamSupport¶
Helper to process audio segments for a given day, resulting in the aggregated hybrid millidecade PSD product.
Source code in pbp/pypam_support.py
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 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 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
|
parameters_set: bool
property
¶
True if set_parameters
has already been called.
__init__(log)
¶
Creates a helper to process audio segments for a given day, resulting in the aggregated hybrid millidecade PSD product.
The created instance should be used only for a day of processing.
The overall call sequence is:
add_missing_segment
can be called before calling set_parameters
.
This allows capturing initial segments with no data for the day.
Call set_parameters
as soon as you get the first audio segment for a day.
Such segment is used to determine the sampling frequency.
Then you can call add_segment
or add_missing_segment
as appropriate
for each subsequent segment until covering the day.
When all segments have been captured, call process_captured_segments
to get the result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
log |
A logger instance. |
required |
Source code in pbp/pypam_support.py
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 |
|
set_parameters(fs, nfft=0, subset_to=None)
¶
Call this as soon as you get the first audio segment for a day, in particular, to set the sampling frequency used for subsequent calculations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fs |
int
|
Sampling frequency. |
required |
nfft |
int
|
Number of samples to use for the FFT. If 0, it will be set to |
0
|
subset_to |
Tuple[int, int]
|
If not None, the product for a day will get the resulting PSD
subset to |
None
|
Source code in pbp/pypam_support.py
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 |
|
add_missing_segment(dt)
¶
Adds a missing segment to the ongoing aggregation.
This method can be called even before set_parameters
is called.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dt |
datetime
|
The datetime of the start of the missing segment. |
required |
Source code in pbp/pypam_support.py
119 120 121 122 123 124 125 126 127 128 |
|
add_segment(dt, data)
¶
Adds an audio segment to the ongoing aggregation.
set_parameters
must have been called first.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dt |
datetime
|
The datetime of the start of the segment. |
required |
data |
ndarray
|
The audio data. |
required |
Source code in pbp/pypam_support.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
process_captured_segments(sensitivity_da=None)
¶
Gets the resulting hybrid millidecade bands for all captured segments. At least one actual segment must have been captured, otherwise None is returned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sensitivity_da |
Optional[DataArray]
|
The sensitivity data. If given, it will be used to calibrate the result. |
None
|
Returns:
Type | Description |
---|---|
Optional[ProcessResult]
|
Result if at least an actual segment was captured, None otherwise. |
Source code in pbp/pypam_support.py
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 |
|
ProcessResult¶
The result of processing a day of audio segments when at least one actual segment has been captured.
Attributes:
Name | Type | Description |
---|---|---|
psd_da |
DataArray
|
The resulting hybrid millidecade PSD product. |
effort_da |
DataArray
|
The effort in seconds for each segment. |
Source code in pbp/pypam_support.py
14 15 16 17 18 19 20 21 22 23 24 25 26 |
|