How ngageoint/sarpy works
Project Type and Purpose
• This is a Python library (not a web or desktop app) for reading, writing, and performing simple processing on Synthetic Aperture Radar (SAR) data in a variety of standardized formats (SICD, SIDD, CPHD, CRSD) plus vendor-specific single look complex (SLC) files.
• It is intended as a building block for downstream applications, complementary to C++ and MATLAB toolkits.
High-Level Architecture
The library follows a layered, modular design with clear separation of concerns:
A. Core Library (sarpy/)
– annotation: classes and schemas for metadata annotation
– geometry: coordinate transforms, geocoords, projections
– io: file readers and writers organized by format
• DEM, complex, general (TIFF/NITF base), phase_history, product, received, xml
• Each submodule has base classes, converters, schema definitions
– processing: algorithms (ortho-rectify, registration, SICD normalization, SIDD product creation)
– consistency: metadata validation and consistency checks
– utils: helper functions for conversions, KMZ, NITF utilities, noise models
– visualization: KMZ generation, remapping overlays
B. External Dependencies
– Required: numpy, scipy
– Optional (runtime‐loaded): h5py, pillow, lxml, networkx, shapely, pyproj, sphinx, sphinx_gallery
C. Testing & Examples
– tests/: unit tests organized by module
– examples/: Python scripts demonstrating key workflows
D. Build & CI
– setup.py / setup.cfg for packaging
– GitHub Actions workflow (pypi.yml) to run tests and publish releases
– Sphinx docs (docs/*), ReadTheDocs integration
Main Components
• Users / Client Code: imports sarpy, calls high-level API
• File System / Data Sources: SICD, SIDD, CPHD, CRSD, vendor SLC files, GeoTIFF DEM, NITF images
• IO Layer: format detectors → specific Reader classes → metadata + image data objects
• Core Models: in-memory Python objects (annotation, geometry, base image data)
• Processing Layer: algorithms consuming core models, producing derived models or processed data
• Utility Layer: cross-cutting helpers (unit conversions, KMZ packaging)
• Visualization Layer: KMZ & map creation modules
• External Libraries: numpy/scipy (core), optional libs invoked by IO & processing modules
• Testing Harness & CI: test runner, GitHub Actions
• Documentation Generator: Sphinx build subsystem
Relationships and Data Flow
1. Client → (reads) → IO Layer
2. IO Layer → (instantiates) → Core Models
3. Core Models → (fed into) → Processing Layer
4. Processing Layer → (update/produce) → Core Models or output files
5. Core Models → (utilities) → Visualization / KMZ / helpers
6. CI Pipeline → (executes) → tests / doc build / package publish
Architectural Patterns & Principles
• Layered Architecture: IO → Core Model → Processing → Utilities → Visualization
• Plugin-style optional dependencies: runtime import with fallbacks
• Package modularity: each subpackage encapsulates domain area
• Schema-driven design: XSD schemas and element classes mirror SAR standards
• Separation of data representation (annotation, geometry) from processing logic
Technologies & Frameworks
• Python packaging: setuptools (setup.py/ cfg), PyPI
• Testing: pytest, nox (noxfile.py)
• Documentation: Sphinx (docs/), ReadTheDocs config
• CI/CD: GitHub Actions (.github/workflows/pypi.yml)
• Scientific stack: numpy, scipy
• Optional GIS/spatial: h5py, pillow, lxml, networkx, shapely, pyproj