gr_check_params: Check the correctness of parameters list for separating

View source: R/separate.R

gr_check_paramsR Documentation

Check the correctness of parameters list for separating

Description

Check the correctness of parameters list for separating

Usage

gr_check_params(params, df = NULL)

Arguments

params

list of separation parameters, as returned by gr_get_params() function

df

data.frame with four columns: date, runoff, temperature, precipitation, as required by gr_separate(). Required when params is a list of parameter lists. Defaults to NULL.

Value

stops the execution if anything is wrong and prints the exact reason of the error. Otherwise prints the message that everything is OK

Examples

library(grwat)

# example Spas-Zagorye data is included with grwat package
data(spas)

params = gr_get_params(reg = 'center')

gr_check_params(params)

# set the unknown parameter
params$new = -2

# use try if you do not want to stop at error
try(gr_check_params(params))

# remove wrong parameter
params$new = NULL

# remove right parameter
params$grad1 = NULL
try(gr_check_params(params))

# reset
params = gr_get_params(reg = 'center')

sep = gr_separate(spas, params, debug = TRUE)
parlist = attributes(sep)$params

parlist[['2002']]$grad1 = 4

# if the parlist is used for separation
# then data frame must be specified
try(gr_check_params(parlist))

gr_check_params(parlist, spas)

# grad parameter is not known
parlist[['2002']]$grad = 4
try(gr_check_params(parlist, spas))

# remove wrong parameter
parlist[['2002']]$grad = NULL

# remove year
parlist[['2002']] = NULL
try(gr_check_params(parlist, spas))

parlist[['2002']] = parlist[['2001']]
gr_check_params(parlist, spas)


tsamsonov/grwat documentation built on Feb. 10, 2024, 5:55 p.m.