wrftools
This package does 3 things
- help you to define domains
- extract data as points of spatial features and bricks
- returns st_bbox from wrf files
I’m not an expert in WRF but i need to use it. One of the very frustating and tricky part was to make a correct namelist.wps. Hours and hours trying to get the perfect domains. This functions solves this part while providing a dynamic maps for actually viewing where are your domains.
remotes::install_github("atmoschem/wrftools")
wrf_domains returns a list of:
- the map
- the sf object
The arguments of wrf_domains are the same arguments of namelist.wps. It include default values but you can change them accordingly.
library(wrftools)
a <- wrf_domains()
a[[1]] # leaflet
(inspired in NCL from DCA/IAG/USP)
Which returns data.frame ready for ggplot2. The class of Time is POSIXct
data(cetesb)
cetesb <- cetesb[!is.na(cetesb$Station), "Station"]
#use your wrfout
wrf <- "wrfoA.nc"
t2 = c("T2", "o3", "no", "no2", "PM10", "PM2_5_DRY")
df <- xtractor(atmos = wrf, vars = t2, points = cetesb,
stations = cetesb$Station)
and raster bricks
library(cptcity)
r <- xtractor(atmos = wrf, vars = t2, points = cetesb[1, ], return_list = T)
# A list with raster and data.frame
sp::spplot(r[[1]][[2]], "layer.60",
scales = list(draw = T), col.regions = cpt(1224))
If you see any errors and know how to improve the function, or add new functions write an issue and a pull request, please. I will be ver grateful, for sure, 100%.