# afahadabdullah/mlanalysis architecture

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

- Interactive diagram: https://gitdiagram.com/afahadabdullah/mlanalysis
- Repository: https://github.com/afahadabdullah/mlanalysis

## Overview

MLanalysis is a research workflow for testing how a frozen GraphCast weather model responds to foreign reanalyses and inserted surface observations. Data preparation supplies ERA5 or MERRA-2 states and climatologies; the main experiment runs forecast and data-assimilation arms, then verification scripts score outcomes and plotting scripts summarize them. The main experiment and its links to GraphCast, scoring, and global maps are supported by the source index; several internal stages are described in the README but are implemented within unsampled portions of the experiment script.

Main entry points: [`scripts/exp_main_real_obs.py`](https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/exp_main_real_obs.py) (Real-observation experiment), [`scripts/prep_merra2.py`](https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/prep_merra2.py) (MERRA-2 mapping), [`scripts/build_clim.py`](https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/build_clim.py) (Climatologies), [`scripts/download_era5_cloud.py`](https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/download_era5_cloud.py) (ERA5 download)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Data preparation"]
  node_era5_download["ERA5 download"]
  node_merra_prep["MERRA-2 mapping<br/>[prep_merra2.py]"]
  node_climatology["Climatologies<br/>[build_clim.py]"]
  node_observations["Station observations"]
  node_uscrn["USCRN reference"]
  node_input_data[("Analysis and observations")]
end

subgraph group_assimilation["Forecast experiments"]
  node_experiment["Real-observation experiment"]
  node_cycling_twin["Cycling twin experiment"]
  node_graphcast["GraphCast interface<br/>[__init__.py]"]
  node_forecast_fields["Forecast fields"]
  node_station_analysis["Station insertion"]
  node_replay["Replay cycling"]
  node_four_dvar["4D-Var"]
end

subgraph group_verification["Verification"]
  node_verification["Forecast verification"]
  node_anomaly_scores["Foreign-analysis scoring<br/>[score_anomalies.py]"]
end

subgraph group_presentation["Results presentation"]
  node_global_maps["Global maps"]
  node_diagnostic_plots["Diagnostics"]
  node_machinery_synthesis["DA synthesis"]
end

node_researcher(("Researcher"))

node_researcher -->|"requests data"| node_era5_download
node_researcher -->|"prepares analysis"| node_merra_prep
node_researcher -->|"builds climatology"| node_climatology
node_era5_download -->|"writes analysis"| node_input_data
node_merra_prep -->|"writes mapped state"| node_input_data
node_climatology -->|"writes climatology"| node_input_data
node_observations -.->|"provides stations"| node_input_data
node_uscrn -.->|"provides reference"| node_input_data
node_input_data -.->|"initializes run"| node_experiment
node_experiment -->|"uses model"| node_graphcast
node_experiment -.->|"runs insertion"| node_station_analysis
node_experiment -.->|"runs cycling"| node_replay
node_experiment -.->|"runs optimization"| node_four_dvar
node_experiment -.->|"writes fields"| node_forecast_fields
node_experiment -.->|"computes scores"| node_verification
node_experiment -->|"invokes maps"| node_global_maps
node_experiment -->|"invokes scoring"| node_anomaly_scores
node_forecast_fields -->|"scores fields"| node_anomaly_scores
node_forecast_fields -->|"plots fields"| node_global_maps
node_forecast_fields -.->|"plots diagnostics"| node_diagnostic_plots
node_verification -.->|"summarizes results"| node_machinery_synthesis
node_researcher -.->|"runs twin"| node_cycling_twin
node_cycling_twin -->|"uses model"| node_graphcast
node_merra_prep -->|"supplies source"| node_climatology

