# uba/tathu architecture

> Architecture diagram of the GitHub repository uba/tathu, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/uba/tathu
- Repository: https://github.com/uba/tathu

## Overview

1. **What this repository is**
   TATHU is a Python library for detecting, tracking, characterizing, and forecasting convective systems. It is organized as a domain-specific processing pipeline rather than a single app: ingest remote sensing data, convert it into a common spatial form, identify storm objects, associate them over time, and persist or visualize the results.

2. **Core architectural idea**
   The codebase centers on a small conceptual model with four interchangeable roles: **Detector**, **Descriptor**, **Tracker**, and **Forecaster**. These operate on a shared storm entity, the **ConvectiveSystem**, which carries a UUID, geometry, timestamp/event metadata, and derived fields. This abstraction boundary is the main reason the library can support radar, multiple satellite products, and future data sources.

3. **Data ingestion subsystem**
   Source-specific adapters live under `tathu/satellite`, `tathu/radar`, and `tathu/downloader`. They handle external observation formats such as GOES, GOES-13/GOES-R, GLM, MSG, MERGIR, and radar CAPPI files. The role of this layer is to normalize raw sensor data into analysis-ready rasters/grids, not to perform tracking logic.

4. **Spatial normalization and geometry**
   The `tathu/geometry` package provides the geospatial primitives used across the project: extents, coordinate transforms, envelopes, and utility functions. This layer is important because detection and tracking are done in a consistent spatial reference, often by remapping sensor-native data to a regular lat/lon grid before analysis.

5. **Detection and characterization**
   `tathu/tracking/detectors.py` identifies candidate convective objects from an image or grid, typically using thresholding and connected-region logic. `tathu/tracking/descriptors.py` enriches each detected system with quantitative attributes such as area, min/mean/std, and count. This is the first point where raw pixels become structured storm objects.

6. **Temporal association and forecasting**
   `tathu/tracking/trackers.py` links systems across consecutive times using overlap-based strategies and related heuristics, turning independent detections into a lifecycle. `tathu/tracking/forecasters.py` then extrapolates future behavior from the tracked history, with conservative motion-based prediction as one implemented strategy. This is the main time-series boundary in the architecture.

7. **Domain-specific tracking extensions**
   The package also includes specialized tracking logic in `tathu/tracking/system.py` and `tathu/tracking/squall_line.py`, plus helper utilities and descriptors. This suggests the library supports multiple storm-object interpretations, not only generic blobs, and can represent more specific phenomena such as squall lines.

8. **Persistence and data exchange**
   The `tathu/io` layer is the repository’s integration boundary for storage. It supports CSV-like output, geospatial databases such as **SpatiaLite** and **PostGIS**, plus loaders/query helpers for reading back storm families by name, duration, day, or SQL query. This is where tracked objects become an analyzable database rather than just in-memory results.

9. **Visualization**
   `tathu/visualizer.py` and related tracking visualizers provide map-based and lifecycle views. The visualizers consume the normalized grid plus detected/tracked systems, so they sit downstream of detection and are not involved in core computation. This makes visualization a read-only presentation layer.

10. **Supporting infrastructure**
   The repository includes extensive `examples/`, `notebooks/`, and `docs/sphinx/` content, which function as executable documentation and usage demonstrations rather than production subsystems. `tools/tracking.py` and the example config show that the library can be driven from scripts/CLI-style workflows, while `tests/` validates the package surface. The bundled radar sample data under `data/radar` is test/demo input for these workflows.

11. **Typical end-to-end data flow**
   The canonical pipeline is: load sensor data from satellite/radar → remap to a common grid → detect convective systems → compute attributes → track across time steps → forecast future positions/behavior → write to CSV or spatial database → load/query for history analysis and visualization. That flow is the best basis for an architecture diagram.

