View source: R/swWeatherGenerator.R
dbW_estimate_WGen_coefs | R Documentation |
SOILWAT2
weather generatorEstimated coefficients correspond to what is required by the two files
"mkv_covar.in"
and "mkv_prob.in"
for the first-order
Markov weather generator in SOILWAT2
> v4.2.5
.
dbW_estimate_WGen_coefs(
weatherData,
WET_limit_cm = 0,
propagate_NAs = FALSE,
valNA = NULL,
imputation_type = c("none", "mean", "locf"),
imputation_span = 5L
)
weatherData |
A list of elements of class |
WET_limit_cm |
A numeric value. A day with more precipitation than
this value is considered |
propagate_NAs |
A logical value. If |
valNA |
The (numerical) value of missing weather data.
If |
imputation_type |
A text string. Passed to |
imputation_span |
An integer value. Passed to |
A list with two named elements:
"mkv_doy"
: A data frame with 366 rows (day of year) and 5 columns:
"DOY"
: Rows represent day of year.
"p_W_W"
: Probability that DOY
is wet if the previous day
(doy - 1)
was wet.
"p_W_D"
: Probability that DOY
is wet if the previous day
(doy - 1)
was dry.
"PPT_avg"
: Average amount of precipitation [cm]
on DOY
if wet.
"PPT_sd"
: Standard deviation of amount of precipitation [cm]
on DOY
if wet.
"mkv_woy"
: A data frame with 53 rows SOILWAT2
weeks of year
(i.e., consecutive heptads
of days) and 11 columns
"WEEK"
: Rows represent week of year.
"wTmax_C"
: Average daily maximum temperature [C]
for week.
"wTmin_C"
: Average daily minimum temperature [C]
for week.
"var_MAX"
: Variance of daily maximum temperature for week.
"cov_MAXMIN"
: Covariance of daily maximum and minimum
temperatures for week.
"cov_MINMAX"
: Identical to "cov_MAXMIN"
.
"var_MIN"
: Variance of daily minimum temperature for week.
"CF_Tmax_wet"
: Difference between average daily maximum
temperature [C]
for wet days of week and "wTmax_C"
.
"CF_Tmax_dry"
: Difference between average daily maximum
temperature [C]
for dry days of week and "wTmax_C"
.
"CF_Tmin_wet"
: Same as "CF_Tmax_wet"
but for daily
minimum temperature.
"CF_Tmin_dry"
: Same as "CF_Tmax_dry"
but for daily
minimum temperature.
This code is a complete overhaul compared to the version
from rSFSTEP2
on 2019-Feb-10
.
This function will produce NA
s in the output if there
are insufficient weather observation in the input data weatherData
for a specific day or week of the year. Such NA
s will cause a
SOILWAT2
run to fail (potentially non-graciously and
with non-obvious error messages). To avoid that, this function offers
imputation approaches in order to fill in those failed coefficient
estimates; see rSW2utils::impute_df()
, but please note that
any such imputation likely introduces biases in the generated weather.
Most users will likely want to set propagate_NAs
to FALSE
.
Note: propagate_NAs
corresponds to !na.rm
from previous versions of this function with a different default value.
Consider an example: a the 30-year long input weatherData
is
complete except for missing values on Jan 1, 2018.
If propagate_NAs
is set to TRUE
, then the
coefficients for day 1 and week 1 of year will be NA
–
despite all the available data. In this case, the missing coefficients
for day 1 and week 1 of year will be imputed.
If propagate_NAs
is set to FALSE
, then the coefficients
for day 1 and week 1 of year will be calculated based on the non-missing
values for that day respectively that week of year. No imputation occurs.
print_mkv_files()
to print values to SOILWAT2
compatible files. swMarkov_Prob()
and
swMarkov_Conv()
to extract/replace values in a rSOILWAT2
input object of class swInputData
.
res1 <- dbW_estimate_WGen_coefs(rSOILWAT2::weatherData)
wdata <- data.frame(dbW_weatherData_to_dataframe(rSOILWAT2::weatherData))
res2 <- dbW_estimate_WGen_coefs(wdata)
sw_in <- rSOILWAT2::sw_exampleData
swMarkov_Prob(sw_in) <- res2[["mkv_doy"]]
swMarkov_Conv(sw_in) <- res2[["mkv_woy"]]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.