View source: R/swWeatherGenerator.R
dbW_substituteWeather | R Documentation |
Replace missing values with values from another weather data set
dbW_substituteWeather(
weatherData,
subData,
vars_substitute = NULL,
by = NULL,
by_weatherData = by,
by_subData = by,
return_weatherDF = FALSE
)
weatherData |
A list of elements of class |
subData |
A weather data object. |
vars_substitute |
Names of variables for which missing values
in |
by |
Names of variables used to match days (rows) between
|
by_weatherData |
See |
by_subData |
See |
return_weatherDF |
A logical value. See section "Value". |
An updated copy of weatherData
where missing values have been
replaced by corresponding values from subData
.
If return_weatherDF
is TRUE
, then the result is converted to a
data frame where columns represent weather variables.
If return_weatherDF
is FALSE
, then the result is
a list of elements of class swWeatherData
.
dbW_generateWeather()
, dbW_imputeWeather()
# Load example data
path_demo <- system.file("extdata", "example1", package = "rSOILWAT2")
dif <- c(rep(TRUE, 3L), rep(FALSE, 11L))
dif[13L] <- TRUE # ACTUAL_VP
dif[14L] <- TRUE # SHORT_WR, desc_rsds = 2
wdata <- getWeatherData_folders(
LookupWeatherFolder = file.path(path_demo, "Input"),
weatherDirName = "data_weather_daymet",
filebasename = "weath",
startYear = 1980,
endYear = 1981,
dailyInputFlags = dif,
method = "C"
)
x0 <- x <- dbW_weatherData_to_dataframe(wdata)
dif0 <- calc_dailyInputFlags(x0)
# Set June-August of 1980 as missing
ids_1980 <- x[, "Year"] == 1980
ids_missing <- ids_1980 & x[, "DOY"] >= 153 & x[, "DOY"] <= 244
x[ids_missing, -(1:2)] <- NA
# Substitute missing values
all.equal(
dbW_substituteWeather(x, x0[ids_1980, ], return_weatherDF = TRUE),
x0
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.