View source: R/swWeatherGenerator.R
compare_weather | R Documentation |
Compare two weather datasets: produces comparison plots for means, quantiles, and Markov weather generator input parameters for all time steps
compare_weather(
ref_weather,
weather,
N,
WET_limit_cm = 0,
path = ".",
tag = format(Sys.time(), "%Y%m%d-%H%M")
)
ref_weather |
A |
weather |
A |
N |
An integer number representing the number of runs or sites contained
in |
WET_limit_cm |
A numeric value. A day with more precipitation than
this value is considered |
path |
A character string. The directory path in which output figures will be saved. |
tag |
A character string to uniquely identify a set of output figures. |
This function is called for its side effects of producing figures that are saved as png files on the disk.
The number of days represented by ref_weather
and by
weather
does not need to be the same.
See also the Weather generator integration tests (in file "tests/testthat/test_WeatherGenerator_functionality.R).
path <- tempdir()
## Example with default rSOILWAT2 weather data
w0 <- dbW_weatherData_to_dataframe(rSOILWAT2::weatherData)
w1 <- w0
w1[, "Tmax_C"] <- w1[, "Tmax_C"] + 2
w1[, "Tmin_C"] <- w1[, "Tmin_C"] - 2
compare_weather(
ref_weather = w0,
weather = w1,
N = 1,
path = path,
tag = "Example1-Silly"
)
## Example with STEPWAT2 output data averaged across iterations (`-o` option)
fname_main <- "file_STEPWAT2_main.csv"
fname_dev <- "file_STEPWAT2_dev.csv"
if (all(file.exists(fname_main, fname_dev))) {
cols_STEPWAT2 <- c(
"Year", "Day", "PRECIP_ppt_Mean", "TEMP_max_C_Mean", "TEMP_min_C_Mean"
)
cols_rSOILWAT2 <- c("Year", "Day", "PPT_cm", "Tmax_C", "Tmin_C")
w0 <- utils::read.csv(fname_main)[, cols_STEPWAT2]
colnames(w0) <- cols_rSOILWAT2
w1 <- utils::read.csv(fname_dev)[, cols_STEPWAT2]
colnames(w1) <- cols_rSOILWAT2
# Note: Since values are averages across many iterations, most days
# have average precipitation values > 0; thus, we need to adjust
# `WET_limit_cm` accordingly (here, with a guess)
compare_weather(
ref_weather = w0,
weather = w1,
N = 1,
WET_limit_cm = 0.1,
path = path,
tag = "Example2-STEPWAT2"
)
}
## Cleanup
unlink(list.files(path), force = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.