True Height Inversion (pynasonde.vipir.analysis.inversion)¶
Virtual Height → True Height Abel / Lamination Inversion
Inverts an O-mode ionogram trace h′(f) to the true electron density profile N(h) using the Titheridge (1967) lamination method.
Theory¶
An ionogram records the virtual height h′(f) — the height a pulse would reach at the speed of light. Because the O-mode group refractive index μ′ > 1, the true reflection height is always lower. The Abel integral:
is discretised by the lamination method into N horizontal layers:
Electron density follows from N = fp² × 1.2399×10⁴ cm⁻³.
Classes¶
pynasonde.vipir.analysis.inversion
¶
inversion.py — Virtual height → true height inversion (Abel / lamination).
An ionogram records the virtual height h'(f) — the height a pulse would reach if it propagated at the speed of light c throughout. Because the ionospheric plasma slows the pulse (group refractive index μ' > 1 for O-mode), the true reflection height is always less than the virtual height.
The relationship is the Abel integral
h'(f) = ∫₀^{h_ref(f)} μ'(f, z) dz
where h_ref(f) is the true reflection height (plasma frequency fₚ = f) and μ'(f, N) = 1/√(1 − fₚ²/f²) for the O-mode without magnetic field.
Inverting this integral yields the true-height profile h(fₚ) and hence the electron density profile N(h).
Lamination method (Titheridge 1967, Paul 1975) Treat the ionosphere as N horizontal layers of uniform plasma frequency. The
true height of the n-th layer is obtained iteratively from
r_n = h'(fₙ) − Σᵢ₌₀ⁿ⁻¹ (μ'(fₙ, fₚᵢ) − 1) × Δhᵢ
where Δhᵢ = rᵢ − rᵢ₋₁ is the thickness of layer i and fₚᵢ = fᵢ (the plasma frequency at the reflection level equals the sounding frequency).
This module provides:
:class:TrueHeightInversion
Processor — inverts an O-mode (frequency_mhz, h_virtual_km) trace.
:class:EDPResult
Output dataclass — true-height profile, plasma frequency, electron
density, and standard layer parameters.
References¶
Titheridge, J. E. (1967). A new method for the analysis of ionospheric h'(f) records. Journal of Atmospheric and Terrestrial Physics, 29, 763–778.
Paul, A. K. (1975). POLAN — A program for true-height analysis of ionograms. NOAA Technical Report ERL 324-SEL 31.
Bilitza, D. (1990). International Reference Ionosphere 1990. NSSDC/WDC-A-R&S 90-22, Greenbelt, Maryland.
TrueHeightInversion
¶
Invert an O-mode ionogram trace to a true-height electron density profile.
The lamination method (Titheridge 1967) discretises the Abel integral into N horizontal layers. Starting from the bottommost layer and working upward, each true reflection height is computed by subtracting the accumulated group- path excess of all underlying layers.
Parameters¶
method
Inversion algorithm. Currently only "lamination" is implemented.
min_freq_mhz
Frequencies below this value are excluded before inversion (MHz).
Removes low-frequency noise below the E-layer. Default 1.0.
max_freq_mhz
Frequencies above this value are excluded (MHz). Useful to limit
the inversion to a specific layer. None → no upper limit.
monotone_enforce
If True (default), non-monotone true-height values (which are
physically invalid) are removed from the output after inversion.
freq_col
Name of the frequency column when fitting from a DataFrame.
Default "frequency_mhz".
height_col
Name of the virtual-height column when fitting from a DataFrame.
Default "height_km".
mode_col
Name of the mode column when filtering O-mode echoes from a full echo
DataFrame. Default "mode".
bin_width_mhz
Frequency bin width (MHz) used to decimate the trace in
:meth:fit_from_df before inversion. Real RIQ traces have ~19 kHz
steps which cause near-singular μ' contributions; binning to this
width (default 0.3) gives 10–20 representative profile points
consistent with the POLAN prescription.
Examples¶
Fit from a (freq_mhz, h_virtual_km) pair of arrays::
from pynasonde.vipir.analysis.inversion import TrueHeightInversion
inv = TrueHeightInversion()
edp = inv.fit(freq_mhz=trace_freq, h_virtual_km=trace_h)
print(edp.summary())
Fit directly from an echo DataFrame with mode labels::
edp = inv.fit_from_df(pol_result.o_mode_df())
Source code in pynasonde/vipir/analysis/inversion.py
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 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | |
fit(freq_mhz, h_virtual_km)
¶
Invert a (frequency, virtual height) trace.
Parameters¶
freq_mhz
Sounding frequencies (MHz). Need not be sorted — the method sorts them internally.
h_virtual_km
Corresponding virtual heights (km).
Returns¶
EDPResult
Raises¶
ValueError If fewer than 2 valid data points remain after filtering.
Source code in pynasonde/vipir/analysis/inversion.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 | |
fit_from_df(df)
¶
Convenience wrapper — fit from an echo or trace DataFrame.
The method extracts (frequency_mhz, height_km) from df, using
the median virtual height at each unique frequency step as the trace.
O-mode filtering is applied when a mode column is present.
Parameters¶
df
Echo DataFrame (with frequency_khz and height_km columns)
or a pre-scaled trace DataFrame (with frequency_mhz and
height_km columns).
Returns¶
EDPResult
Source code in pynasonde/vipir/analysis/inversion.py
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 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | |
EDPResult
dataclass
¶
Electron density profile from true-height inversion.
Parameters¶
true_height_km
True reflection heights (km), one per input frequency.
plasma_freq_mhz
Plasma frequency at each layer (MHz). Equals the sounding frequency in the lamination approximation (fₚ ≈ f at the reflection level).
electron_density_cm3
Electron density at each layer (cm⁻³).
virtual_height_km
Input virtual heights (km) that were inverted.
frequency_mhz
Input sounding frequencies (MHz).
foF2_mhz
Critical frequency of the F2 layer — maximum plasma frequency (MHz).
hmF2_km
True height of the F2 peak (km).
NmF2_cm3
Peak electron density (cm⁻³).
method
Inversion method used: "lamination".
n_layers
Number of layers used in the inversion.
Source code in pynasonde/vipir/analysis/inversion.py
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 | |
to_dataframe()
¶
Return a DataFrame with columns: frequency_mhz, virtual_height_km, true_height_km, plasma_freq_mhz, electron_density_cm3.
Source code in pynasonde/vipir/analysis/inversion.py
to_csv(path)
¶
summary()
¶
One-line summary.
plot(ax=None)
¶
Plot N(h) electron density profile alongside the virtual-height trace.
Parameters¶
ax
Existing axes. A new figure (two panels) is created when None.
Returns¶
matplotlib.axes.Axes Left panel axes (N vs h).
Source code in pynasonde/vipir/analysis/inversion.py
TrueHeightInversion¶
Constructor¶
TrueHeightInversion(
method: str = "lamination", # only option currently
min_freq_mhz: float = 1.0, # low-frequency cutoff
max_freq_mhz: float | None = None, # optional upper cutoff
monotone_enforce: bool = True, # remove non-monotone h_true points
freq_col: str = "frequency_mhz", # column name for fit_from_df
height_col: str = "height_km",
mode_col: str = "mode", # O-mode filter for fit_from_df
bin_width_mhz: float = 0.05, # binning step for fit_from_df stability
)
Methods¶
| Method | Input | Output |
|---|---|---|
fit(freq_mhz, h_virtual_km) |
Arrays of matching shape | EDPResult |
fit_from_df(df) |
Echo DataFrame (O-mode filtered inside) | EDPResult |
fit_from_df expects a virtual height trace
fit_from_df extracts median virtual height per frequency bin — it requires
echoes that form a valid O-mode trace h′(f) (monotone increasing in height).
Do not pass a raw N(h) profile here; construct EDPResult directly instead.
Quick start¶
from pynasonde.vipir.analysis import TrueHeightInversion, PolarizationClassifier
inv = TrueHeightInversion(min_freq_mhz=1.5, bin_width_mhz=0.05)
# From arrays
edp = inv.fit(freq_mhz=trace_f, h_virtual_km=trace_h)
print(edp.summary())
# EDPResult (lamination): n_layers=24 foF2=8.20 MHz hmF2=280.5 km NmF2=8.31e+05 cm⁻³
# From an echo DataFrame (O-mode filter applied automatically)
clf = PolarizationClassifier(o_mode_sign=-1)
pol = clf.fit(echo_df)
edp = inv.fit_from_df(pol.annotated_df) # O-mode column used for filtering
edp.plot()
EDPResult dataclass¶
| Field | Type | Description |
|---|---|---|
true_height_km |
ndarray |
True reflection heights (km) |
plasma_freq_mhz |
ndarray |
Plasma frequency at each layer (MHz) = sounding frequency |
electron_density_cm3 |
ndarray |
Electron density at each layer (cm⁻³) |
virtual_height_km |
ndarray |
Input virtual heights (km) |
frequency_mhz |
ndarray |
Input sounding frequencies (MHz) |
foF2_mhz |
float |
F2 critical frequency (MHz) |
hmF2_km |
float |
F2 peak true height (km) |
NmF2_cm3 |
float |
Peak electron density (cm⁻³) |
method |
str |
"lamination" |
n_layers |
int |
Number of layers after monotone filter |
Methods¶
edp.summary() # "EDPResult (lamination): n_layers=24 foF2=8.20 MHz …"
edp.to_dataframe() # DataFrame: frequency_mhz, virtual_height_km, true_height_km, …
edp.to_csv("edp.csv") # write to file
edp.plot() # two-panel: N(h) left, virtual vs true height right
Build EDPResult directly (for synthetic / model profiles)¶
When you have a known N(h) profile (e.g. Chapman layer, model output) rather than an ionogram trace, bypass the inversion and construct EDPResult directly:
import numpy as np
from pynasonde.vipir.analysis.inversion import EDPResult
_FP_TO_N = 1.2399e4 # N_cm3 = fp_mhz² × this
h = np.linspace(60.0, 130.0, 140)
xi = (h - 90.0) / 8.0
fp = np.maximum(0.5 * np.exp(0.5 * (1.0 - xi - np.exp(-xi))), 1e-4)
peak = int(np.argmax(fp))
edp = EDPResult(
true_height_km=h, plasma_freq_mhz=fp,
electron_density_cm3=fp**2 * _FP_TO_N,
virtual_height_km=h, frequency_mhz=fp,
foF2_mhz=float(fp[peak]), hmF2_km=float(h[peak]),
NmF2_cm3=float(fp[peak]**2 * _FP_TO_N),
method="synthetic_chapman", n_layers=len(h),
)
References¶
- Titheridge, J. E. (1967). A new method for the analysis of ionospheric h'(f) records. J. Atmos. Terr. Phys., 29, 763–778.
- Paul, A. K. (1975). POLAN — A program for true-height analysis of ionograms. NOAA Technical Report ERL 324-SEL 31.
See Also¶
- Analysis Overview
- Absorption Profile — uses
EDPResultfor Method 4 - NeXtYZ Inversion — full 3-D inversion alternative