12. **Technology and deployment shape**
   The project is a pure Python geospatial/scientific package with packaging support via `setup.py`, `conda.recipe`, and an `env.yml`. The architecture depends materially on geospatial data handling and database-backed storage, but it is not built around a web server or distributed runtime. Its main deployment modes are library use, notebooks, scripts, and documentation examples.

Main entry points: [`tathu/tracking/system.py`](https://github.com/uba/tathu/blob/master/tathu/tracking/system.py) (Convective system), [`tathu/tracking/trackers.py`](https://github.com/uba/tathu/blob/master/tathu/tracking/trackers.py) (Trackers), [`tathu/geometry`](https://github.com/uba/tathu/tree/master/tathu/geometry) (Geometry), [`tathu/__init__.py`](https://github.com/uba/tathu/blob/master/tathu/__init__.py) (tathu)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_support["Support & examples"]
  node_examples_docs["Examples & docs<br/>usage material"]
end

subgraph group_ingest["Ingestion"]
  node_satellite_adapters["Satellite adapters<br/>sensor adapters"]
  node_radar_adapter["Radar adapter<br/>sensor adapter<br/>[radar.py]"]
  node_downloaders["Downloaders<br/>ingest helpers"]
end

subgraph group_spatial["Spatial model"]
  node_geometry["Geometry<br/>geo primitives"]
end

subgraph group_tracking["Tracking core"]
  node_detectors["Detectors<br/>storm detection<br/>[detectors.py]"]
  node_descriptors["Descriptors<br/>storm features<br/>[descriptors.py]"]
  node_convective_system["Convective system<br/>storm entity<br/>[system.py]"]
  node_trackers["Trackers<br/>object association<br/>[trackers.py]"]
  node_forecasters["Forecasters<br/>motion forecast<br/>[forecasters.py]"]
  node_squall_line["Squall line<br/>specialized tracking<br/>[squall_line.py]"]
  node_tracking_utils["Tracking utils<br/>tracking helpers<br/>[utils.py]"]
end

subgraph group_storage["Persistence"]
  node_icsv["CSV I/O<br/>tabular output<br/>[icsv.py]"]
  node_spatialite[("SpatiaLite<br/>spatial database<br/>[spatialite.py]")]
  node_pgis[("PostGIS<br/>spatial database<br/>[pgis.py]")]
  node_forecast_io["Forecast I/O<br/>forecast exchange<br/>[forecast.py]"]
end

subgraph group_presentation["Visualization"]
  node_visualizer["Visualizer<br/>presentation<br/>[visualizer.py]"]
end

node_tathu_pkg["tathu<br/>package root<br/>[__init__.py]"]

node_tathu_pkg -->|"uses"| node_satellite_adapters
node_tathu_pkg -->|"uses"| node_radar_adapter
node_tathu_pkg -->|"uses"| node_geometry
node_tathu_pkg -->|"uses"| node_detectors
node_satellite_adapters -->|"normalize"| node_geometry
node_radar_adapter -->|"normalize"| node_geometry
node_downloaders -->|"feeds"| node_satellite_adapters
node_geometry -->|"grid"| node_detectors
node_detectors -->|"creates"| node_convective_system
node_detectors -->|"passes"| node_descriptors
node_descriptors -->|"annotates"| node_convective_system
node_convective_system -->|"links"| node_trackers
node_trackers -->|"history"| node_forecasters
node_trackers -->|"specializes"| node_squall_line
node_trackers -->|"shares"| node_tracking_utils
node_convective_system -->|"exports"| node_icsv
node_convective_system -->|"persists"| node_spatialite
node_convective_system -->|"persists"| node_pgis
node_forecasters -->|"writes"| node_forecast_io
node_spatialite -->|"loads"| node_visualizer
node_pgis -->|"loads"| node_visualizer
node_geometry -->|"renders"| node_visualizer
node_examples_docs -.->|"demonstrates"| node_satellite_adapters
node_examples_docs -.->|"demonstrates"| node_trackers

click node_tathu_pkg "https://github.com/uba/tathu/blob/master/tathu/__init__.py"
click node_satellite_adapters "https://github.com/uba/tathu/tree/master/tathu/satellite"
click node_radar_adapter "https://github.com/uba/tathu/blob/master/tathu/radar/radar.py"
click node_downloaders "https://github.com/uba/tathu/tree/master/tathu/downloader"
click node_geometry "https://github.com/uba/tathu/tree/master/tathu/geometry"
click node_detectors "https://github.com/uba/tathu/blob/master/tathu/tracking/detectors.py"
click node_descriptors "https://github.com/uba/tathu/blob/master/tathu/tracking/descriptors.py"
click node_convective_system "https://github.com/uba/tathu/blob/master/tathu/tracking/system.py"
click node_trackers "https://github.com/uba/tathu/blob/master/tathu/tracking/trackers.py"
click node_forecasters "https://github.com/uba/tathu/blob/master/tathu/tracking/forecasters.py"
click node_squall_line "https://github.com/uba/tathu/blob/master/tathu/tracking/squall_line.py"
click node_tracking_utils "https://github.com/uba/tathu/blob/master/tathu/tracking/utils.py"
click node_icsv "https://github.com/uba/tathu/blob/master/tathu/io/icsv.py"
click node_spatialite "https://github.com/uba/tathu/blob/master/tathu/io/spatialite.py"
click node_pgis "https://github.com/uba/tathu/blob/master/tathu/io/pgis.py"
click node_forecast_io "https://github.com/uba/tathu/blob/master/tathu/io/forecast.py"
click node_visualizer "https://github.com/uba/tathu/blob/master/tathu/visualizer.py"
click node_examples_docs "https://github.com/uba/tathu/tree/master/examples"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_examples_docs toneBlue
class node_satellite_adapters,node_radar_adapter,node_downloaders toneAmber
class node_geometry toneMint
class node_detectors,node_descriptors,node_convective_system,node_trackers,node_forecasters,node_squall_line,node_tracking_utils toneRose
class node_icsv,node_spatialite,node_pgis,node_forecast_io toneIndigo
class node_visualizer toneTeal
class node_tathu_pkg toneNeutral
```

## Components

### Support & examples

Packaging, docs, examples, and demo assets

- [Examples & docs](https://github.com/uba/tathu/tree/master/examples): usage material · Executable examples, notebooks, and Sphinx documentation · `examples`

### Ingestion

Source-specific adapters and downloaders

- [Satellite adapters](https://github.com/uba/tathu/tree/master/tathu/satellite): sensor adapters · GOES, GLM, MSG, and related satellite readers · `tathu/satellite`
- [Radar adapter](https://github.com/uba/tathu/blob/master/tathu/radar/radar.py): sensor adapter · Radar CAPPI reader and normalization entry point · `tathu/radar/radar.py`
- [Downloaders](https://github.com/uba/tathu/tree/master/tathu/downloader): ingest helpers · Fetches source data from external providers · `tathu/downloader`

### Spatial model

Common geometry and normalization layer

- [Geometry](https://github.com/uba/tathu/tree/master/tathu/geometry): geo primitives · Extents, transforms, envelopes, and spatial utilities · `tathu/geometry`

### Tracking core

Detection, descriptors, association, forecasting, and storm entities

- [Detectors](https://github.com/uba/tathu/blob/master/tathu/tracking/detectors.py): storm detection · Thresholding and connected-region detection of convective objects · `tathu/tracking/detectors.py`
- [Descriptors](https://github.com/uba/tathu/blob/master/tathu/tracking/descriptors.py): storm features · Area and intensity statistics for detected systems · `tathu/tracking/descriptors.py`
- [Convective system](https://github.com/uba/tathu/blob/master/tathu/tracking/system.py): storm entity · Shared storm object carrying geometry, timestamp, and derived fields · `tathu/tracking/system.py`
- [Trackers](https://github.com/uba/tathu/blob/master/tathu/tracking/trackers.py): object association · Links detections across time into storm lifecycles · `tathu/tracking/trackers.py`
- [Forecasters](https://github.com/uba/tathu/blob/master/tathu/tracking/forecasters.py): motion forecast · Extrapolates future behavior from tracked history · `tathu/tracking/forecasters.py`
- [Squall line](https://github.com/uba/tathu/blob/master/tathu/tracking/squall_line.py): specialized tracking · Domain-specific storm interpretation and tracking extension · `tathu/tracking/squall_line.py`
- [Tracking utils](https://github.com/uba/tathu/blob/master/tathu/tracking/utils.py): tracking helpers · Shared helper logic for tracking workflows · `tathu/tracking/utils.py`

### Persistence

Outputs and database-backed exchange

- [CSV I/O](https://github.com/uba/tathu/blob/master/tathu/io/icsv.py): tabular output · CSV-like persistence for storm tracks and summaries · `tathu/io/icsv.py`
- [SpatiaLite](https://github.com/uba/tathu/blob/master/tathu/io/spatialite.py): spatial database · SQLite/SpatiaLite storage for tracked systems · `tathu/io/spatialite.py`
- [PostGIS](https://github.com/uba/tathu/blob/master/tathu/io/pgis.py): spatial database · PostgreSQL/PostGIS persistence and queries · `tathu/io/pgis.py`
- [Forecast I/O](https://github.com/uba/tathu/blob/master/tathu/io/forecast.py): forecast exchange · Read/write helpers for forecast products and metadata · `tathu/io/forecast.py`

### Visualization

Map and lifecycle presentation

- [Visualizer](https://github.com/uba/tathu/blob/master/tathu/visualizer.py): presentation · Map-based and lifecycle visual views · `tathu/visualizer.py`

### Other components

- [tathu](https://github.com/uba/tathu/blob/master/tathu/__init__.py): package root · Top-level library package exposing the public surface · `tathu/__init__.py`

## Connections

- tathu → Satellite adapters: uses · Library entry point exposes sensor adapters
- tathu → Radar adapter: uses · Library entry point exposes radar support
- tathu → Geometry: uses · Core package depends on spatial primitives
- tathu → Detectors: uses · Public API includes tracking pipeline components
- Satellite adapters → Geometry: normalize · Remap sensor-native data into a common spatial form
- Radar adapter → Geometry: normalize · Convert radar products to analysis-ready grids
- Downloaders → Satellite adapters: feeds · Fetches upstream products for adapter processing
- Geometry → Detectors: grid · Detection operates on normalized spatial grids
- Detectors → Convective system: creates · Candidate objects become storm entities
- Detectors → Descriptors: passes · Detected objects are enriched with quantitative features
- Descriptors → Convective system: annotates · Derived metrics are stored on the storm entity
- Convective system → Trackers: links · Tracked objects are associated across time steps
- Trackers → Forecasters: history · Track history provides the basis for prediction
- Trackers → Squall line: specializes · Specialized storm interpretations extend generic tracking
- Trackers → Tracking utils: shares · Common logic supports association strategies
- Convective system → CSV I/O: exports · Track results can be serialized to tabular form
- Convective system → SpatiaLite: persists · Storm families can be stored in spatial SQLite
- Convective system → PostGIS: persists · Storm families can be stored in PostGIS
- Forecasters → Forecast I/O: writes · Predictions are exchanged through forecast I/O
- SpatiaLite → Visualizer: loads · Stored histories can be queried for visualization
- PostGIS → Visualizer: loads · Database-backed tracks can be rendered and inspected
- Geometry → Visualizer: renders · Visualization consumes normalized geometry and grids
- Examples & docs → Satellite adapters: demonstrates · Examples and notebooks show sensor-specific workflows
- Examples & docs → Trackers: demonstrates · Documentation covers detection, tracking, and forecasting flows
