wrfrun is a comprehensive toolkit for managing and using WRF
Project description
🌀 wrfrun
A modern, unified framework for running and managing numerical models.
Designed for researchers who want to focus on science — not on the details of model execution.
📖 Introduction
wrfrun is a Python package that provides a general-purpose, reproducible, and extensible framework for running numerical models.
It automates the tedious parts of model execution — preparing input data, handling namelist configurations, organizing logs, and submitting jobs — so that you can spend your time on research, not on managing model runs.
⚡ Quick Installation
pip install wrfrun
📖 Documentation
Check https://wrfrun.syize.cn.
🌟 Core Features
🧩 Unified Interface Architecture
wrfrun enforces a unified interface specification for all numerical models. Specifically, each model interface must inherit from a provided base class, ensuring a consistent structure and behavior across different models.
This design makes model execution intuitive — any supported model can be launched simply by calling a Python function or class method, while wrfrun automatically handles all background tasks such as data preparation and configuration file management.
from wrfrun import WRFRun
from wrfrun.model.wrf import geogrid, metgrid, real, ungrib, wrf
# wrfrun will prepare input data, generate namelist file,
# save outputs and logs automatically.
with WRFRun("./config.toml", init_workspace=True) as wrf_run:
geogrid()
ungrib()
metgrid()
real()
wrf()
🪶 Record & Replay
Every simulation can be fully recorded and later reproduced from a single .replay file — ensuring total reproducibility.
from wrfrun import WRFRun
from wrfrun.model.wrf import geogrid, ungrib, metgrid, real, wrf
# 1. Record simulation with method `record_simulation`.
with WRFRun("./config.toml", init_workspace=True) as wrf_run:
wrf_run.record_simulation(output_path="./outputs/example.replay")
geogrid()
ungrib()
metgrid()
real()
wrf()
# 2. Replay the simulation in a different directory or on a different machine.
with WRFRun("./config.toml", init_workspace=True) as wrf_run:
wrf_run.replay_simulation("./example.replay")
⚙️ Simplified Configuration
Manage all simulation settings in TOML files: A main config file, and model config files.
For more information about the configuration file, check config.
# main config file: config.toml
work_dir = "./.wrfrun"
input_data_path = ""
output_path = "./outputs"
log_path = "./logs"
server_host = "localhost"
server_port = 54321
core_num = 36
[job_scheduler]
job_scheduler = "pbs"
queue_name = ""
node_num = 1
env_settings = {}
python_interpreter = "/usr/bin/python3" # or just "python3"
[model]
[model.wrf]
use = false
include = "./configs/wrf.toml"
wrfrun remains compatible with original namelist inputs, just set namelist file path in the model config.
# WRF model config file: wrf.toml
wps_path = '/path/to/your/WPS/folder'
wrf_path = '/path/to/your/WRF/folder'
wrfda_path = '' # WRFDA is optional.
geog_data_path = '/path/to/your/geog/data'
user_wps_namelist = '' # set your own namelist file here
user_real_namelist = '' # set your own namelist file here
user_wrf_namelist = '' # set your own namelist file here
user_wrfda_namelist = '' # set your own namelist file here
restart_mode = false
debug_level = 100
[time]
start_date = 2021-03-24T12:00:00Z # or [2021-03-24T12:00:00Z, 2021-03-24T12:00:00Z]
end_date = 2021-03-26T00:00:00Z # or [2021-03-26T00:00:00Z, 2021-03-24T12:00:00Z]
input_data_interval = 10800
output_data_interval = 180
time_step = 120
parent_time_step_ratio = [1, 3, 4]
restart_interval = -1
[domain]
domain_num = 3
parent_grid_ratio = [1, 3, 9]
i_parent_start = [1, 17, 72]
j_parent_start = [1, 17, 36]
e_we = [120, 250, 1198]
e_sn = [120, 220, 1297]
dx = 9000
dy = 9000
map_proj = 'lambert'
truelat1 = 34.0
truelat2 = 40.0
ref_lat = 37.0
ref_lon = 120.5
stand_lon = 120.5
[scheme]
long_wave_scheme = { name = "rrtm", option = {} }
short_wave_scheme = { name = "rrtmg", option = {} }
cumulus_scheme = { name = "kf", option = {} }
pbl_scheme = { name = "ysu", option = { ysu_topdown_pblmix = 1} }
land_surface_scheme = { name = "noah", option = {} }
surface_layer_scheme = { name = "mm5", option = {} }
💻 Job Scheduling Integration
Automatically submit jobs to supported schedulers:
- PBS
- Slurm
- LSF
wrfrun takes care of resource requests and queue management automatically.
from wrfrun import WRFRun
from wrfrun.model.wrf import geogrid, metgrid, real, ungrib, wrf
# just set submit_job=True
with WRFRun("./config.toml", init_workspace=True, submit_job=True) as wrf_run:
geogrid()
ungrib()
metgrid()
real()
wrf()
📡 Real-time Monitoring
wrfrun can parse model log files and start a lightweight socket server to report simulation progress.
from wrfrun import WRFRun
from wrfrun.model.wrf import geogrid, metgrid, real, ungrib, wrf
# just set start_server=True
with WRFRun("./config.toml", init_workspace=True, start_server=True) as wrf_run:
geogrid()
ungrib()
metgrid()
real()
wrf()
🌍 Current Capabilities
- Automated ERA5 data download (requires
cdsapiauthentication) - Real-time progress reporting via socket interface
- Partial WRF support:
- Full support for WPS
- Wrapped execution for
realandwrf
- Job submission on PBS, Slurm, and LSF
record/replayreproducibility for all compliant interfaces
🧭 TODO
- Full WRF model integration.
- Broaden model support.
- Enhanced progress visualization dashboard.
🤝 Contributing
This project is currently for personal and research use. If you have ideas or feature requests, feel free to open an issue.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wrfrun-0.3.0.tar.gz.
File metadata
- Download URL: wrfrun-0.3.0.tar.gz
- Upload date:
- Size: 104.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec28e90d219ca540a0ac95deb04424fd375eaab85f4a1130c609d8467f69c432
|
|
| MD5 |
25a5a7e4deb18e45a705e6e97428bccd
|
|
| BLAKE2b-256 |
1f80121d86a6c93904a31a39c0fb95fe9e895cbfacc3555b50fdbe865a17b928
|
Provenance
The following attestation bundles were made for wrfrun-0.3.0.tar.gz:
Publisher:
python-package.yaml on wrfrun/wrfrun
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wrfrun-0.3.0.tar.gz -
Subject digest:
ec28e90d219ca540a0ac95deb04424fd375eaab85f4a1130c609d8467f69c432 - Sigstore transparency entry: 910292421
- Sigstore integration time:
-
Permalink:
wrfrun/wrfrun@f1a149418f881831ed74b4e2927d3da07dbccff8 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/wrfrun
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-package.yaml@f1a149418f881831ed74b4e2927d3da07dbccff8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file wrfrun-0.3.0-py3-none-any.whl.
File metadata
- Download URL: wrfrun-0.3.0-py3-none-any.whl
- Upload date:
- Size: 114.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
238cd9ccf1cda3ad758fe374eabbf5538505c8751913f137601e9293de035e5a
|
|
| MD5 |
ba5816df56671cb510c3a1b82febd1cc
|
|
| BLAKE2b-256 |
403617e2b8aed3526a18d3066eacca2600e6bee7bfaf75fdb16a850413eae9ff
|
Provenance
The following attestation bundles were made for wrfrun-0.3.0-py3-none-any.whl:
Publisher:
python-package.yaml on wrfrun/wrfrun
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wrfrun-0.3.0-py3-none-any.whl -
Subject digest:
238cd9ccf1cda3ad758fe374eabbf5538505c8751913f137601e9293de035e5a - Sigstore transparency entry: 910292423
- Sigstore integration time:
-
Permalink:
wrfrun/wrfrun@f1a149418f881831ed74b4e2927d3da07dbccff8 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/wrfrun
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-package.yaml@f1a149418f881831ed74b4e2927d3da07dbccff8 -
Trigger Event:
release
-
Statement type: