
Convert downloaded ERA5 files to a daily meteorology data frame
Source:R/convert_era5_netcdf.R
convert_era5_netcdf.RdConvenience wrapper that runs extract_era5_hourly_met() over the ERA5
files in path (netCDF, or GRIB as written by download_era5_cds()) and
aggregates the model-ready hourly frame to daily with met_to_daily():
precipitation and snowfall are summed, everything else is averaged, and -
unless minmax = FALSE - daily minimum and maximum air and dewpoint
temperature are added.
File discovery (by name pattern), the per-file reader backend, spatial
sampling (method), de-accumulation of the flux variables, unit
conversion and the UTC -> tz shift are all handled by
extract_era5_hourly_met(); see there for the details and for the
arguments passed through ....
Usage
convert_era5_netcdf(
path,
format = c("AEME", "LER", "raw"),
tz = "UTC",
minmax = TRUE,
min_frac = 0.5,
site = NULL,
outfile = NULL,
...
)Arguments
- path
directory holding the ERA5 files (netCDF or GRIB).
- format
"AEME"(default,MET_*names, aDatecolumn),"LER"(LakeEnsemblR names) or"raw"(ERA5 short names);"LER"and"raw"return adatetimecolumn.- tz
output / aggregation time zone: passed to
extract_era5_hourly_met()and used to assign calendar days. Default"UTC".- minmax
add daily min / max columns for air and dewpoint temperature (
MET_airmin/MET_airmax/MET_dewmin/MET_dewmaxin AEME naming). DefaultTRUE.- min_frac
drop days with fewer than this fraction of the expected hourly records, passed to
met_to_daily(). Default0.5; set0to keep every day.- site
optional site tag; when given (and
patternis left at its default) only files whose name contains the tag are used - a shortcut forpattern = paste0("*{variable}*", site, "*").- outfile
optional path; if given the daily frame is written there with
utils::write.csv()(row.names = FALSE, dates as"%Y-%m-%d").- ...
further arguments for
extract_era5_hourly_met():lon,lat,geom,years,months,variables,method,precip_units,pressure_units,pattern,max_dist_km,area_crs,fill_gaps,verbose.
Value
a daily data frame: the time column first, then one column per
variable in the chosen format, plus the temperature min / max columns
when minmax = TRUE. The lon / lat / tz / method attributes
from extract_era5_hourly_met() are carried through.
See also
extract_era5_hourly_met() for the hourly frame and the full
argument list, met_to_daily() for the aggregation, standardise_met()
which recognises the "raw" ERA5 short names directly.