CreateGRiwrm | R Documentation |
Generation of a network description containing all hydraulic nodes and the description of their connections
CreateGRiwrm(
db,
cols = list(id = "id", down = "down", length = "length", area = "area", model =
"model", donor = "donor"),
keep_all = FALSE
)
db |
data.frame description of the network (See details) |
cols |
list or vector columns of |
keep_all |
logical indicating if all columns of |
db
is a data.frame which at least contains in its columns:
a node identifier (column id
),
the identifier and the hydraulic distance to the downstream node
(character columns down
and numeric columns length
in km). The
last downstream node should have fields down
and length
set to NA
,
the total area of the basin at the node location (numeric column area
in km2).
Direct injection node can have a null area defined by NA
the model to use (character column model
), see section below for details
An optional column donor
can be used to manually define which sub-basin
will give its parameters to an ungauged node (See Ungauged
model below).
The "model" column should be filled by one of the following:
One of the hydrological models available in the airGR package defined by its
RunModel
function (i.e.: RunModel_GR4J
, RunModel_GR5HCemaneige
...)
RunModel_Reservoir
for simulating a reservoir (See: RunModel_Reservoir)
Ungauged
for an ungauged node. The sub-basin inherits hydrological model and
parameters from a "donor" sub-basin. If not defined by the user in the column donor
,
the donor is automatically set to the first gauged node at downstream.
This set of sub-basins with the same donor downstream then forms an ungauged
node cluster that will be calibrated at once.
NA
for injecting (or abstracting) a flow time series at the location of the node
(direct flow injection)
Diversion
for abstracting a flow time series from an existing node transfer it
to another node. As a Diversion
is attached to an existing node, this node is
then described with 2 lines: one for the hydrological model and another one for the
diversion
data.frame of class GRiwrm
describing the airGR semi-distributed
model network, with each line corresponding to a location on the river
network and with the following columns:
id
(character): node identifier
down
(character): identifier of the node downstream of the current
node (NA for the most downstream node)
length
(numeric): hydraulic distance to the downstream node in km
(NA for the most downstream node)
area
(numeric): total area of the basin starting from the current
node location in km2
model
(character): hydrological model to use (NA for using observed
flow instead of a runoff model output)
donor
(character): node used as model and calibration parameter "donor" for
ungauged nodes. For other types of nodes, if the donor is different than the
id, it indicates that the node is embedded in an ungauged node cluster.
library(airGRiwrm)
#########################################
# Network of 2 nodes distant of 150 km: #
#########################################
# - an upstream reservoir modeled as a direct flow injection (no model)
# - a gauging station downstream a catchment of 360 km² modeled with GR4J
db <- data.frame(id = c("Reservoir", "GaugingDown"),
length = c(150, NA),
down = c("GaugingDown", NA),
area = c(NA, 360),
model = c(NA, "RunModel_GR4J"),
stringsAsFactors = FALSE)
griwrm_basic <- CreateGRiwrm(db)
griwrm_basic
# Network diagram with direct flow node in red, intermediate sub-basin in green
## Not run:
plot(griwrm_basic)
## End(Not run)
###################################################
# GR4J semi-distributed model of the Severn River #
###################################################
data(Severn)
nodes <- Severn$BasinsInfo
nodes$model <- "RunModel_GR4J"
str(nodes)
# Mismatch column names are renamed to stick with GRiwrm requirements
rename_columns <- list(id = "gauge_id",
down = "downstream_id",
length = "distance_downstream")
griwrm_severn <- CreateGRiwrm(nodes, rename_columns)
griwrm_severn
# Network diagram with upstream basin nodes in blue, intermediate sub-basin in green
## Not run:
plot(griwrm_severn)
## End(Not run)
####################################################################
# Severn network with an ungauged station at nodes 54029 and 54001 #
####################################################################
nodes_ungauged <- nodes
nodes_ungauged$model[nodes_ungauged$gauge_id %in% c("54029", "54001")] <- "Ungauged"
# By default the first gauged node at downstream is used for parameter calibration (54032)
# Add a `donor`column for defining manually an upstream or sibling donor
nodes_ungauged$donor <- as.character(NA)
nodes_ungauged$donor[nodes_ungauged$id == "54001"] <- "54095"
griwrm_ungauged <- CreateGRiwrm(nodes_ungauged, rename_columns)
griwrm_ungauged
# Network diagram with gauged nodes of vivid color, and ungauged nodes of dull color
## Not run:
plot(griwrm_ungauged)
## End(Not run)
###########################################################
# Severn network with a Diversion on the node "54029" #
# to a reservoir which transfer flows to the node "54001" #
# and a withdrawal on the reservoir #
###########################################################
nodes_div <- nodes[, c("gauge_id", "downstream_id", "distance_downstream", "model", "area")]
nodes_div <- rbind(
nodes_div,
data.frame(gauge_id = c("54029" , "Reservoir" , "Irrigation_Pump"),
downstream_id = c("Reservoir", "54001" , "Reservoir" ),
distance_downstream = c(10 , 5 , 0 ),
model = c("Diversion", "RunModel_Reservoir", NA ),
area = c(NA , NA , NA))
)
griwrm_div <- CreateGRiwrm(nodes_div, rename_columns)
# Network diagram figures Diversion node by a red frame and a red arrow
## Not run:
plot(griwrm_div, orientation = "TB")
## End(Not run)
# It's also possible to custom the diagram's look with mermaid directives
# (See details in plot.GRiwrm help topic)
## Not run:
plot(
griwrm_div,
header = "%%{init: {'flowchart': {'nodeSpacing': 30, 'rankSpacing': 30, 'curve': 'linear'}}}%%"
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.