Fetch data once and extract time series at many lon/lat locations.
The grid is read from S3 only once regardless of site count, making
this dramatically faster than looping over cae_fetch_point().
Usage
cae_fetch_points(
variable,
model,
scenario,
points,
timescale = "1hr",
resolution = "d01",
start_time = NULL,
end_time = NULL,
n_timesteps = NULL
)Arguments
- variable
character; variable name (e.g. "t2", "prec", "psfc"). Use cae_variables() to see what's available.
- model
character; GCM name (e.g. "CESM2", "MPI-ESM1-2-HR"). Use cae_models() to see options.
- scenario
character; SSP experiment (e.g. "ssp370", "ssp245", "historical"). Use cae_scenarios() to see options.
- points
data.frame with columns
lonandlatin WGS84 decimal degrees. An optionalsite_idcolumn provides labels; otherwise sites are numbered 1..N.- timescale
character; temporal resolution. One of "1hr", "day", "mon". Default "1hr".
- resolution
character; spatial grid. One of "d01" (45km), "d02" (9km), "d03" (3km). Default "d01".
- start_time
POSIXct or character; start of time window. If character, parsed as UTC. Default NULL reads from the beginning.
- end_time
POSIXct or character; end of time window. Default NULL reads to the end.
- n_timesteps
integer; number of timesteps to read. Alternative to end_time for quick reads. Default NULL.
Value
A data.frame with columns: site_id, time, value (in native units). One row per site per timestep.
Examples
if (FALSE) { # \dontrun{
# 5 sites across California
sites <- data.frame(
site_id = c("fresno", "la", "sacramento", "redding", "bakersfield"),
lon = c(-119.77, -118.24, -121.49, -122.39, -119.02),
lat = c(36.75, 34.05, 38.58, 40.59, 35.37)
)
ts <- cae_fetch_points("t2", model = "CESM2", scenario = "ssp370",
points = sites, n_timesteps = 24)
head(ts)
# works for thousands of sites -- grid is read once
big <- data.frame(lon = runif(10000, -124, -114),
lat = runif(10000, 32, 42))
ts_big <- cae_fetch_points("t2", model = "CESM2", scenario = "ssp370",
points = big, n_timesteps = 24)
} # }