# oceanmodeling/ondemand-storm-workflow architecture

> Architecture diagram of the GitHub repository oceanmodeling/ondemand-storm-workflow, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/oceanmodeling/ondemand-storm-workflow
- Repository: https://github.com/oceanmodeling/ondemand-storm-workflow

## Overview

1. **What this repository is**
   - `stormworkflow` is a Python workflow for generating **probabilistic storm-surge products** from an **ensemble of tropical cyclone simulations**.
   - The repo is organized as a pipeline: **prepare inputs → run simulations on HPC → postprocess ensemble outputs → validate/visualize results**.

2. **Top-level orchestration**
   - `stormworkflow/main.py` is the likely Python entrypoint that ties the workflow together.
   - The package layout suggests the workflow is driven by configuration and then dispatches into prep or postprocessing steps rather than embedding the solver itself in Python.

3. **Preprocessing subsystem**
   - `stormworkflow/prep/` contains the input-building side of the workflow.
   - Key responsibilities appear to be:
     - fetching external datasets (`download_data.py`)
     - assembling hurricane forcing and event metadata (`hurricane_data.py`)
     - generating or adapting the computational mesh (`hurricane_mesh.py`)
     - defining ensemble members / parameter perturbations (`setup_ensemble.py`)
     - generating model-ready directories and input files (`setup_model.py`)
     - optional wave-model setup (`wwm.py`)
   - This is the stage where raw scientific data becomes solver-ready inputs.

4. **Simulation/model boundary**
   - The presence of `stormworkflow/refs/param.nml`, `input.yaml`, and `wwminput.nml` indicates the workflow emits **Fortran-style namelist and YAML configuration files** consumed by downstream model components.
   - The `stormworkflow/slurm/` directory and `schism.sbatch` strongly imply the actual storm-surge solver runs externally on a **SLURM-managed HPC cluster**, likely using **SCHISM** or a closely related coastal model.
   - Python prepares the run; HPC scripts execute the heavy numerical model.

5. **Batch and operational scripts**
   - `stormworkflow/scripts/` contains shell helpers that likely glue together the workflow stages:
     - `entrypoint.sh`
     - `workflow.sh`
     - `combine_gr3.exp`
   - These scripts are the operational boundary between Python orchestration and cluster execution, and are likely used in containers or job-launch contexts.

6. **SLURM job definitions**
   - `stormworkflow/slurm/prep.sbatch`, `mesh.sbatch`, `post.sbatch`, and `schism.sbatch` indicate the workflow is split into separate compute jobs.
   - This separation suggests a distributed execution model:
     - prep/mesh generation jobs
     - model simulation jobs
     - postprocessing jobs
   - That boundary is important for architecture diagrams because compute-heavy steps do not run in the same process as the Python controller.

7. **Postprocessing subsystem**
   - `stormworkflow/post/` handles aggregation and analysis of simulation outputs.
   - The modules indicate several distinct postprocessing products:
     - ensemble combination (`combine_ensemble.py`)
     - ensemble statistics/analysis (`analyze_ensemble.py`)
     - visualization generation (`generate_viz.py`)
     - surge/hurricane-specific diagnostics (`hurricane_funcs.py`)
     - maximum elevation and difference analyses (`max_ele_vs_hwm.py`, `maxelev_diff.py`)
     - validation against tides/observations (`Tidal_validation.py`)
     - storm return/relative curve analysis (`storm_roc_ts_rel_curves.py`)
   - This stage converts raw per-member model output into probabilistic and validation-oriented deliverables.

8. **Reference assets and templates**
   - `stormworkflow/refs/` stores canonical input templates and model defaults.
   - These reference files are important because they define the baseline configuration used to generate a reproducible simulation set.
   - The workflow likely copies or parameterizes these templates during setup.

9. **Versioned inputs and backward compatibility**
   - `tests/data/refs/input_v0.0.1.yaml` through `input_v0.0.5.yaml` plus `leadtime.json` show that the input schema has evolved over time.
   - `tests/test_input_version.py` suggests the repo actively checks compatibility across input versions, which is an important architectural concern for a workflow intended to be reused across events and releases.

10. **Testing and validation**
    - `tests/test_prep_funcs.py` focuses on preprocessing logic, meaning the repository emphasizes correctness in input generation.
    - `tests/test.sh` and `tests/conftest.py` suggest integration-style test execution in addition to unit tests.
    - The `tests/data/refs/` fixtures provide known-good configuration files for regression testing.