click node_era5_download "https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/download_era5_cloud.py"
click node_merra_prep "https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/prep_merra2.py"
click node_climatology "https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/build_clim.py"
click node_observations "https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/download_isd_lite.py"
click node_uscrn "https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/download_uscrn_range.py"
click node_experiment "https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/exp_main_real_obs.py"
click node_cycling_twin "https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/exp0_v3_cycling_twin.py"
click node_graphcast "https://github.com/afahadabdullah/mlanalysis/blob/main/graphcast/__init__.py"
click node_station_analysis "https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/exp_main_real_obs.py"
click node_replay "https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/exp_main_real_obs.py"
click node_four_dvar "https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/exp_main_real_obs.py"
click node_verification "https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/exp_main_real_obs.py"
click node_anomaly_scores "https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/score_anomalies.py"
click node_global_maps "https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/plot_global_maps.py"
click node_diagnostic_plots "https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/plot_diagnostics.py"
click node_machinery_synthesis "https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/plot_da_machinery_synthesis.py"

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_era5_download,node_merra_prep,node_climatology,node_observations,node_uscrn,node_input_data toneBlue
class node_experiment,node_cycling_twin,node_graphcast,node_forecast_fields,node_station_analysis,node_replay,node_four_dvar toneAmber
class node_verification,node_anomaly_scores toneMint
class node_global_maps,node_diagnostic_plots,node_machinery_synthesis toneRose
class node_researcher toneIndigo
```

## Components

### Data preparation

- [ERA5 download](https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/download_era5_cloud.py): `scripts/download_era5_cloud.py`
- [MERRA-2 mapping](https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/prep_merra2.py): `scripts/prep_merra2.py`
- [Climatologies](https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/build_clim.py): `scripts/build_clim.py`
- [Station observations](https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/download_isd_lite.py): `scripts/download_isd_lite.py`
- [USCRN reference](https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/download_uscrn_range.py): `scripts/download_uscrn_range.py`
- **Analysis and observations**

### Forecast experiments

- [Real-observation experiment](https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/exp_main_real_obs.py): `scripts/exp_main_real_obs.py`
- [Cycling twin experiment](https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/exp0_v3_cycling_twin.py): `scripts/exp0_v3_cycling_twin.py`
- [GraphCast interface](https://github.com/afahadabdullah/mlanalysis/blob/main/graphcast/__init__.py): `graphcast/__init__.py`
- **Forecast fields**
- [Station insertion](https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/exp_main_real_obs.py): `scripts/exp_main_real_obs.py`
- [Replay cycling](https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/exp_main_real_obs.py): `scripts/exp_main_real_obs.py`
- [4D-Var](https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/exp_main_real_obs.py): `scripts/exp_main_real_obs.py`

### Verification

- [Forecast verification](https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/exp_main_real_obs.py): `scripts/exp_main_real_obs.py`
- [Foreign-analysis scoring](https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/score_anomalies.py): `scripts/score_anomalies.py`

### Results presentation

- [Global maps](https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/plot_global_maps.py): `scripts/plot_global_maps.py`
- [Diagnostics](https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/plot_diagnostics.py): `scripts/plot_diagnostics.py`
- [DA synthesis](https://github.com/afahadabdullah/mlanalysis/blob/main/scripts/plot_da_machinery_synthesis.py): `scripts/plot_da_machinery_synthesis.py`

### Other components

- **Researcher**

## Connections

- Researcher → ERA5 download: requests data (evidence: `scripts/download_era5_cloud.py`)
- Researcher → MERRA-2 mapping: prepares analysis (evidence: `scripts/prep_merra2.py`)
- Researcher → Climatologies: builds climatology (evidence: `scripts/build_clim.py`)
- ERA5 download → Analysis and observations: writes analysis (evidence: `scripts/download_era5_cloud.py`)
- MERRA-2 mapping → Analysis and observations: writes mapped state (evidence: `scripts/prep_merra2.py`)
- Climatologies → Analysis and observations: writes climatology (evidence: `scripts/build_clim.py`)
- Station observations → Analysis and observations: provides stations
- USCRN reference → Analysis and observations: provides reference
- Analysis and observations → Real-observation experiment: initializes run
- Real-observation experiment → GraphCast interface: uses model (evidence: `scripts/exp_main_real_obs.py`)
- Real-observation experiment → Station insertion: runs insertion (evidence: `scripts/exp_main_real_obs.py`)
- Real-observation experiment → Replay cycling: runs cycling (evidence: `scripts/exp_main_real_obs.py`)
- Real-observation experiment → 4D-Var: runs optimization (evidence: `scripts/exp_main_real_obs.py`)
- Real-observation experiment → Forecast fields: writes fields
- Real-observation experiment → Forecast verification: computes scores (evidence: `scripts/exp_main_real_obs.py`)
- Real-observation experiment → Global maps: invokes maps (evidence: `scripts/exp_main_real_obs.py`)
- Real-observation experiment → Foreign-analysis scoring: invokes scoring (evidence: `scripts/exp_main_real_obs.py`)
- Forecast fields → Foreign-analysis scoring: scores fields (evidence: `scripts/score_anomalies.py`)
- Forecast fields → Global maps: plots fields (evidence: `scripts/plot_global_maps.py`)
- Forecast fields → Diagnostics: plots diagnostics
- Forecast verification → DA synthesis: summarizes results
- Researcher → Cycling twin experiment: runs twin
- Cycling twin experiment → GraphCast interface: uses model (evidence: `scripts/exp0_v3_cycling_twin.py`)
- MERRA-2 mapping → Climatologies: supplies source (evidence: `scripts/build_clim.py`)
