# emit-sds/emit-sds-tgp architecture

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

- Interactive diagram: https://gitdiagram.com/emit-sds/emit-sds-tgp
- Repository: https://github.com/emit-sds/emit-sds-tgp

## Overview

#### Purpose and operational entry point
This repository controls an EMIT trace-gas plume workflow: ingesting manual or ML delineations, enriching and filtering them, quantifying emissions, and preparing products for delivery. The operational orchestrator is `src/scrape_refine_upload.py`, invoked with an authentication token, source layer, output directory, product version, database configuration, and track-coverage file.

#### Workflow orchestration and source boundary
`src/scrape_refine_upload.py` is the primary control-plane boundary between external delineation sources and downstream processing. It coordinates scraping, refinement, upload/delivery-oriented output handling, and operational inputs such as credentials, a database configuration file, and coverage metadata. The `layer` argument indicates that delineations are selected from an external layer/source rather than created by this repository.

Paths:
- `src/scrape_refine_upload.py`
- `src/annotate/plume_io.py`

#### Annotation ingestion, metadata, and filtering
The annotation package normalizes plume/delineation data, attaches workflow metadata, and applies acceptance or rejection criteria before quantification or publication. This is the interface intended for both manual and ML-based plume boundaries. Plume I/O separates source/product representations from processing logic, while filtering establishes a quality-control boundary.

Paths:
- `src/annotate/plume_io.py`
- `src/annotate/filter.py`
- `src/annotate/utils.py`

#### Quantification engine
Quantification is a separable scientific subsystem that converts accepted plume geometry and supporting measurements into emission-rate estimates and uncertainties. The implementation includes a simple Integrated Mass Enhancement (IME) approach, wind-speed handling, flux computation, and uncertainty utilities. It can run independently of the full operational scrape/refine/delivery path.

Paths:
- `src/quantification/simple_ime.py`
- `src/quantification/compute_Q_and_Qunc_simple_IME.py`
- `src/quantification/compute_flux.py`

#### Wind and uncertainty dependencies
Emission estimates depend on wind-speed inputs and uncertainty propagation; these are explicit stages rather than incidental calculations. Wind handling feeds flux/IME calculations, while shared uncertainty utilities support reported `Q` and `Qunc` outputs. This is the principal scientific boundary between delineated plume observations and quantified trace-gas products.

Paths:
- `src/quantification/windspeed.py`
- `src/quantification/compute_Q_and_uncertainty_utils.py`
- `src/quantification/compute_Q_and_Qunc_simple_IME.py`

#### Product discovery and delivery
Delivery logic discovers Cloud Optimized GeoTIFF (COG) products eligible for release and submits/packages them for the DAAC-facing delivery process. This forms the final boundary between internally generated/refined outputs and external distribution infrastructure.

Paths:
- `src/delivery/find_cogs_to_deliver.py`
- `src/delivery/daac_delivery.py`

#### Documentation and operational contract
The algorithm and user-facing behavior are specified in the trace-gas ATBD and User Guide; quantification-specific usage is documented alongside the quantification code. These documents define the scientific and product contract that the pipeline implements.

Paths:
- `docs/EMIT_L2B_TRACE_GAS_ATBD.md`
- `docs/EMIT_L2B_TRACE_GAS_User_Guide.md`
- `src/quantification/quantification_readme.md`

