Skip to content

Handle missing station metadata and restore angular distances - #11

Merged
actarus2971 merged 2 commits into
INGV:9_Code_Optimizationfrom
guglielminicola12:10-zero-azimuth
Nov 19, 2026
Merged

actarus2971 merged 2 commits into
INGV:9_Code_Optimizationfrom
guglielminicola12:10-zero-azimuth

Conversation

@guglielminicola12

Copy link
Copy Markdown

The optimized calculation path assigns an azimuth of 0.0 when only precomputed distances are supplied, leaves ep_distance_delta empty, and raises KeyError when station metadata columns are absent. This change returns JSON null for uncomputed bearings and angular distances, restores calculated angular distances, and omits station records with missing metadata while preserving valid zero values.

It also keeps Di Bona station corrections numeric to avoid an object-to-float assignment error with Pandas 3.1, and documents the station-to-event azimuth convention. The existing branch 9 behavior that already preserves calculated zero azimuths and zero coordinates/elevation is covered by regression tests.

Validation:

  • All 9 CLI regression tests pass: python3 -m unittest discover -s tests -v.
  • Tests cover the CPTP zero-azimuth case from REI issue 684, nearby nonzero bearings, southward bearings, zero coordinates/elevation, negative elevation, absent/null metadata, uncomputed azimuths, and unchanged CPTP magnitudes, distances and readings.
  • Python syntax validation and git diff --check pass.

Keep vectorized magnitude calculations while preserving zero azimuths, valid zero station metadata, missing metadata handling and null values for uncomputed bearings. Restore angular distances and keep Di Bona corrections numeric for Pandas compatibility. Validated with all 9 station metadata regression tests.
@actarus2971
actarus2971 merged commit 35fcc89 into INGV:9_Code_Optimization Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants