NGI Data Source¶
C
pynasonde.vipir.ngi.source — Trace, Dataset, DataSource — data model for NGI ionogram traces.
pynasonde.vipir.ngi.source
¶
Data ingestion helpers for VIPIR NGI ionogram datasets.
Provides structures to represent scaled traces (Trace), the full NGI dataset
(Dataset), and a DataSource orchestrator that loads raw NGI files, extracts
plots, and writes scaled diagnostics.
Trace
dataclass
¶
Container for scaled trace parameters extracted from NGI files.
Attributes:
| Name | Type | Description |
|---|---|---|
traces |
pd.DataFrame
|
Data frame of individual trace samples. |
trace_params |
pd.DataFrame
|
Data frame describing fitted trace parameters. |
Source code in pynasonde/vipir/ngi/source.py
load_saved_scaled_parameters(folder, extension='*.nc', mode='O', local_tz=None, lat=37.8815, long=-75.4374)
staticmethod
¶
Load previously scaled trace parameters from NetCDF files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder |
str
|
Directory containing saved scaling products. |
required |
extension |
File extension glob (default |
'*.nc'
|
|
mode |
str
|
Wave mode prefix (e.g., |
'O'
|
local_tz |
str
|
Optional local timezone name. If omitted the value is inferred from latitude/longitude. |
None
|
lat |
float
|
Station latitude in degrees. |
37.8815
|
long |
float
|
Station longitude in degrees. |
-75.4374
|
Returns:
| Type | Description |
|---|---|
Pandas DataFrame with time, local time, solar zenith angle, and |
|
fitted frequency/height pairs. |
Source code in pynasonde/vipir/ngi/source.py
Dataset
dataclass
¶
Representation of a single NGI dataset and its derived traces.
Source code in pynasonde/vipir/ngi/source.py
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 | |
__initialize__(ds, unicode='latin-1')
¶
Populate the dataclass fields using an xarray dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds |
|
required | |
unicode |
str
|
Encoding used for legacy byte-string attributes. |
'latin-1'
|
Returns:
| Name | Type | Description |
|---|---|---|
Dataset | The populated instance (also stored as |
Source code in pynasonde/vipir/ngi/source.py
set_traces(traces, trace_params)
¶
Attach fitted trace data produced by the autoscaler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
traces |
dict
|
Mapping of cluster labels to extracted trace samples. |
required |
trace_params |
dict
|
Mapping of cluster labels to metadata dictionaries. |
required |
Source code in pynasonde/vipir/ngi/source.py
get_n_traces()
¶
Return the number of trace parameter sets currently stored.
Returns:
| Name | Type | Description |
|---|---|---|
int | Number of available traces (zero when none were set). |
Source code in pynasonde/vipir/ngi/source.py
DataSource
¶
Bases: object
Manage discovery and loading of NGI ionogram files.
Source code in pynasonde/vipir/ngi/source.py
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 | |
__init__(source_folder='./tmp/', file_ext='*.ngi.bz2', file_names=[], needs_decompression=False)
¶
Configure the datasource to point at a folder or explicit files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_folder |
str
|
Directory containing NGI files. |
'./tmp/'
|
file_ext |
str
|
Filename glob to match ionogram products. |
'*.ngi.bz2'
|
file_names |
List[str]
|
Explicit list of filenames (optional). |
[]
|
needs_decompression |
bool
|
Force decompression even if extension differs. |
False
|
Source code in pynasonde/vipir/ngi/source.py
load_data_sets(load_start=0, load_end=-1, n_jobs=-1)
¶
Populate self.datasets with NGI records from disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
load_start |
Start index when slicing the discovered file list. |
0
|
|
load_end |
End index (non-inclusive) for the slice; |
-1
|
|
n_jobs |
Parallelism level passed to |
-1
|
Source code in pynasonde/vipir/ngi/source.py
extract_ionograms(folder='tmp/', mode='O')
¶
Render quick-look ionograms for each dataset to PNG files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder |
str
|
Destination directory for PNG images. |
'tmp/'
|
mode |
str
|
Wave mode to visualize ( |
'O'
|
Source code in pynasonde/vipir/ngi/source.py
extract_FTI_RTI(rlim=[50, 800], flim=[], mode='O', noise_scale=1.0)
¶
Extract frequency–time ionogram summary points for each dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rlim |
List[float]
|
Height limits (km) used when scanning for maxima. |
[50, 800]
|
flim |
List[float]
|
Optional frequency limits (MHz) for filtering results. |
[]
|
mode |
str
|
Ionogram mode to process. |
'O'
|
noise_scale |
float
|
Multiplier applied to the noise threshold. |
1.0
|
Returns:
| Type | Description |
|---|---|
pd.DataFrame
|
DataFrame of RTI points with timestamp, frequency, power, and range. |
Source code in pynasonde/vipir/ngi/source.py
extract_Power_RTI(folder='tmp/', rlim=[50, 800], flim=[3.95, 4.05], mode='O', fname=None, xlabel='Time, UT', ylabel='Virtual Height, km', xlim=None, add_cbar=True, cbar_label='{}-mode Power, dB', cmap='Spectral', xtick_locator=mdates.HourLocator(interval=4), prange=[5, 70], noise_scale=1.2, date_format='$%H^{%M}$', del_ticks=False, xdate_lims=None)
¶
Generate power RTI plots and return the underlying dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder |
str
|
Directory where the PNG plot will be written. |
'tmp/'
|
rlim |
List[float]
|
Range limits (km) kept in the dataset. |
[50, 800]
|
flim |
List[float]
|
Frequency limits (MHz) used to narrow the data. |
[3.95, 4.05]
|
mode |
str
|
Ionogram mode ( |
'O'
|
fname |
str
|
Optional filename for the saved figure. |
None
|
xlabel |
str
|
X-axis label text. |
'Time, UT'
|
ylabel |
str
|
Y-axis label text. |
'Virtual Height, km'
|
xlim |
List[dt.datetime]
|
Datetime limits applied to the plot. |
None
|
add_cbar |
bool
|
Whether to include a colorbar. |
True
|
cbar_label |
str
|
Format string for the colorbar label. |
'{}-mode Power, dB'
|
cmap |
str
|
Matplotlib colormap name. |
'Spectral'
|
xtick_locator |
mdates.HourLocator
|
Locator controlling x-axis tick frequency. |
mdates.HourLocator(interval=4)
|
prange |
List[float]
|
Min/max dB levels displayed. |
[5, 70]
|
noise_scale |
float
|
Multiplier applied to the noise floor when masking. |
1.2
|
date_format |
str
|
Major tick label format. |
'$%H^{%M}$'
|
del_ticks |
bool
|
Remove axis ticks before plotting (useful for grids). |
False
|
xdate_lims |
List[dt.datetime]
|
Override for x-axis limits. |
None
|
Returns:
| Type | Description |
|---|---|
pd.DataFrame
|
DataFrame containing the filtered RTI samples. |
Source code in pynasonde/vipir/ngi/source.py
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 | |
save_scaled_dataset(params=['hmF2', 'foF2'])
¶
Persist selected scaled parameters to a CSV file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params |
Sequence of attribute names to extract per dataset. |
['hmF2', 'foF2']
|
Source code in pynasonde/vipir/ngi/source.py
save_scaled_parameters(attr=dict(), mode='O')
¶
Write trace parameters into per-epoch NetCDF files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attr |
dict
|
Extra dataset-level attributes to store in each NetCDF file. |
dict()
|
mode |
str
|
Mode suffix applied to the output filenames. |
'O'
|