Skip to content

Conversation

@mmaclay
Copy link
Collaborator

@mmaclay mmaclay commented Sep 3, 2025

Geolocation Error Statistics Python Implementation

Overview

Converts MATLAB geolocation error statistics code (developed by Tim Holden) into a production-ready Python implementation that integrates with the CSDS pipeline. This is a first stab at making this error-stats code play nicely with image-matching outputs, and assumes Xarray as the standard format.

Key Changes

MATLAB to Python Conversion

  • Translated Tim Holden's original MATLAB algorithm (183262revB_GeolocationStatistics.m) to Python
  • Maintains mathematical accuracy and numerical precision from heritage implementation
  • Preserves all 13 original test cases for validation against MATLAB reference results (100% agreement)

Basic Class architecture

  • Main Class: ErrorStatsProcessor - handles geolocation error processing
  • Configuration: GeolocationConfig dataclass with configurable parameters
  • Input/Output: Xarray Dataset support for pipeline integration
  • Error Handling: Validation and error management

Core Algorithm Functionality (from Matlab)

Processes geolocation errors through all matlab steps:

  1. Angular to Distance Conversion - Converts lat/lon errors to meters using Earth radius
  2. Coordinate Transformations - Transforms between sensor, Earth-centered, and local coordinate systems
  3. View-Plane Projection - Decomposes errors into along-track/cross-track components
  4. Nadir-Equivalent Scaling - Applies geometric corrections for off-nadir viewing angles
  5. Performance Statistics - Computes pass/fail metrics against 250m threshold (39% requirement)

Testing

  • Unit Tests: test_geolocation_error_stats.py using unittest
  • Validation Tests: Regression testing against original MATLAB results
  • Edge Case Coverage: Input validation, coordinate transformations, statistical calculations
  • Integration Tests: End-to-end processing with heritage test data

Performance & Validation

  • Numerical Accuracy: Matches MATLAB results within 0.1m tolerance
  • Matlab Test Validation: 1203.26m mean error, 61.5% pass rate (8/13 cases < 250m)

Files Added

  • geolocation_error_stats.py - Main implementation
  • test_geolocation_error_stats.py - Comprehensive unit tests

 - use unittest not pytest
 - stop tracking outdated csds_error_stats file
 - improve test documentation and strings
Copy link
Member

@medley56 medley56 left a comment

Choose a reason for hiding this comment

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

My only real feedback is that I'm skeptical that this repo is the right place for this code. This feels like a debugging utility script for a specific mission (CLARREO?) and we're trying to really push Curryer towards being a generic SPICE/geolocation utility library rather than a repository for mission code.

Comment on lines +86 to +89
required_vars = [
'lat_error_deg', 'lon_error_deg', 'riss_ctrs', 'bhat_hs',
't_hs2ctrs', 'cp_lat_deg', 'cp_lon_deg', 'cp_alt'
]
Copy link
Member

Choose a reason for hiding this comment

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

This seems very mission-specific. Does this really belong in a generic geolocation library?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adding a comment here to remind myself. I'm going to be pulling out mission-specific code during further development and integration of this with the GCS module - plan for now is that these variables will be named in a config json.

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