Skip to content

Tolerate malformed residual lines in PRIDE-PPPAR .res files - #35

Open
mikegottlieb84 wants to merge 1 commit into
mainfrom
fix/pride-wrms-residual-parsing
Open

Tolerate malformed residual lines in PRIDE-PPPAR .res files#35
mikegottlieb84 wants to merge 1 commit into
mainfrom
fix/pride-wrms-residual-parsing

Conversation

@mikegottlieb84

Copy link
Copy Markdown
Contributor

PRIDE-PPPAR writes phase residuals in fixed-width columns. An unusually large residual (e.g. an unresolved ambiguity/cycle slip) can overflow its column and run into the neighbouring field with no separating space (e.g. "0.0000-1641.5825"), which breaks get_wrms_from_res's whitespace split and raises ValueError. That exception was caught by a broad except in kin_to_kin_position_df, which nulled out the wrms column for every epoch in the file rather than just the malformed one.

Catch the per-line parse error, skip just that satellite's contribution to the epoch's WRMS, and guard against an epoch ending up with zero valid weights (return NaN for that epoch instead of raising ZeroDivisionError).

PRIDE-PPPAR writes phase residuals in fixed-width columns. An unusually
large residual (e.g. an unresolved ambiguity/cycle slip) can overflow its
column and run into the neighbouring field with no separating space
(e.g. "0.0000-1641.5825"), which breaks get_wrms_from_res's whitespace
split and raises ValueError. That exception was caught by a broad
except in kin_to_kin_position_df, which nulled out the wrms column for
every epoch in the file rather than just the malformed one.

Catch the per-line parse error, skip just that satellite's contribution
to the epoch's WRMS, and guard against an epoch ending up with zero
valid weights (return NaN for that epoch instead of raising
ZeroDivisionError).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves robustness of PRIDE-PPPAR .res parsing by making per-epoch WRMS computation resilient to malformed fixed-width residual lines that overflow into adjacent fields, preventing a single bad satellite record from blanking WRMS for an entire file.

Changes:

  • Catch per-line parse failures while reading residual/weight fields and skip only the malformed satellite contribution.
  • Log a warning when skipping an unparsable residual line (instead of failing the epoch/file).
  • Return NaN for an epoch WRMS when no valid weights were accumulated (avoids division-by-zero).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 82 to +86
while not line.startswith("TIM"):
phase_residual = float(line_data[1])
phase_weight = float(line_data[3].replace("D", "E"))
sumOfSquares += phase_residual**2 * phase_weight
sumOfWeights += phase_weight
try:
phase_residual = float(line_data[1])
phase_weight = float(line_data[3].replace("D", "E"))
except (ValueError, IndexError):
Comment on lines +83 to +87
try:
phase_residual = float(line_data[1])
phase_weight = float(line_data[3].replace("D", "E"))
except (ValueError, IndexError):
# PRIDE-PPPAR writes residuals in fixed-width columns; an
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.

2 participants