The wrfpp post-processor¶
What is wrfpp?¶
wrfpp is a Python package that facilitates the analysis of WRF and WRF-Chem outputs.
Installation¶
Tip
We strongly encourage you to work within some kind of isolated Python environment (eg. venv or conda)
You can install wrfpp and its dependencies with pip. It is recommended to install a tagged version (eg. "v1.0"):
To install the latest development version, simply omit the tag:
You can choose not to install optional dependencies by omitting [all] in the commands above. Some features of wrfpp will not work in this case.
Versioning¶
For reproducible computing, please only use commits tagged with a version number (eg. "v2.3"). These uniquely and unequivocally define specific versions of wrfpp. This is not true for any version number that has the ".dev0" suffix (eg "v2.3.dev0").
Basic usage¶
First open a WRF or WRF-Chem output file with wrfpp:
wrfpp adds wrf-specific functionalities to xarray datasets via a tool called an accessor.
For all practical purposes, the ds object should behave exactly like any other xarray Dataset:
Derived variables¶
One of the main features of wrfpp is so-called derived variables. These are DataArray objects, just as any other dataset variable, but they are calculated on the fly by wrfpp instead of being read directly from the underlying WRF file.
For instance, WRF output files typically contain a variable T that is the potential air temperature relative to some reference value:
avg = ds.T.values.mean()
units = ds.T.units
print(f"Average relative potential temperature = {avg} {units}")
wrfpp's magic, we can use air_temperature as if it were a native variable:
avg = ds.air_temperature.values.mean()
units = ds.air_temperature.units
print(f"Average air temperature = {avg} {units}")
Thanks to this transparent syntax, one can write code that works agnostically on both native and derived WRF variables:
variables = ("T", "air_temperature", "QVAPOR", "relative_humidity")
for v in variables:
data_array = getattr(ds, v)
avg = data_array.values.mean()
units = data_array.units
print(f"{v}: {avg} {units}")
T: 43.795982360839844 K
air_temperature: 234.40847778320312 K
QVAPOR: 0.00043676584027707577 kg kg-1
relative_humidity: 31.046321868896484 %
The following table lists all derived variables available at this time:
| Name | Description |
|---|---|
grid_cell_area |
Grid cell area, accounting for projection deformation |
altitude_asl |
Grid cell altitude above sea level |
altitude_agl |
Grid cell altitude above ground level |
altitude_asl_c |
Grid cell centrepoint altitude above sea level |
altitude_agl_c |
Grid cell centrepoint altitude above ground level |
box_dz |
Grid box vertical extent |
potential_temperature |
Potential temperature |
atm_pressure |
Atmospheric pressure |
air_temperature |
Air temperature |
density_of_dry_air |
Dry air density |
relative_humidity |
Relative humidity |
accumulated_precipitation |
Accumulated total precipitation |
liquid_water_path |
Liquid water path |
cloud_liquid_water_path |
Cloud liquid water path |
ice_water_path |
Solid water path |
cloud_ice_water_path |
Cloud solid water path |
aer_number_conc_nonact |
Non-activated aerosol number concentration |
aer_number_conc_act |
Activated aerosol number concentration |
aer_number_conc_total |
Total aerosol number concentration |
fraction_activated_aerosol |
Number-based fraction of aerosols that are activated |