11. **Runtime and packaging**
    - `pyproject.toml` and `environment.yml` indicate standard Python packaging plus a Conda-based scientific runtime.
    - This is a scientific workflow repository rather than a general web service: the important runtime concerns are package reproducibility, numerical dependencies, and HPC execution compatibility.

12. **Likely end-to-end data flow**
    - External hurricane/ocean inputs are acquired or staged in `prep/`.
    - Mesh and model configuration are generated.
    - Ensemble members are launched through SLURM and an external surge model.
    - Model outputs are collected by `post/` modules into probabilistic summaries, validation metrics, and plots.

13. **Key architectural boundary**
    - The most important boundary is between **workflow control in Python** and **numerical simulation in external HPC jobs**.
    - Another important boundary is between **event-specific inputs/configuration** and **generic reusable postprocessing/validation code**.

14. **What to draw in an architecture diagram**
    - Show a Python orchestrator at the center.
    - Feed it with reference templates and external hurricane datasets.
    - From it, branch to preprocessing, then to SLURM-managed simulation jobs, then to postprocessing/visualization/validation.
    - Include tests and versioned input fixtures as a separate quality-control lane.

Main entry points: [`stormworkflow/post/analyze_ensemble.py`](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/post/analyze_ensemble.py) (Analyze ensemble), [`stormworkflow/prep/setup_model.py`](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/prep/setup_model.py) (Model setup), [`stormworkflow/scripts/workflow.sh`](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/scripts/workflow.sh) (Workflow script), [`tests`](https://github.com/oceanmodeling/ondemand-storm-workflow/tree/main/tests) (Tests)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_orch["Orchestration"]
  node_n_main["Workflow main<br/>python entrypoint<br/>[main.py]"]
  node_n_entry["Entrypoint<br/>shell launcher<br/>[entrypoint.sh]"]
  node_n_workflow_sh["Workflow script<br/>shell orchestration<br/>[workflow.sh]"]
  node_n_refs["Reference templates<br/>model defaults<br/>[input.yaml]"]
end

subgraph group_grp_prep["Preprocessing"]
  node_n_download["Fetch data<br/>prep data staging<br/>[download_data.py]"]
  node_n_hurr_data["Storm data<br/>prep metadata<br/>[hurricane_data.py]"]
  node_n_mesh["Mesh setup<br/>prep mesh<br/>[hurricane_mesh.py]"]
  node_n_ensemble["Ensemble setup<br/>prep members<br/>[setup_ensemble.py]"]
  node_n_model["Model setup<br/>prep inputs<br/>[setup_model.py]"]
  node_n_wwm["Wave setup<br/>prep coupling<br/>[wwm.py]"]
end

subgraph group_grp_run["HPC Run"]
  node_n_prep_job["Prep job<br/>slurm job<br/>[prep.sbatch]"]
  node_n_mesh_job["Mesh job<br/>slurm job<br/>[mesh.sbatch]"]
  node_n_schism_job["Solver job<br/>slurm job<br/>[schism.sbatch]"]
  node_n_post_job["Post job<br/>slurm job<br/>[post.sbatch]"]
end

subgraph group_grp_post["Postprocessing"]
  node_n_combine["Combine ensemble<br/>post aggregation"]
  node_n_analyze["Analyze ensemble<br/>post stats"]
  node_n_viz["Generate plots<br/>post viz<br/>[generate_viz.py]"]
  node_n_validate["Validate tides<br/>post validation"]
  node_n_hwm["HWM compare<br/>post diagnostics<br/>[max_ele_vs_hwm.py]"]
  node_n_diff["Elevation diff<br/>post diagnostics<br/>[maxelev_diff.py]"]
  node_n_roc["Return curves<br/>post analysis"]
end

subgraph group_grp_qc["Quality Control"]
  node_n_tests["Tests<br/>pytest suite"]
  node_n_fixtures["Versioned inputs<br/>test fixtures"]
end

node_n_main -->|"delegates"| node_n_workflow_sh
node_n_entry -->|"starts"| node_n_main
node_n_workflow_sh -->|"submits"| node_n_prep_job
node_n_workflow_sh -->|"submits"| node_n_mesh_job
node_n_workflow_sh -->|"submits"| node_n_schism_job
node_n_workflow_sh -->|"submits"| node_n_post_job
node_n_refs -->|"templates"| node_n_download
node_n_refs -->|"defaults"| node_n_model
node_n_download -->|"feeds"| node_n_hurr_data
node_n_hurr_data -->|"drives"| node_n_mesh
node_n_hurr_data -->|"drives"| node_n_ensemble
node_n_mesh -->|"produces"| node_n_model
node_n_ensemble -->|"parameterizes"| node_n_model
node_n_wwm -->|"couples"| node_n_model
node_n_model -->|"executes"| node_n_schism_job
node_n_schism_job -->|"outputs"| node_n_combine
node_n_combine -->|"feeds"| node_n_analyze
node_n_analyze -->|"renders"| node_n_viz
node_n_analyze -->|"checks"| node_n_validate
node_n_analyze -->|"checks"| node_n_hwm
node_n_analyze -->|"derives"| node_n_diff
node_n_analyze -->|"derives"| node_n_roc
node_n_tests -->|"uses"| node_n_fixtures
node_n_tests -.->|"covers"| node_n_main
node_n_tests -.->|"covers"| node_n_download
node_n_tests -.->|"covers"| node_n_model

click node_n_main "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/main.py"
click node_n_entry "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/scripts/entrypoint.sh"
click node_n_workflow_sh "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/scripts/workflow.sh"
click node_n_download "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/prep/download_data.py"
click node_n_hurr_data "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/prep/hurricane_data.py"
click node_n_mesh "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/prep/hurricane_mesh.py"
click node_n_ensemble "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/prep/setup_ensemble.py"
click node_n_model "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/prep/setup_model.py"
click node_n_wwm "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/prep/wwm.py"
click node_n_prep_job "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/slurm/prep.sbatch"
click node_n_mesh_job "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/slurm/mesh.sbatch"
click node_n_schism_job "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/slurm/schism.sbatch"
click node_n_post_job "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/slurm/post.sbatch"
click node_n_combine "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/post/combine_ensemble.py"
click node_n_analyze "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/post/analyze_ensemble.py"
click node_n_viz "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/post/generate_viz.py"
click node_n_validate "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/post/Tidal_validation.py"
click node_n_hwm "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/post/max_ele_vs_hwm.py"
click node_n_diff "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/post/maxelev_diff.py"
click node_n_roc "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/post/storm_roc_ts_rel_curves.py"
click node_n_tests "https://github.com/oceanmodeling/ondemand-storm-workflow/tree/main/tests"
click node_n_fixtures "https://github.com/oceanmodeling/ondemand-storm-workflow/tree/main/tests/data/refs"
click node_n_refs "https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/refs/input.yaml"

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_n_main,node_n_entry,node_n_workflow_sh,node_n_refs toneBlue
class node_n_download,node_n_hurr_data,node_n_mesh,node_n_ensemble,node_n_model,node_n_wwm toneAmber
class node_n_prep_job,node_n_mesh_job,node_n_schism_job,node_n_post_job toneMint
class node_n_combine,node_n_analyze,node_n_viz,node_n_validate,node_n_hwm,node_n_diff,node_n_roc toneRose
class node_n_tests,node_n_fixtures toneIndigo
```

## Components

### Orchestration

Python entrypoints and shell glue that coordinate the workflow

- [Workflow main](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/main.py): python entrypoint · Top-level workflow driver · `stormworkflow/main.py`
- [Entrypoint](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/scripts/entrypoint.sh): shell launcher · Container or job entry wrapper · `stormworkflow/scripts/entrypoint.sh`
- [Workflow script](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/scripts/workflow.sh): shell orchestration · Shell logic that ties stages together · `stormworkflow/scripts/workflow.sh`
- [Reference templates](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/refs/input.yaml): model defaults · Canonical input and namelist templates · `stormworkflow/refs/input.yaml`

### Preprocessing

Data acquisition, event setup, mesh generation, and model staging

- [Fetch data](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/prep/download_data.py): prep data staging · Download or stage external forcing data · `stormworkflow/prep/download_data.py`
- [Storm data](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/prep/hurricane_data.py): prep metadata · Hurricane event and forcing assembly · `stormworkflow/prep/hurricane_data.py`
- [Mesh setup](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/prep/hurricane_mesh.py): prep mesh · Generate or adapt computational mesh · `stormworkflow/prep/hurricane_mesh.py`
- [Ensemble setup](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/prep/setup_ensemble.py): prep members · Define perturbations and ensemble members · `stormworkflow/prep/setup_ensemble.py`
- [Model setup](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/prep/setup_model.py): prep inputs · Create run directories and model-ready inputs · `stormworkflow/prep/setup_model.py`
- [Wave setup](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/prep/wwm.py): prep coupling · Optional wave-model configuration · `stormworkflow/prep/wwm.py`

### HPC Run

SLURM jobs and external solver execution

- [Prep job](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/slurm/prep.sbatch): slurm job · Batch job for preprocessing stages · `stormworkflow/slurm/prep.sbatch`
- [Mesh job](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/slurm/mesh.sbatch): slurm job · Batch job for mesh generation or adaptation · `stormworkflow/slurm/mesh.sbatch`
- [Solver job](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/slurm/schism.sbatch): slurm job · Batch job that launches the external storm-surge model · `stormworkflow/slurm/schism.sbatch`
- [Post job](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/slurm/post.sbatch): slurm job · Batch job for output aggregation and analysis · `stormworkflow/slurm/post.sbatch`

### Postprocessing

Ensemble aggregation, diagnostics, validation, and plots

- [Combine ensemble](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/post/combine_ensemble.py): post aggregation · Merge member outputs into ensemble products · `stormworkflow/post/combine_ensemble.py`
- [Analyze ensemble](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/post/analyze_ensemble.py): post stats · Compute ensemble summaries and diagnostics · `stormworkflow/post/analyze_ensemble.py`
- [Generate plots](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/post/generate_viz.py): post viz · Produce visualizations and figures · `stormworkflow/post/generate_viz.py`
- [Validate tides](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/post/Tidal_validation.py): post validation · Compare model output against tide or observation data · `stormworkflow/post/Tidal_validation.py`
- [HWM compare](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/post/max_ele_vs_hwm.py): post diagnostics · Analyze max elevation versus high-water marks · `stormworkflow/post/max_ele_vs_hwm.py`
- [Elevation diff](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/post/maxelev_diff.py): post diagnostics · Compute maximum elevation differences · `stormworkflow/post/maxelev_diff.py`
- [Return curves](https://github.com/oceanmodeling/ondemand-storm-workflow/blob/main/stormworkflow/post/storm_roc_ts_rel_curves.py): post analysis · Storm return and relative curve analysis · `stormworkflow/post/storm_roc_ts_rel_curves.py`

### Quality Control

Tests and versioned fixtures that guard input compatibility

- [Tests](https://github.com/oceanmodeling/ondemand-storm-workflow/tree/main/tests): pytest suite · Unit and integration checks for workflow logic · `tests`
- [Versioned inputs](https://github.com/oceanmodeling/ondemand-storm-workflow/tree/main/tests/data/refs): test fixtures · Back-compat input samples and lead-time fixture · `tests/data/refs`

## Connections

- Workflow main → Workflow script: delegates · Python entrypoint hands off orchestration to shell workflow
- Entrypoint → Workflow main: starts · Entry wrapper launches the Python controller
- Workflow script → Prep job: submits · Workflow dispatches preprocessing batch jobs
- Workflow script → Mesh job: submits · Workflow dispatches mesh generation jobs
- Workflow script → Solver job: submits · Workflow dispatches solver runs on SLURM
- Workflow script → Post job: submits · Workflow dispatches postprocessing jobs
- Reference templates → Fetch data: templates · Reference configuration seeds preprocessing
- Reference templates → Model setup: defaults · Canonical model inputs are parameterized into run files
- Fetch data → Storm data: feeds · Fetched datasets become event-specific forcing
- Storm data → Mesh setup: drives · Storm metadata informs mesh and domain setup
- Storm data → Ensemble setup: drives · Event metadata defines ensemble construction
- Mesh setup → Model setup: produces · Mesh artifacts are staged into model inputs
- Ensemble setup → Model setup: parameterizes · Ensemble members are written into model-ready runs
- Wave setup → Model setup: couples · Optional wave-model inputs are added to run configuration
- Model setup → Solver job: executes · Prepared inputs are consumed by the external solver
- Solver job → Combine ensemble: outputs · Solver outputs are collected for ensemble merging
- Combine ensemble → Analyze ensemble: feeds · Combined outputs are summarized and analyzed
- Analyze ensemble → Generate plots: renders · Analysis results become plots and deliverables
- Analyze ensemble → Validate tides: checks · Ensemble statistics are compared against observations
- Analyze ensemble → HWM compare: checks · Maximum surge/elevation is compared to high-water marks
- Analyze ensemble → Elevation diff: derives · Difference diagnostics are computed from ensemble output
- Analyze ensemble → Return curves: derives · Return-curve analysis is generated from postprocessed fields
- Tests → Versioned inputs: uses · Tests rely on versioned input fixtures
- Tests → Workflow main: covers · Test suite exercises workflow orchestration
- Tests → Fetch data: covers · Test suite exercises preprocessing behavior
- Tests → Model setup: covers · Test suite checks model input generation
