Skip to contents

Fetches WRF data from S3 once per variable per year and extracts all sites in a single vectorized call via cae_fetch_points(), then writes one CF-compliant NetCDF per site per year. For N sites, 8 variables, and Y years this makes 8*Y S3 requests regardless of N.

Usage

cae_build_met_drivers(
  sites,
  model = "CESM2",
  scenario = "ssp370",
  start_year,
  end_year,
  outdir,
  resolution = "d01",
  overwrite = FALSE,
  verbose = TRUE
)

Arguments

sites

data.frame with columns site_id, lon, lat (WGS84 decimal degrees). See Examples.

model

character; WRF GCM name. Default "CESM2". See cae_models(activity = "WRF") for options.

scenario

character; SSP experiment. Default "ssp370". See cae_scenarios() for options.

start_year

integer; first year to process

end_year

integer; last year to process

outdir

character; root output directory. Files are written to {outdir}/{site_id}/{model}.{scenario}.{year}.nc.

resolution

character; WRF grid label. Default "d01" (45 km).

overwrite

logical; overwrite existing files? Default FALSE.

verbose

logical; print progress messages? Default TRUE.

Value

A data.frame with columns site_id, year, file (invisibly).

Details

Output files follow the PEcAn CF Meteorology convention and can be registered in BETY or used directly by ecosystem models that read CF-standard met inputs.

See also

cae_fetch_points() for the underlying multi-site extraction, cae_write_cf_netcdf() for the stars-based single-grid approach

Examples

if (FALSE) { # \dontrun{
sites <- data.frame(
  site_id = c("fresno", "la", "sacramento"),
  lon = c(-119.77, -118.24, -121.49),
  lat = c(36.75, 34.05, 38.58)
)
result <- cae_build_met_drivers(
  sites, model = "CESM2", scenario = "ssp370",
  start_year = 2050, end_year = 2051,
  outdir = "met_output"
)
head(result)
} # }