diff --git a/packages/pride-ppp/src/pride_ppp/factories/output.py b/packages/pride-ppp/src/pride_ppp/factories/output.py index 04aaddf..bf66995 100644 --- a/packages/pride-ppp/src/pride_ppp/factories/output.py +++ b/packages/pride-ppp/src/pride_ppp/factories/output.py @@ -80,15 +80,27 @@ def get_wrms_from_res(res_path): line = res_file.readline() line_data = line.split() 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): + # PRIDE-PPPAR writes residuals in fixed-width columns; an + # unusually large value (e.g. an unresolved ambiguity) can + # overflow its column and run into the neighbouring field + # with no separating space (e.g. "0.0000-1641.5825"), + # which breaks whitespace-based splitting. Skip just this + # satellite's contribution rather than failing the epoch. + logger.warning( + f"Skipping unparsable residual line in {res_path}: {line.strip()!r}" + ) + else: + sumOfSquares += phase_residual**2 * phase_weight + sumOfWeights += phase_weight line = res_file.readline() if line == "": break line_data = line.split() - wrms = (sumOfSquares / sumOfWeights) ** 0.5 * 1000 # in mm + wrms = (sumOfSquares / sumOfWeights) ** 0.5 * 1000 if sumOfWeights else float("nan") # in mm data.append(wrms) else: line = res_file.readline()