# mzhen77/neural-ca-wildfire architecture

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

- Interactive diagram: https://gitdiagram.com/mzhen77/neural-ca-wildfire
- Repository: https://github.com/mzhen77/neural-ca-wildfire

## Overview

Neural CA Wildfire trains a CNN-parameterized probabilistic cellular automaton to predict daily fire spread from LANDFIRE terrain/fuel, ERA5 wind, and observed fire histories. The main workflow loads and preprocesses configured events, initializes the model, simulates spread, evaluates losses, and saves checkpoints; included notebooks use a saved checkpoint for metric and spatial plots. The graph follows the sampled training path and README-documented data extraction and plotting capabilities; notebook internals were not sampled.

Main entry points: [`src/main.py`](https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/main.py) (Training entry point), [`src/training.py`](https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/training.py) (Optimizer and training loop), [`data/data_extractor.py`](https://github.com/mzhen77/neural-ca-wildfire/blob/main/data/data_extractor.py) (HDF5 extractor), [`src/data_loader.py`](https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/data_loader.py) (Event loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_extractor["HDF5 extractor<br/>[data_extractor.py]"]
  node_hdf5[("HDF5 dataset<br/>[dataset.hdf5]")]
  node_eventdata[("Event rasters")]
  node_loader["Event loader<br/>[data_loader.py]"]
  node_preprocess["Feature preprocessing<br/>[preprocessing.py]"]
end

subgraph group_simulation["Fire simulation"]
  node_fuel["Fuel embedding<br/>[model.py]"]
  node_cnn["Multi-scale CNN<br/>[model.py]"]
  node_ca["Wildfire CA<br/>[model.py]"]
  node_simloop["Simulation loops<br/>[simulation.py]"]
end

subgraph group_learning["Training and evaluation"]
  node_entry["Training entry point<br/>[main.py]"]
  node_config["Training configuration<br/>[config.yaml]"]
  node_training["Optimizer and training loop<br/>[training.py]"]
  node_loss["Loss metrics<br/>[loss.py]"]
end

subgraph group_outputs["Results and analysis"]
  node_checkpoints[("Saved checkpoints")]
  node_plots1d["Metric plots"]
  node_plots2d["Spatial plots"]
  node_plotfiles["Generated figures"]
end

node_operator(("Researcher"))

node_operator -->|"runs extraction"| node_extractor
node_extractor -->|"reads"| node_hdf5
node_extractor -->|"writes events"| node_eventdata
node_operator -->|"starts training"| node_entry
node_entry -->|"loads config"| node_config
node_entry -->|"loads events"| node_loader
node_loader -->|"reads rasters"| node_eventdata
node_loader -->|"preprocesses inputs"| node_preprocess
node_entry -->|"initializes model"| node_fuel
node_fuel -->|"embeds fuel"| node_cnn
node_cnn -->|"generates parameters"| node_ca
node_entry -->|"starts training"| node_training
node_training -->|"simulates spread"| node_simloop
node_simloop -->|"steps CA"| node_ca
node_training -->|"computes loss"| node_loss
node_training -.->|"saves model"| node_checkpoints
node_operator -->|"runs notebook"| node_plots1d
node_operator -->|"runs notebook"| node_plots2d
node_plots1d -->|"loads checkpoint"| node_checkpoints
node_plots2d -->|"loads checkpoint"| node_checkpoints
node_plots1d -->|"writes figures"| node_plotfiles
node_plots2d -->|"writes figures"| node_plotfiles

click node_extractor "https://github.com/mzhen77/neural-ca-wildfire/blob/main/data/data_extractor.py"
click node_hdf5 "https://github.com/mzhen77/neural-ca-wildfire/blob/main/data/hdf5/dataset.hdf5"
click node_eventdata "https://github.com/mzhen77/neural-ca-wildfire/tree/main/data/data_real"
click node_loader "https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/data_loader.py"
click node_preprocess "https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/preprocessing.py"
click node_entry "https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/main.py"
click node_config "https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/config.yaml"
click node_fuel "https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/model.py"
click node_cnn "https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/model.py"
click node_ca "https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/model.py"
click node_simloop "https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/simulation.py"
click node_training "https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/training.py"
click node_loss "https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/loss.py"
click node_checkpoints "https://github.com/mzhen77/neural-ca-wildfire/tree/main/result_saved/best_model"
click node_plots1d "https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/paper_plots_1d.ipynb"
click node_plots2d "https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/paper_plots_2d.ipynb"
click node_plotfiles "https://github.com/mzhen77/neural-ca-wildfire/tree/main/result_saved/paper_plots"

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_extractor,node_hdf5,node_eventdata,node_loader,node_preprocess toneBlue
class node_fuel,node_cnn,node_ca,node_simloop toneAmber
class node_entry,node_config,node_training,node_loss toneMint
class node_checkpoints,node_plots1d,node_plots2d,node_plotfiles toneRose
class node_operator toneIndigo
```

## Components

### Data preparation

- [HDF5 extractor](https://github.com/mzhen77/neural-ca-wildfire/blob/main/data/data_extractor.py): `data/data_extractor.py`
- [HDF5 dataset](https://github.com/mzhen77/neural-ca-wildfire/blob/main/data/hdf5/dataset.hdf5): `data/hdf5/dataset.hdf5`
- [Event rasters](https://github.com/mzhen77/neural-ca-wildfire/tree/main/data/data_real): `data/data_real`
- [Event loader](https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/data_loader.py): `src/data_loader.py`
- [Feature preprocessing](https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/preprocessing.py): `src/preprocessing.py`

### Fire simulation

- [Fuel embedding](https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/model.py): `src/model.py`
- [Multi-scale CNN](https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/model.py): `src/model.py`
- [Wildfire CA](https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/model.py): `src/model.py`
- [Simulation loops](https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/simulation.py): `src/simulation.py`

### Training and evaluation

- [Training entry point](https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/main.py): `src/main.py`
- [Training configuration](https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/config.yaml): `src/config.yaml`
- [Optimizer and training loop](https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/training.py): `src/training.py`
- [Loss metrics](https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/loss.py): `src/loss.py`

### Results and analysis

- [Saved checkpoints](https://github.com/mzhen77/neural-ca-wildfire/tree/main/result_saved/best_model): `result_saved/best_model`
- [Metric plots](https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/paper_plots_1d.ipynb): `src/paper_plots_1d.ipynb`
- [Spatial plots](https://github.com/mzhen77/neural-ca-wildfire/blob/main/src/paper_plots_2d.ipynb): `src/paper_plots_2d.ipynb`
- [Generated figures](https://github.com/mzhen77/neural-ca-wildfire/tree/main/result_saved/paper_plots): `result_saved/paper_plots`

### Other components

- **Researcher**

## Connections

- Researcher → HDF5 extractor: runs extraction (evidence: `README.md`)
- HDF5 extractor → HDF5 dataset: reads (evidence: `README.md`)
- HDF5 extractor → Event rasters: writes events (evidence: `README.md`)
- Researcher → Training entry point: starts training (evidence: `README.md`)
- Training entry point → Training configuration: loads config (evidence: `src/main.py`)
- Training entry point → Event loader: loads events (evidence: `src/main.py`)
- Event loader → Event rasters: reads rasters (evidence: `README.md`)
- Event loader → Feature preprocessing: preprocesses inputs (evidence: `src/data_loader.py`)
- Training entry point → Fuel embedding: initializes model (evidence: `src/main.py`)
- Fuel embedding → Multi-scale CNN: embeds fuel (evidence: `src/model.py`)
- Multi-scale CNN → Wildfire CA: generates parameters (evidence: `src/model.py`)
- Training entry point → Optimizer and training loop: starts training (evidence: `src/main.py`)
- Optimizer and training loop → Simulation loops: simulates spread (evidence: `src/training.py`)
- Simulation loops → Wildfire CA: steps CA (evidence: `src/simulation.py`)
- Optimizer and training loop → Loss metrics: computes loss (evidence: `src/training.py`)
- Optimizer and training loop → Saved checkpoints: saves model
- Researcher → Metric plots: runs notebook (evidence: `README.md`)
- Researcher → Spatial plots: runs notebook (evidence: `README.md`)
- Metric plots → Saved checkpoints: loads checkpoint (evidence: `README.md`)
- Spatial plots → Saved checkpoints: loads checkpoint (evidence: `README.md`)
- Metric plots → Generated figures: writes figures (evidence: `README.md`)
- Spatial plots → Generated figures: writes figures (evidence: `README.md`)
