# zawadzkim/pyswap architecture

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

- Interactive diagram: https://gitdiagram.com/zawadzkim/pyswap
- Repository: https://github.com/zawadzkim/pyswap

## Overview

pySWAP lets users define SWAP hydrology simulations in Python, run the external SWAP model, and inspect or visualize results. The central workflow is model configuration → input-file generation → SWAP execution → result parsing; configuration spans simulation settings, soil, crops, weather, boundaries, drainage, irrigation, and transport. Shared validation and SWAP-format serialization support these inputs. The README documents analysis and visualization, while the source index confirms result and plotting modules; their detailed wiring was not sampled, so those links are left unverified.

Main entry points: [`pyswap/model/model.py`](https://github.com/zawadzkim/pyswap/blob/main/pyswap/model/model.py) (Model orchestration), [`pyswap/components/meteorology.py`](https://github.com/zawadzkim/pyswap/blob/main/pyswap/components/meteorology.py) (Meteorology), [`pyswap/components/crop.py`](https://github.com/zawadzkim/pyswap/blob/main/pyswap/components/crop.py) (Crop settings), [`pyswap/model/result.py`](https://github.com/zawadzkim/pyswap/blob/main/pyswap/model/result.py) (Simulation results)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_configuration["Simulation configuration"]
  node_settings["Simulation settings<br/>[simsettings.py]"]
  node_soil["Soil water<br/>[soilwater.py]"]
  node_crop["Crop settings<br/>[crop.py]"]
  node_weather["Meteorology<br/>[meteorology.py]"]
  node_water_controls["Water controls<br/>[irrigation.py]"]
  node_drainage["Drainage<br/>[drainage.py]"]
  node_boundary["Boundary conditions<br/>[boundary.py]"]
  node_transport["Solute transport<br/>[transport.py]"]
end

subgraph group_input_runtime["Input and execution"]
  node_model["Model orchestration<br/>[model.py]"]
  node_validation["Validation and fields<br/>[basemodel.py]"]
  node_serialization["SWAP serialization<br/>[fields.py]"]
  node_executable["Executable management<br/>[executables.py]"]
end

subgraph group_results["Results and analysis"]
  node_result["Simulation results<br/>[result.py]"]
  node_plotting["Result plotting"]
end

subgraph group_integrations["Data and integrations"]
  node_data_io["Data file I/O"]
  node_crop_database[("Crop database<br/>[cropdb.py]")]
  node_gis["Location data<br/>[location.py]"]
  node_cli["Command line<br/>[cli.py]"]
end

node_user(("Python user"))
node_swap["SWAP model"]

node_user -->|"configures"| node_model
node_model -->|"uses settings"| node_settings
node_model -->|"uses soil"| node_soil
node_model -->|"uses crop"| node_crop
node_model -->|"uses weather"| node_weather
node_model -->|"uses irrigation"| node_water_controls
node_model -->|"uses drainage"| node_drainage
node_model -->|"uses boundaries"| node_boundary
node_model -->|"uses transport"| node_transport
node_model -->|"validates inputs"| node_validation
node_model -->|"writes inputs"| node_serialization
node_model -->|"gets executable"| node_executable
node_model -->|"runs"| node_swap
node_model -->|"reads outputs"| node_result
node_result -.->|"visualizes"| node_plotting
node_weather -->|"loads CSV"| node_data_io
node_crop -->|"loads crop data"| node_crop_database
node_weather -.->|"uses location"| node_gis
node_cli -->|"manages executable"| node_executable

click node_model "https://github.com/zawadzkim/pyswap/blob/main/pyswap/model/model.py"
click node_settings "https://github.com/zawadzkim/pyswap/blob/main/pyswap/components/simsettings.py"
click node_soil "https://github.com/zawadzkim/pyswap/blob/main/pyswap/components/soilwater.py"
click node_crop "https://github.com/zawadzkim/pyswap/blob/main/pyswap/components/crop.py"
click node_weather "https://github.com/zawadzkim/pyswap/blob/main/pyswap/components/meteorology.py"
click node_water_controls "https://github.com/zawadzkim/pyswap/blob/main/pyswap/components/irrigation.py"
click node_drainage "https://github.com/zawadzkim/pyswap/blob/main/pyswap/components/drainage.py"
click node_boundary "https://github.com/zawadzkim/pyswap/blob/main/pyswap/components/boundary.py"
click node_transport "https://github.com/zawadzkim/pyswap/blob/main/pyswap/components/transport.py"
click node_validation "https://github.com/zawadzkim/pyswap/blob/main/pyswap/core/basemodel.py"
click node_serialization "https://github.com/zawadzkim/pyswap/blob/main/pyswap/core/fields.py"
click node_executable "https://github.com/zawadzkim/pyswap/blob/main/pyswap/utils/executables.py"
click node_result "https://github.com/zawadzkim/pyswap/blob/main/pyswap/model/result.py"
click node_plotting "https://github.com/zawadzkim/pyswap/tree/main/pyswap/core/plot"
click node_data_io "https://github.com/zawadzkim/pyswap/tree/main/pyswap/core/io"
click node_crop_database "https://github.com/zawadzkim/pyswap/blob/main/pyswap/db/cropdb.py"
click node_gis "https://github.com/zawadzkim/pyswap/blob/main/pyswap/gis/location.py"
click node_cli "https://github.com/zawadzkim/pyswap/blob/main/pyswap/core/cli/cli.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_settings,node_soil,node_crop,node_weather,node_water_controls,node_drainage,node_boundary,node_transport,node_user toneBlue
class node_model,node_validation,node_serialization,node_executable toneAmber
class node_result,node_plotting toneMint
class node_data_io,node_crop_database,node_gis,node_cli toneRose
class node_swap toneIndigo
```

## Components

### Simulation configuration

- [Simulation settings](https://github.com/zawadzkim/pyswap/blob/main/pyswap/components/simsettings.py): `pyswap/components/simsettings.py`
- [Soil water](https://github.com/zawadzkim/pyswap/blob/main/pyswap/components/soilwater.py): `pyswap/components/soilwater.py`
- [Crop settings](https://github.com/zawadzkim/pyswap/blob/main/pyswap/components/crop.py): `pyswap/components/crop.py`
- [Meteorology](https://github.com/zawadzkim/pyswap/blob/main/pyswap/components/meteorology.py): `pyswap/components/meteorology.py`
- [Water controls](https://github.com/zawadzkim/pyswap/blob/main/pyswap/components/irrigation.py): `pyswap/components/irrigation.py`
- [Drainage](https://github.com/zawadzkim/pyswap/blob/main/pyswap/components/drainage.py): `pyswap/components/drainage.py`
- [Boundary conditions](https://github.com/zawadzkim/pyswap/blob/main/pyswap/components/boundary.py): `pyswap/components/boundary.py`
- [Solute transport](https://github.com/zawadzkim/pyswap/blob/main/pyswap/components/transport.py): `pyswap/components/transport.py`

### Input and execution

- [Model orchestration](https://github.com/zawadzkim/pyswap/blob/main/pyswap/model/model.py): `pyswap/model/model.py`
- [Validation and fields](https://github.com/zawadzkim/pyswap/blob/main/pyswap/core/basemodel.py): `pyswap/core/basemodel.py`
- [SWAP serialization](https://github.com/zawadzkim/pyswap/blob/main/pyswap/core/fields.py): `pyswap/core/fields.py`
- [Executable management](https://github.com/zawadzkim/pyswap/blob/main/pyswap/utils/executables.py): `pyswap/utils/executables.py`

### Results and analysis

- [Simulation results](https://github.com/zawadzkim/pyswap/blob/main/pyswap/model/result.py): `pyswap/model/result.py`
- [Result plotting](https://github.com/zawadzkim/pyswap/tree/main/pyswap/core/plot): `pyswap/core/plot`

### Data and integrations

- [Data file I/O](https://github.com/zawadzkim/pyswap/tree/main/pyswap/core/io): `pyswap/core/io`
- [Crop database](https://github.com/zawadzkim/pyswap/blob/main/pyswap/db/cropdb.py): `pyswap/db/cropdb.py`
- [Location data](https://github.com/zawadzkim/pyswap/blob/main/pyswap/gis/location.py): `pyswap/gis/location.py`
- [Command line](https://github.com/zawadzkim/pyswap/blob/main/pyswap/core/cli/cli.py): `pyswap/core/cli/cli.py`

### Other components

- **Python user**
- **SWAP model**

## Connections

- Python user → Model orchestration: configures
- Model orchestration → Simulation settings: uses settings (evidence: `pyswap/model/model.py`)
- Model orchestration → Soil water: uses soil (evidence: `pyswap/model/model.py`)
- Model orchestration → Crop settings: uses crop (evidence: `pyswap/model/model.py`)
- Model orchestration → Meteorology: uses weather (evidence: `pyswap/model/model.py`)
- Model orchestration → Water controls: uses irrigation (evidence: `pyswap/model/model.py`)
- Model orchestration → Drainage: uses drainage (evidence: `pyswap/model/model.py`)
- Model orchestration → Boundary conditions: uses boundaries (evidence: `pyswap/model/model.py`)
- Model orchestration → Solute transport: uses transport (evidence: `pyswap/model/model.py`)
- Model orchestration → Validation and fields: validates inputs (evidence: `pyswap/model/model.py`)
- Model orchestration → SWAP serialization: writes inputs (evidence: `pyswap/model/model.py`)
- Model orchestration → Executable management: gets executable (evidence: `pyswap/model/model.py`)
- Model orchestration → SWAP model: runs
- Model orchestration → Simulation results: reads outputs (evidence: `pyswap/model/model.py`)
- Simulation results → Result plotting: visualizes
- Meteorology → Data file I/O: loads CSV (evidence: `pyswap/components/meteorology.py`)
- Crop settings → Crop database: loads crop data (evidence: `pyswap/components/crop.py`)
- Meteorology → Location data: uses location
- Command line → Executable management: manages executable (evidence: `pyswap/core/cli/cli.py`)
