Drive a fine-resolution WRF domain from a coarse WRF run — in pure Python, with no nest-ratio constraint.
wrf2wps converts a coarse WRF-ARW history (wrfout) into WPS intermediate
files,
which metgrid.exe → real.exe then turn into wrfinput / wrfbdy / wrffdda
for a finer domain.
It is an alternative to ndown that carries no nest-ratio constraint.
Because metgrid is a free horizontal interpolation (not a parent/child nest),
the inner grid dimensions are unconstrained — you are not bound by WRF's
(e-1) % parent_grid_ratio == 0 rule, and you can keep an existing,
byte-frozen inner domain while changing the coarse driver.
coarse WRF run ──► wrfout (eta levels, Mercator)
│ wrf2wps
▼
WPS intermediate (regular lat/lon, pressure levels)
│ metgrid.exe ─ real.exe
▼
wrfinput / wrfbdy / wrffdda ──► fine WRF run
- No nest-ratio constraint. Nesting and
ndownboth enforce integer grid ratios and aligned dimensions. Going through WPS intermediate sidesteps that entirely — useful when your fine domain dimensions can't be divided by a clean ratio, or when the coarse:fine jump is too large for a single nest. - No Fortran, no wrf-python. Diagnostics (temperature from θ, geopotential
height, sea-level pressure, wind destagger, η→pressure interpolation) are
computed with
numpy. Runs on minimal/old cluster Pythons where buildingwrf-pythonis painful. - Battle-tested format core. The intermediate read/write is vendored from
the author's
cmip6-to-wrfintermand has driven multi-decade regional downscaling runs.
pip install wrf2wps # or: pip install -e . (from a clone)Requires Python ≥ 3.8 and numpy, scipy, pandas, xarray, netCDF4.
cp examples/config.example.ini config.ini
# edit wrf_root / out_root / the time window
wrf2wps config.iniThen point metgrid at the output by setting, in namelist.wps:
&metgrid
fg_name = 'WRFITM',
/
prepare your inner-domain geo_em, run metgrid.exe and real.exe as usual.
A single [w2w] section (see examples/config.example.ini):
| key | meaning | default |
|---|---|---|
wrf_root / wrf_prefix |
coarse-run output dir + file prefix | ./sample / wrfout_d01_ |
out_root / out_prefix |
intermediate output dir + prefix | ./output / WRFITM |
map_source |
free-text MAP_SOURCE tag |
WRF-ARW |
deltlat / deltlon |
target lat/lon mesh spacing (deg) | 0.2 |
plevs |
positive target pressure levels (hPa), strictly surface→top | ERA5 26-level |
vtable |
variable table: wrf-arw, wrf-arw-2soil, or a .csv path |
wrf-arw |
geo_file |
optional geo_em.d01.nc to backfill XLAT/XLONG/HGT |
(none) |
etl_strt_ts / etl_end_ts / frq |
window (YYYYMMDDHHMM) + cadence (h) | — |
deltlat, deltlon, and frq must be positive, and etl_end_ts must not
precede etl_strt_ts. If a multi-time wrfout is opened and its Times
metadata does not contain the requested timestamp, wrf2wps stops instead of
silently using the first record.
Two are bundled:
wrf-arw(default) — native Noah 4-layer soil (ST000010/ST010040/ST040100/ST100200+ moisture).wrf-arw-2soil— a 10–200 cm aggregate (ST000010/ST010200), for a metgrid/real path tuned to a 2-layer soil source (e.g. some CMIP6 setups).
Each row maps an internally computed field (calc) to a WPS field name
(aim_v) with its units, type (3d/2d), and desc. Copy one and edit to
emit a different field set.
- Mercator / rectilinear sources only. The horizontal regrid is a fast
separable 1-D interpolation, which is exact when
wrfoutrows are constant latitude and columns constant longitude. Lambert / polar-stereographic sources need a true 2-D regrid and wind rotation to earth-relative — not yet implemented; a warning is logged if a non-rectilinear grid is detected. (Tracked for v0.2.) - Noah 4-layer soil is assumed (
TSLB/SMOISwith 4 levels). - Winds are written
IS_WIND_EARTH_REL = 1, valid for Mercator (unrotated); revisit when 2-D projections land.
pip install -e ".[test]"
pytestTests cover the format round-trip and an end-to-end conversion on a synthetic in-memory wrfout (no large data files committed).
Author: Zhenning Li (zhenningli91@gmail.com). The WPS-intermediate format
core derives from cmip6-to-wrfinterm.
If wrf2wps supports your research, please cite it (see CITATION.cff).
Licensed under the MIT License.