% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/extract_serie.R
\name{extract_serie}
\alias{extract_serie}
\title{Extract time series of wrf file list of lat/lon}
\usage{
extract_serie(
  filelist,
  point,
  variable = "o3",
  field = "4d",
  level = 1,
  prefix = "serie",
  new = "check",
  return.nearest = FALSE,
  fast = FALSE,
  use_ij = FALSE,
  model = "WRF",
  id = "id",
  remove_ch = FALSE,
  verbose = TRUE
)
}
\arguments{
\item{filelist}{list of files to be read}

\item{point}{data.frame with lat/lon}

\item{variable}{variable name}

\item{field}{dimension of the variable, '4d' (default), '2dz', '2dz', '2d' or 'xyzt', 'xyz', 'xyz', and 'xy' see notes
\tabular{lll}{
  \strong{Field}\tab \strong{Dimensions}\tab \strong{Example} \cr
  3dt  \tab xyzt \tab WRF dimensions for 3D array with multiple times\cr
  2dt  \tab xyt  \tab WRF dimensions for 2D array with multiple times \cr
  2dz  \tab xyz  \tab WRF dimensions for 3D array with single time\cr
  2d   \tab xy   \tab WRF dimensions for 2D array with single time\cr
}}

\item{level}{model level (index) to be extracted}

\item{prefix}{to output file, default is serie}

\item{new}{TRUE, FALSE of 'check' see notes}

\item{return.nearest}{return the data.frame of nearest points instead of extract the serie}

\item{fast}{faster calculation of grid distances but less precise}

\item{use_ij}{logical, use i and j from input instead of calculate}

\item{model}{"WRF" (default), "CAMx" (CAMx, CMAQ and smoke files), and "WACCM" (WACCM and CAM-Chem)}

\item{id}{name of the column with station names, if point is a SpatVector (points) from terra package}

\item{remove_ch}{remove special characters on row.names}

\item{verbose}{display additional information}
}
\value{
No return value
}
\description{
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.
}
\note{
The field argument '4d' or '2dz' is used to read a 4d/3d variable droping the 3rd dimension (z), this should be based how ncdf4 R-package reads the model output.

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

The option field '3d' was removed, a new option should be used instead (2dt or 2dz).

The site-list of two global data-sets (METAR/ISD and AERONET) are provided on examples and site-list for stations on Brazil (INMET and Air Quality stations). Site-lists for other regions (US, Canada, Europa, etc) are provided as additional examples.
}
\examples{
cat('Example 1: METAR site list\n')
sites <- readRDS(paste0(system.file("extdata",package="eva3dm"),"/sites_METAR.Rds"))

cat('Example 2: Integrated Surface Dataset (ISD) site list\n')
# row.names are a combination of State Code,	County Code	and Site Number (2,3 and 4 digits)
sites <- readRDS(paste0(system.file("extdata",package="eva3dm"),"/sites_ISD.Rds"))

cat('Example 4: AERONET site list\n')
sites <- readRDS(paste0(system.file("extdata",package="eva3dm"),"/sites_AERONET.Rds"))

cat('Example 5: list of INMET stations in Brazil\n')
sites <- readRDS(paste0(system.file("extdata",package="eva3dm"),"/sites_INMET.Rds"))

cat('Example 6: list of Air Quality stations in Brazil\n')
sites <- readRDS(paste0(system.file("extdata",package="eva3dm"),"/sites_AQ_BR.Rds"))

cat('Example 7: list of AQM stations in US\n')
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')
sites <- readRDS(paste0(system.file("extdata",package="eva3dm"),"/sites_CASTNET.Rds"))

cat('Example 9: list of Longterm European Program (EMEP) stations\n')
sites <- readRDS(paste0(system.file("extdata",package="eva3dm"),"/sites_EMEP.Rds"))

cat('Example 10: list of FLUXNET stations\n')
sites <- readRDS(paste0(system.file("extdata",package="eva3dm"),"/sites_FLUXNET.Rds"))

cat('Example 11: list of IMPROVE stations\n')
sites <- readRDS(paste0(system.file("extdata",package="eva3dm"),"/sites_IMPROVE.Rds"))

cat('Example 12: list of TOAR stations\n')
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'))

}
