View source: R/read_forecast.R
read_forecast | R Documentation |
read_forecast
generates file names, based on the arguments given,
reads data from them, and optionally performs a transformation on those data.
By default the function returns nothing due to the large volumes of data that
may be read from the files. Optionally, the read data can be returned to the
calling environment, and / or written to files.
read_forecast(
dttm,
fcst_model,
parameter,
lead_time = seq(0, 48, 3),
members = NULL,
members_out = members,
lags = NULL,
vertical_coordinate = c("pressure", "model", "height", NA),
file_path = getwd(),
file_format = NULL,
file_template = "vfld",
file_format_opts = list(),
transformation = c("none", "interpolate", "regrid", "xsection", "subgrid"),
transformation_opts = NULL,
param_defs = get("harp_params"),
output_file_opts = sqlite_opts(),
return_data = FALSE,
merge_lags = TRUE,
show_progress = TRUE,
stop_on_fail = FALSE,
is_forecast = TRUE,
start_date = NULL,
end_date = NULL,
by = "6h"
)
When return_date = TRUE
, a harp_fcst object.
if (requireNamespace("harpData", quietly = TRUE)) {
# Read all parameters from vfld files for a deterministic model
read_forecast(
start_date = 2019021700,
end_date = 2019021718,
fcst_model = "AROME_Arctic_prod",
file_path = system.file("vfld", package = "harpData"),
return_data = TRUE
)
# Ensure height corrections to 2m temperature are done and keep the
# uncorrected data
read_forecast(
start_date = 2019021700,
end_date = 2019021718,
fcst_model = "AROME_Arctic_prod",
file_path = system.file("vfld", package = "harpData"),
transformation_opts = interpolate_opts(
correct_t2m = TRUE,
keep_model_t2m = TRUE
),
return_data = TRUE
)
# Read 10m wind speed from the MEPS_prod ensemble
read_forecast(
start_date = 2019021700,
end_date = 2019021718,
fcst_model = "MEPS_prod",
parameter = "S10m",
lead_time = seq(0, 12, 3),
members = seq(0, 10),
file_path = system.file("vfld", package = "harpData"),
file_template = "vfld_eps",
return_data = TRUE
)
# Read vertical profiles of temperature and dewpoint temperature
read_forecast(
start_date = 2019021700,
end_date = 2019021718,
fcst_model = "MEPS_prod",
parameter = c("T", "Td"),
lead_time = seq(0, 12, 3),
members = seq(0, 10),
file_path = system.file("vfld", package = "harpData"),
file_template = "vfld_eps",
return_data = TRUE
)
# Read ensemble data from MEPS_prod and lagged ensemble data from
# CMEPS_prod
read_forecast(
start_date = 2019021700,
end_date = 2019021718,
fcst_model = c("MEPS_prod", "CMEPS_prod"),
parameter = c("T", "Td"),
lead_time = seq(0, 12, 3),
members = list(
MEPS_prod = seq(0, 10),
CMEPS_prod = c(0, 1, 3, 4, 5, 6)
),
lags = list(CMEPS_prod = c(0, 0, 2, 2, 1, 1)),
file_path = system.file("vfld", package = "harpData"),
file_template = "vfld_eps",
return_data = TRUE
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.