Here we attempt to provide useful code to generate figures from WRF outputs based on known galleries. For instance, NCL and WRF-Python provides extensive examples for plotting WRF outputs. Therefore, we aim to replicate some of these. Our approach to read wrfout files is based on eixport which relies r packages with GDAL bindings such as raster and stars. We do not try to provide a full gallery, instead, some basics and necessary plots to inspire other R used and receive more examples so share with the community.
library(eixport)
library(raster)
#> Loading required package: sp
library(stars)
#> Loading required package: abind
#> Loading required package: sf
#> Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.4.0; sf_use_s2() is TRUE
library(cptcity)
library(sf)
Based on NCL:
First lets get a summary of a WRF output file
wrfo <- "/home/sergio/R/x86_64-pc-linux-gnu-library/4.3/helios/extras/wrfout_d01_2020-01-01_01%3A00%3A00_sub.nc"
(dt <- wrf_meta(wrfo)$vars)
#> vars FieldType MemoryOrder description units stagger
#> 1 T2 104 XY TEMP at 2 M K
#> 2 XLAT 104 XY LATITUDE, SOUTH IS NEGATIVE degree_north
#> 3 XLONG 104 XY LONGITUDE, WEST IS NEGATIVE degree_east
#> coordinates
#> 1 XLONG XLAT XTIME
#> 2 XLONG XLAT
#> 3 XLONG XLAT
Now we can select some variables
(vars <- dt$vars)
#> [1] "T2" "XLAT" "XLONG"
Now get some statistics
wrf_summary(wrfo, vars = c("T2"))
#> | | | 0% | |======================================================================| 100%
#> Min. 1st Qu. Median Mean 3rd Qu. Max. sum
#> T2 263.2122 272.8542 274.6107 274.5677 276.3937 284.13 5581411