How uobwatergroup/towerpy works
Project Type and Purpose
• Towerpy is an open-source Python toolbox (library + CLI scripts + notebooks) for reading, processing, analyzing and visualizing polarimetric weather radar data.
• It is not a web or mobile app but a domain-specific scientific library with command-line entry points and extensive Sphinx-based documentation and example notebooks.
High-level Architecture Components
a. CLI & Notebooks (Entry Points)
• scripts/ directory: Python scripts (e.g., radchain_ukmo.py) that invoke library functions.
• Jupyter notebooks under docs and .virtual_documents provide worked examples and tutorial flows.
b. Core Library Package (towerpy/)
• IO Layer
– towerpy/io: readers for various radar formats (ukmo, ncas, empty)
• Data Processing & Calibration
– towerpy/calib: functions for phase, ZDR calibration
– towerpy/eclass: classification algorithms and calibration factors for different bands
– towerpy/ml: machine-learning models (e.g., mlyr)
– towerpy/qpe: quantitative precipitation estimation algorithms
– towerpy/profs: radial profile computations
• Geospatial & Coordinate Services
– towerpy/georad: coordinate transformations, georeferencing functions
• Visualization
– towerpy/datavis: static and interactive plotting utilities, colormap definitions
• Utilities
– towerpy/base, towerpy/utils: shared base classes, unit conversions, general helpers
c. External Dependencies
• NumPy, SciPy, Matplotlib, Cartopy, netCDF4
• Sphinx (docs), Jupyter (notebooks)
Data Flow and Interactions
1. User calls a CLI script or imports towerpy in a notebook.
2. IO module loads raw radar data into NumPy arrays or xarray structures.
3. Calibration (towerpy/calib) and classification (towerpy/eclass, towerpy/ml) process the raw fields.
4. QPE algorithms compute precipitation estimates (towerpy/qpe).
5. Georeferencing maps data to geographical coordinates (towerpy/georad).
6. Visualization module (towerpy/datavis) renders plots or interactive figures.
7. Output can be saved, further analyzed in notebooks, or used downstream.
Architectural Patterns & Principles
• Modular layering: clear separation of concerns (I/O → Processing → Visualization).
• Plugin-like extensibility: new formats (in io/), new calibration tables (in eclass/), new algorithms (in ml/, qpe/).
• Data-centric design: all processing functions operate on in-memory arrays, enabling chaining.
• Documentation pipeline: Sphinx source under docs/source generates HTML, example notebooks are auto-executed via jupyter_execute.
Detailed Elements to Capture
• scripts/ → towerpy/io → towerpy/calib/eclass/ml/qpe → towerpy/georad → towerpy/datavis
• Inclusion of docs build: docs/source + jupyter_execute → Sphinx → HTML/PDF
• Sample datasets folder can be shown as optional “Input Data” repository.