RawDataReader API
AeroViz.rawDataReader.RawDataReader(instrument, path, reset=False, qc=True, start=None, end=None, mean_freq='1h', size_range=None, suppress_warnings=False, log_level='INFO', **kwargs)
Factory function to instantiate the appropriate reader module for a given instrument and return the processed data over the specified time range.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
instrument
|
str
|
The instrument name for which to read data, must be a valid key in the meta dictionary |
required |
path
|
Path or str
|
The directory where raw data files for the instrument are stored |
required |
reset
|
bool or str
|
Data processing control mode: False (default) - Use existing processed data if available True - Force reprocess all data from raw files 'append' - Add new data to existing processed data |
False
|
qc
|
bool or str
|
Quality control and rate calculation mode: True (default) - Apply QC and calculate overall rates False - Skip QC and return raw data only str - Calculate rates at specified intervals: 'W' - Weekly rates 'MS' - Month start rates 'QS' - Quarter start rates 'YS' - Year start rates Can add number prefix (e.g., '2MS' for bi-monthly) |
True
|
start
|
datetime
|
Start time for filtering the data |
None
|
end
|
datetime
|
End time for filtering the data |
None
|
mean_freq
|
str
|
Resampling frequency for averaging the data (e.g., '1h' for hourly mean) |
'1h'
|
size_range
|
tuple[float, float]
|
Size range in nanometers (min_size, max_size) for SMPS/APS data filtering |
None
|
suppress_warnings
|
bool
|
Whether to suppress warning messages (default: False) |
False
|
log_level
|
(DEBUG, INFO, WARNING, ERROR)
|
Logging level (default: 'INFO') |
'DEBUG'
|
**kwargs
|
Additional arguments to pass to the reader module |
{}
|
Returns:
Type | Description |
---|---|
DataFrame
|
Processed data with specified QC and time range |
Raises:
Type | Description |
---|---|
ValueError
|
If QC mode or mean_freq format is invalid |
TypeError
|
If parameters are of incorrect type |
KeyError
|
If instrument name is not found in the supported instruments list |
FileNotFoundError
|
If path does not exist or cannot be accessed |
Examples:
>>> from AeroViz import RawDataReader
>>>
>>> # Using string inputs
>>> df_ae33 = RawDataReader(
... instrument='AE33',
... path='/path/to/your/data/folder',
... reset=True,
... qc='1MS',
... start='2024-01-01',
... end='2024-06-30',
... mean_freq='1h',
... )
>>> # Using Path and datetime objects
>>> from pathlib import Path
>>> from datetime import datetime
>>>
>>> df_ae33 = RawDataReader(
... instrument='AE33',
... path=Path('/path/to/your/data/folder'),
... reset=True,
... qc='1MS',
... start=datetime(2024, 1, 1),
... end=datetime(2024, 6, 30),
... mean_freq='1h',
... )
Source code in AeroViz/rawDataReader/__init__.py
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 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 |
|
AbstractReader API
AeroViz.rawDataReader.core.AbstractReader
Bases: ABC
Abstract class for reading raw data from different instruments. Each instrument should have a separate class that
inherits from this class and implements the abstract methods. The abstract methods are _raw_reader
and _QC
.
List the file in the path and read pickle file if it exists, else read raw data and dump the pickle file the pickle file will be generated after read raw data first time, if you want to re-read the rawdata, please set 'reset=True'
Source code in AeroViz/rawDataReader/core/__init__.py
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 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 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
|
__calculate_rates(raw_data, qc_data, all_keys=False, with_log=False)
Calculate acquisition rate, yield rate, and total rate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
raw_data
|
DataFrame
|
Raw data before quality control |
required |
qc_data
|
DataFrame
|
Data after quality control |
required |
all_keys
|
bool
|
Whether to calculate rates for all deterministic keys |
False
|
with_log
|
bool
|
Whether to output calculation logs |
False
|
Returns:
Type | Description |
---|---|
dict
|
Dictionary containing calculated rates |
Source code in AeroViz/rawDataReader/core/__init__.py
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 |
|
__call__(start, end, mean_freq='1h')
Process data for specified time range.
Source code in AeroViz/rawDataReader/core/__init__.py
__generate_grouped_report(current_time, weekly_raw_groups, weekly_qc_groups, monthly_raw_groups, monthly_qc_groups)
Generate acquisition and yield reports based on grouped data
Source code in AeroViz/rawDataReader/core/__init__.py
__init__(path, reset=False, qc=True, **kwargs)
A core initialized method for reading raw data from different instruments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str | Path
|
The path of the raw data file. |
required |
reset
|
bool | str
|
Whether to reset the raw data before reading. |
False
|
qc
|
bool | str
|
Whether to read QC data before reading. |
True
|
**kwargs
|
dict
|
Additional keyword arguments passed to the reader. |
{}
|
Source code in AeroViz/rawDataReader/core/__init__.py
filter_error_status(_df, error_codes, special_codes=None)
staticmethod
Filter data containing specified error status codes and specially handle certain specific codes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
_df
|
DataFrame
|
A DataFrame containing a 'Status' column |
required |
error_codes
|
list
|
A List of status codes for bitwise testing |
required |
special_codes
|
list
|
List of special status codes for exact matching |
None
|
Returns:
Type | Description |
---|---|
DataFrame
|
Filtered DataFrame |
Notes
This function performs two types of filtering: 1. Bitwise filtering that checks if any error_codes are present in the Status 2. Exact matching for special_codes
Source code in AeroViz/rawDataReader/core/__init__.py
reorder_dataframe_columns(df, order_lists, keep_others=False)
staticmethod
Reorder DataFrame columns.