View source: R/sw_dbW_WeatherDatabase.R
getWeatherData_folders | R Documentation |
SOILWAT2 does not handle missing weather data. If you have missing
data, then you have to impute yourself or use the built-in Markov weather
generator (see examples for sw_exec
).
getWeatherData_folders(
LookupWeatherFolder,
weatherDirName = NULL,
filebasename = "weath",
startYear = NULL,
endYear = NULL,
dailyInputFlags = c(rep(TRUE, 3L), rep(FALSE, 11L)),
method = c("R", "C")
)
LookupWeatherFolder |
A character string. The path to the parent folder
of |
weatherDirName |
String. Name of the folder with the daily weather data files. |
filebasename |
String. File prefix for weather data. Usually weath. |
startYear |
Numeric. Extracted weather data will start with this year. |
endYear |
Numeric. Extracted weather data will end with this year. |
dailyInputFlags |
A logical vector of length |
method |
A character string. |
A list of elements of class swWeatherData
.
dbW_weather_to_SOILWATfiles()
offers the inverse operation, i.e.,
writing weather data to disk files.
dbW_getWeatherData
path_demo <- system.file("extdata", "example1", package = "rSOILWAT2")
## ------ Simulation with data prepared beforehand and separate weather data
## Read inputs from files on disk (via SOILWAT2)
sw_in3 <- sw_inputDataFromFiles(dir = path_demo, files.in = "files.in")
## Read forcing weather data from files on disk (via SOILWAT2)
sw_weath3c <- getWeatherData_folders(
LookupWeatherFolder = file.path(path_demo, "Input"),
weatherDirName = "data_weather",
filebasename = "weath",
startYear = 1979,
endYear = 2010,
method = "C"
)
## Read forcing weather data from files on disk (via R)
sw_weath3r <- getWeatherData_folders(
LookupWeatherFolder = file.path(path_demo, "Input"),
weatherDirName = "data_weather",
filebasename = "weath",
startYear = 1979,
endYear = 2010,
method = "R"
)
## Weather data (for the non-calculated variables) should be identical
identical(
sw_weath3c[[1L]]@data[, 1:4],
rSOILWAT2::get_WeatherHistory(sw_in3)[[1L]]@data[, 1:4]
)
identical(
sw_weath3r[[1L]]@data[, 1:4],
rSOILWAT2::get_WeatherHistory(sw_in3)[[1L]]@data[, 1:4]
)
## List of the slots of the input objects of class 'swWeatherData'
utils::str(sw_weath3c, max.level = 1)
utils::str(sw_weath3r, max.level = 1)
## Execute the simulation run
sw_out3c <- sw_exec(inputData = sw_in3, weatherList = sw_weath3c)
sw_out3r <- sw_exec(inputData = sw_in3, weatherList = sw_weath3r)
all.equal(sw_out3c, sw_out3r)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.