Read and extract data from a list of wrf output files and a table of lat/lon points based on the distance of the points and the center of model grid points, points outside the domain (and points on domain boundary) are not extracted.
Usage
extract_serie(
filelist,
point,
variable = "o3",
field = "4d",
level = 1,
prefix = "serie",
new = "check",
return.nearest = FALSE,
fast = FALSE,
use_ij = FALSE,
latitude = "XLAT",
longitude = "XLONG",
use_TFLAG = FALSE,
use_datesec = FALSE,
id = "id",
remove_ch = FALSE,
verbose = TRUE
)
Arguments
- filelist
list of files to be read
- point
data.frame with lat/lon
- variable
variable name
- field
'4d' (default), '3d', '2d' or '2dz' see notes
- level
model level to be extracted
- prefix
to output file, default is serie
- new
TRUE, FALSE of 'check' see notes
- return.nearest
return the data.frame of nearest points instead of extract the serie
- fast
faster calculation of grid distances but less precise
- use_ij
logical, use i and j from input instead of calculate
- latitude
name of latitude coordinate variable in the netcdf
- longitude
name of longitude coordinate variable in the netcdf
- use_TFLAG
use the variable TFLAG (CMAQ / smoke) instead of Times (WRF)
- use_datesec
use the variable date and datesec (WACCM / CAM-Chem) instead of Times (WRF)
- id
name of the column with station names, if point is a SpatVector (points) from terra package
- remove_ch
remove special characters on row.names
- verbose
display additional information
Note
The field argument '4d' or '2dz' is used to read a 4d/3d variable droping the 3rd dimention (z).
new = TRUE create a new file, new = FALSE append the data in a old file, and new = 'check' check if the file exist and append if the file exist and create if the file doesnt exist
FOR CAMx time-series, use the options: use_TFLAG=T, latitude='latitude', longitude='longitude', new=T
FOR WACCM time-series, use the options: use_datesec=T, latitude='lat', longitude='lon', new=T
The site-list of two global data-sets (METAR and AERONET) are provided on examples and site-list for stations on Brazil (INMET and Air Quality stations).
Examples
cat('Example 1: METAR site list\n')
#> Example 1: METAR site list
sites <- readRDS(paste0(system.file("extdata",package="eva3dm"),"/sites_METAR.Rds"))
cat('Example 2: Integrated Surface Dataset (ISD) site list\n')
#> Example 2: Integrated Surface Dataset (ISD) site list
sites <- readRDS(paste0(system.file("extdata",package="eva3dm"),"/sites_ISD.Rds"))
cat('Example 4: AERONET site list\n')
#> Example 4: AERONET site list
sites <- readRDS(paste0(system.file("extdata",package="eva3dm"),"/sites_AERONET.Rds"))
cat('Example 5: list of INMET stations in Brazil\n')
#> Example 5: list of INMET stations in Brazil
sites <- readRDS(paste0(system.file("extdata",package="eva3dm"),"/sites_INMET.Rds"))
cat('Example 6: list of Air Quality stations in Brazil\n')
#> Example 6: list of Air Quality stations in Brazil
sites <- readRDS(paste0(system.file("extdata",package="eva3dm"),"/sites_AQ_BR.Rds"))
cat('Example 7: list of AQM stations in US\n')
#> Example 7: list of AQM stations in US
sites <- readRDS(paste0(system.file("extdata",package="eva3dm"),"/sites_AQS.Rds"))
cat('Example 8: list of CASTNET stations in rural areas of US/Canada\n')
#> Example 8: list of CASTNET stations in rural areas of US/Canada
sites <- readRDS(paste0(system.file("extdata",package="eva3dm"),"/sites_CASTNET.Rds"))
cat('Example 9: list of Longterm European Program (EMEP) stations\n')
#> Example 9: list of Longterm European Program (EMEP) stations
sites <- readRDS(paste0(system.file("extdata",package="eva3dm"),"/sites_EMEP.Rds"))
cat('Example 10: list of FLUXNET stations\n')
#> Example 10: list of FLUXNET stations
sites <- readRDS(paste0(system.file("extdata",package="eva3dm"),"/sites_FLUXNET.Rds"))
cat('Example 11: list of IMPROVE stations\n')
#> Example 11: list of IMPROVE stations
sites <- readRDS(paste0(system.file("extdata",package="eva3dm"),"/sites_IMPROVE.Rds"))
cat('Example 12: list of TOAR stations\n')
#> Example 12: list of TOAR stations
sites <- readRDS(paste0(system.file("extdata",package="eva3dm"),"/sites_TOAR.Rds"))
files <- dir(path = system.file("extdata",package="eva3dm"),
pattern = 'wrf.day',
full.names = TRUE)
dir.create(file.path(tempdir(),"SERIE"))
folder <- file.path(tempdir(),"SERIE")
# extract data for 3 locations
extract_serie(filelist = files, point = sites[1:3,],prefix = paste0(folder,'/serie'))
#> extracting series of o3 field 4d for 3 points
#> dim of lat/lon: 125 125
#> used dim of lat/lon: 125 125
#> inside lat / lon range: 0 points
#> [1] "no data to extract!"