R6 Class for Dynamic TOPMODEL

Methods


dynatop$new()

Creates a dynatop class object from the a list based model description as generated by dynatopGIS.

Usage

dynatop$new(geo, param, delta = 1e-13)

Arguments

geo

a data.frame describing the HRUs geography or path to a gpkg file that can read to create one

param

a data.frame describing the parameters for each HRU class or path to a jsonfile that can read to create one

delta

error allowed in checking redistribution sums

Details

This function makes some basic consistency checks on a list representing a dynamic TOPMODEL model. The checks performed and basic 'sanity' checks. They do not check for the logic of the parameter values nor the consistency of states and parameters. Sums of the redistribution matrices are checked to be in the range 1 +/- delta.

Returns

invisible(self) suitable for chaining


dynatop$initialise()

Initialises a dynatop object in the simplest way possible.

Usage

dynatop$initialise(initial_states = NULL)

Arguments

initial_states

a date frame of states

Details

is initial_states are present these are used for the HRUs given. Otherwise a steady state initialisation is performed.

Returns

invisible(self) suitable for chaining


dynatop$sim()

Simulate the dynatop model

Usage

dynatop$sim(
  obs_data,
  output_defn,
  keep_states = NULL,
  output_dir = NULL,
  sub_step = NULL,
  n_thread = 1
)

Arguments

obs_data

data.frame of observations

output_defn

definition of the outputs from the model

keep_states

a vector of POSIXct objects (e.g. from xts) giving the time stamp at which the states should be kept

output_dir

the directory to write output to

sub_step

simulation timestep in seconds, default value of NULL results in data time step

n_thread

number of parallel threads to use in execution

Details

Saving the states at every timestep and keeping the mass balance can generate very large data sets!!

Returns

invisible(self) for chaining


dynatop$get_states()

Get the current states

Usage

dynatop$get_states()

Returns

data.frame of current statea


dynatop$clone()

The objects of this class are cloneable with this method.

Usage

dynatop$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

## the vignettes contains further details of the method calls.
mdlFile <- system.file("extdata","mdl","test_mdl.gpkg",package="dynatop",mustWork=TRUE)
paramFile <- system.file("extdata","mdl","test_mdl_param.json",package="dynatop",mustWork=TRUE)
obsFile <- system.file("extdata","mdl","SwindaleObs.csv",package="dynatop",mustWork=TRUE)
## create and initialise model
dyn <- dynatop$new(mdlFile,paramFile)
dyn$initialise() ## this initialisation isn't good - see the vignette
## define an output definition
defn <- data.frame(name="outlet",hru=1,scale=1,flux="q_sf")
## read in observed
obs <- read_obs(obsFile)
## simulate
# \donttest{
out <- dyn$sim(obs,defn)
#> Number of threads 1
# }