Main entry points: [`src/quantification/compute_Q_and_Qunc_simple_IME.py`](https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/quantification/compute_Q_and_Qunc_simple_IME.py) (Q and Qunc estimates), [`src/scrape_refine_upload.py`](https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/scrape_refine_upload.py) (Scrape, refine, upload), [`src/quantification/simple_ime.py`](https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/quantification/simple_ime.py) (Simple IME), [`src/quantification/compute_flux.py`](https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/quantification/compute_flux.py) (Flux computation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ops["Operations"]
  node_ops_inputs["Operational inputs<br/>credentials and metadata"]
  node_orchestrator["Scrape, refine, upload<br/>workflow orchestrator"]
end

subgraph group_annotation["Annotation QC"]
  node_plume_io["Plume I/O<br/>annotation adapter<br/>[plume_io.py]"]
  node_metadata["Annotation metadata<br/>workflow utilities<br/>[utils.py]"]
  node_filter["Plume quality filter<br/>QC boundary<br/>[filter.py]"]
end

subgraph group_quant["Quantification"]
  node_wind["Wind-speed handling<br/>scientific input<br/>[windspeed.py]"]
  node_ime["Simple IME<br/>quantification method<br/>[simple_ime.py]"]
  node_flux["Flux computation<br/>scientific calculation<br/>[compute_flux.py]"]
  node_uncertainty["Uncertainty utilities<br/>scientific utility"]
  node_q_product["Q and Qunc estimates<br/>quantification output"]
end

subgraph group_delivery["Delivery"]
  node_cog_discovery["COG release discovery<br/>product selector"]
  node_daac_delivery["DAAC delivery<br/>distribution adapter<br/>[daac_delivery.py]"]
end

subgraph group_docs["Scientific contract"]
  node_atbd["Trace-gas ATBD<br/>algorithm specification"]
  node_user_guide["Trace-gas User Guide<br/>product guide"]
  node_quant_readme["Quantification guide<br/>usage documentation"]
end

node_sources{{"External delineation layers<br/>source boundary"}}

node_sources -->|"selected layer"| node_orchestrator
node_ops_inputs -->|"runtime parameters"| node_orchestrator
node_orchestrator -->|"ingests delineations"| node_plume_io
node_plume_io -->|"normalized plumes"| node_metadata
node_metadata -->|"annotated plumes"| node_filter
node_filter -->|"accepted plumes"| node_ime
node_wind -->|"wind input"| node_ime
node_ime -->|"IME quantities"| node_flux
node_wind -->|"wind speed"| node_flux
node_flux -->|"flux estimate"| node_q_product
node_uncertainty -->|"propagation"| node_q_product
node_ime -->|"plume quantities"| node_q_product
node_orchestrator -->|"prepares release outputs"| node_cog_discovery
node_q_product -->|"quantified products"| node_cog_discovery
node_cog_discovery -->|"eligible COGs"| node_daac_delivery
node_atbd -.->|"specifies algorithm"| node_q_product
node_user_guide -.->|"defines behavior"| node_orchestrator
node_quant_readme -.->|"documents usage"| node_q_product

click node_orchestrator "https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/scrape_refine_upload.py"
click node_plume_io "https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/annotate/plume_io.py"
click node_metadata "https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/annotate/utils.py"
click node_filter "https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/annotate/filter.py"
click node_wind "https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/quantification/windspeed.py"
click node_ime "https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/quantification/simple_ime.py"
click node_flux "https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/quantification/compute_flux.py"
click node_uncertainty "https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/quantification/compute_Q_and_uncertainty_utils.py"
click node_q_product "https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/quantification/compute_Q_and_Qunc_simple_IME.py"
click node_cog_discovery "https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/delivery/find_cogs_to_deliver.py"
click node_daac_delivery "https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/delivery/daac_delivery.py"
click node_atbd "https://github.com/emit-sds/emit-sds-tgp/blob/develop/docs/EMIT_L2B_TRACE_GAS_ATBD.md"
click node_user_guide "https://github.com/emit-sds/emit-sds-tgp/blob/develop/docs/EMIT_L2B_TRACE_GAS_User_Guide.md"
click node_quant_readme "https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/quantification/quantification_readme.md"

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_ops_inputs,node_orchestrator toneBlue
class node_plume_io,node_metadata,node_filter toneAmber
class node_wind,node_ime,node_flux,node_uncertainty,node_q_product toneMint
class node_cog_discovery,node_daac_delivery toneRose
class node_atbd,node_user_guide,node_quant_readme toneIndigo
class node_sources toneNeutral
```

## Components

### Operations

- **Operational inputs**: credentials and metadata · Token, database configuration, output directory, version, and track coverage.
- [Scrape, refine, upload](https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/scrape_refine_upload.py): workflow orchestrator · Operational entry point for the end-to-end plume workflow. · `src/scrape_refine_upload.py`

### Annotation QC

- [Plume I/O](https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/annotate/plume_io.py): annotation adapter · Normalizes source and product plume representations. · `src/annotate/plume_io.py`
- [Annotation metadata](https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/annotate/utils.py): workflow utilities · Attaches processing metadata to plume records. · `src/annotate/utils.py`
- [Plume quality filter](https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/annotate/filter.py): QC boundary · Accepts or rejects delineations before downstream use. · `src/annotate/filter.py`

### Quantification

- [Wind-speed handling](https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/quantification/windspeed.py): scientific input · Supplies wind information for emission estimates. · `src/quantification/windspeed.py`
- [Simple IME](https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/quantification/simple_ime.py): quantification method · Computes integrated mass enhancement quantities. · `src/quantification/simple_ime.py`
- [Flux computation](https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/quantification/compute_flux.py): scientific calculation · Converts plume and wind inputs into flux terms. · `src/quantification/compute_flux.py`
- [Uncertainty utilities](https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/quantification/compute_Q_and_uncertainty_utils.py): scientific utility · Provides shared uncertainty propagation. · `src/quantification/compute_Q_and_uncertainty_utils.py`
- [Q and Qunc estimates](https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/quantification/compute_Q_and_Qunc_simple_IME.py): quantification output · Produces emission-rate estimates and uncertainties. · `src/quantification/compute_Q_and_Qunc_simple_IME.py`

### Delivery

- [COG release discovery](https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/delivery/find_cogs_to_deliver.py): product selector · Finds Cloud Optimized GeoTIFF products eligible for release. · `src/delivery/find_cogs_to_deliver.py`
- [DAAC delivery](https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/delivery/daac_delivery.py): distribution adapter · Packages and submits products to external delivery infrastructure. · `src/delivery/daac_delivery.py`

### Scientific contract

- [Trace-gas ATBD](https://github.com/emit-sds/emit-sds-tgp/blob/develop/docs/EMIT_L2B_TRACE_GAS_ATBD.md): algorithm specification · Defines the scientific algorithm contract. · `docs/EMIT_L2B_TRACE_GAS_ATBD.md`
- [Trace-gas User Guide](https://github.com/emit-sds/emit-sds-tgp/blob/develop/docs/EMIT_L2B_TRACE_GAS_User_Guide.md): product guide · Defines user-facing product behavior. · `docs/EMIT_L2B_TRACE_GAS_User_Guide.md`
- [Quantification guide](https://github.com/emit-sds/emit-sds-tgp/blob/develop/src/quantification/quantification_readme.md): usage documentation · Documents quantification-specific operation. · `src/quantification/quantification_readme.md`

### Other components

- **External delineation layers**: source boundary · Manual and ML plume boundaries selected by layer.

## Connections

- External delineation layers → Scrape, refine, upload: selected layer
- Operational inputs → Scrape, refine, upload: runtime parameters
- Scrape, refine, upload → Plume I/O: ingests delineations
- Plume I/O → Annotation metadata: normalized plumes
- Annotation metadata → Plume quality filter: annotated plumes
- Plume quality filter → Simple IME: accepted plumes
- Wind-speed handling → Simple IME: wind input
- Simple IME → Flux computation: IME quantities
- Wind-speed handling → Flux computation: wind speed
- Flux computation → Q and Qunc estimates: flux estimate
- Uncertainty utilities → Q and Qunc estimates: propagation
- Simple IME → Q and Qunc estimates: plume quantities
- Scrape, refine, upload → COG release discovery: prepares release outputs
- Q and Qunc estimates → COG release discovery: quantified products
- COG release discovery → DAAC delivery: eligible COGs
- Trace-gas ATBD → Q and Qunc estimates: specifies algorithm
- Trace-gas User Guide → Scrape, refine, upload: defines behavior
- Quantification guide → Q and Qunc estimates: documents usage
