# androhuman/swg_nationalscenario architecture

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

- Interactive diagram: https://gitdiagram.com/androhuman/swg_nationalscenario
- Repository: https://github.com/androhuman/swg_nationalscenario

## Overview

This R project reproduces a national scenario analysis and its figures. The documented user workflow is to provide national scenario data and reference datasets, then run `prog/main.R`; results are written under `output/figures/`. The program modules cover loading, preprocessing, mappings, unit corrections, energy-data treatment, sensitivity analysis, and plotting. The README documents these responsibilities and the entry point, but no source excerpts were provided, so internal call relationships are not verified; dashed links mark those inferred workflow connections.

Main entry points: [`prog/main.R`](https://github.com/androhuman/swg_nationalscenario/blob/main/prog/main.R) (Main workflow), [`prog/load_data.R`](https://github.com/androhuman/swg_nationalscenario/blob/main/prog/load_data.R) (Data loading), [`data/scen_data`](https://github.com/androhuman/swg_nationalscenario/tree/main/data/scen_data) (Scenario inputs), [`data/20240815_IAMC-SWG-National-Scenario_Variable-List_Final_D4V7_Shared.xlsx`](https://github.com/androhuman/swg_nationalscenario/blob/main/data/20240815_IAMC-SWG-National-Scenario_Variable-List_Final_D4V7_Shared.xlsx) (Variable list)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_execution["Execution and configuration"]
  node_main["Main workflow<br/>[main.R]"]
  node_config["Paths and settings<br/>[config.R]"]
end

subgraph group_analysis["Data preparation and analysis"]
  node_loader["Data loading<br/>[load_data.R]"]
  node_processing["Preprocessing<br/>[process_data.R]"]
  node_regions["Region mapping<br/>[region_mapping.R]"]
  node_units["Unit corrections"]
  node_energy["Primary energy treatment"]
  node_sensitivity["LOO regression<br/>[regression_loo.R]"]
  node_helpers["Analysis helpers<br/>[functions.R]"]
end

subgraph group_visualization["Figures and reporting"]
  node_supplementary["Supplementary figures<br/>[sup_plots.R]"]
  node_figures[("Generated figures")]
end

subgraph group_inputs["Analysis inputs"]
  node_scenario_data[("Scenario inputs")]
  node_variable_list["Variable list"]
  node_classification["Classification data"]
  node_effort_sharing["Effort-sharing data<br/>[effort_sharing.csv]"]
end

node_analyst(("Analyst"))

node_analyst -->|"runs"| node_main
node_main -->|"generates"| node_figures
node_scenario_data -.->|"provides scenarios"| node_loader
node_classification -.->|"provides reference data"| node_loader
node_effort_sharing -.->|"provides allocations"| node_loader
node_variable_list -.->|"provides variable definitions"| node_loader
node_main -.->|"runs workflow"| node_loader
node_main -.->|"runs workflow"| node_processing
node_main -.->|"generates figures"| node_supplementary

click node_main "https://github.com/androhuman/swg_nationalscenario/blob/main/prog/main.R"
click node_config "https://github.com/androhuman/swg_nationalscenario/blob/main/prog/config.R"
click node_loader "https://github.com/androhuman/swg_nationalscenario/blob/main/prog/load_data.R"
click node_processing "https://github.com/androhuman/swg_nationalscenario/blob/main/prog/process_data.R"
click node_regions "https://github.com/androhuman/swg_nationalscenario/blob/main/prog/region_mapping.R"
click node_units "https://github.com/androhuman/swg_nationalscenario/blob/main/prog/unit_correction_table.R"
click node_energy "https://github.com/androhuman/swg_nationalscenario/blob/main/prog/fill_unreported_pe.R"
click node_sensitivity "https://github.com/androhuman/swg_nationalscenario/blob/main/prog/regression_loo.R"
click node_helpers "https://github.com/androhuman/swg_nationalscenario/blob/main/prog/functions.R"
click node_supplementary "https://github.com/androhuman/swg_nationalscenario/blob/main/prog/sup_plots.R"
click node_scenario_data "https://github.com/androhuman/swg_nationalscenario/tree/main/data/scen_data"
click node_variable_list "https://github.com/androhuman/swg_nationalscenario/blob/main/data/20240815_IAMC-SWG-National-Scenario_Variable-List_Final_D4V7_Shared.xlsx"
click node_classification "https://github.com/androhuman/swg_nationalscenario/blob/main/data/ref_data/CLASS_2025_10_07.xlsx"
click node_effort_sharing "https://github.com/androhuman/swg_nationalscenario/blob/main/data/ref_data/effort_sharing.csv"
click node_figures "https://github.com/androhuman/swg_nationalscenario/tree/main/output"

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_main,node_config toneBlue
class node_loader,node_processing,node_regions,node_units,node_energy,node_sensitivity,node_helpers toneAmber
class node_supplementary,node_figures toneMint
class node_scenario_data,node_variable_list,node_classification,node_effort_sharing toneRose
class node_analyst toneIndigo
```

## Components

### Execution and configuration

- [Main workflow](https://github.com/androhuman/swg_nationalscenario/blob/main/prog/main.R): `prog/main.R`
- [Paths and settings](https://github.com/androhuman/swg_nationalscenario/blob/main/prog/config.R): `prog/config.R`

### Data preparation and analysis

- [Data loading](https://github.com/androhuman/swg_nationalscenario/blob/main/prog/load_data.R): `prog/load_data.R`
- [Preprocessing](https://github.com/androhuman/swg_nationalscenario/blob/main/prog/process_data.R): `prog/process_data.R`
- [Region mapping](https://github.com/androhuman/swg_nationalscenario/blob/main/prog/region_mapping.R): `prog/region_mapping.R`
- [Unit corrections](https://github.com/androhuman/swg_nationalscenario/blob/main/prog/unit_correction_table.R): `prog/unit_correction_table.R`
- [Primary energy treatment](https://github.com/androhuman/swg_nationalscenario/blob/main/prog/fill_unreported_pe.R): `prog/fill_unreported_pe.R`
- [LOO regression](https://github.com/androhuman/swg_nationalscenario/blob/main/prog/regression_loo.R): `prog/regression_loo.R`
- [Analysis helpers](https://github.com/androhuman/swg_nationalscenario/blob/main/prog/functions.R): `prog/functions.R`

### Figures and reporting

- [Supplementary figures](https://github.com/androhuman/swg_nationalscenario/blob/main/prog/sup_plots.R): `prog/sup_plots.R`
- [Generated figures](https://github.com/androhuman/swg_nationalscenario/tree/main/output): `output`

### Analysis inputs

- [Scenario inputs](https://github.com/androhuman/swg_nationalscenario/tree/main/data/scen_data): `data/scen_data`
- [Variable list](https://github.com/androhuman/swg_nationalscenario/blob/main/data/20240815_IAMC-SWG-National-Scenario_Variable-List_Final_D4V7_Shared.xlsx): `data/20240815_IAMC-SWG-National-Scenario_Variable-List_Final_D4V7_Shared.xlsx`
- [Classification data](https://github.com/androhuman/swg_nationalscenario/blob/main/data/ref_data/CLASS_2025_10_07.xlsx): `data/ref_data/CLASS_2025_10_07.xlsx`
- [Effort-sharing data](https://github.com/androhuman/swg_nationalscenario/blob/main/data/ref_data/effort_sharing.csv): `data/ref_data/effort_sharing.csv`

### Other components

- **Analyst**

## Connections

- Analyst → Main workflow: runs (evidence: `README.md`)
- Main workflow → Generated figures: generates (evidence: `README.md`)
- Scenario inputs → Data loading: provides scenarios
- Classification data → Data loading: provides reference data
- Effort-sharing data → Data loading: provides allocations
- Variable list → Data loading: provides variable definitions
- Main workflow → Data loading: runs workflow
- Main workflow → Preprocessing: runs workflow
- Main workflow → Supplementary figures: generates figures
