Compare Modeled versus Observed Hydrographs using razviz

Introduction

The purpose of this vignette is to demonstrate how to use the razviz package to produce a pdf report of modeled versus observed hydrographs for a set of HEC-RAS hydraulic model scenarios.

Install

Begin by loading the needed packages.

library(tidyverse)
library(devtools)

Next, we’ll install the razviz package.

devtools::install_github(repo = "mpdougherty/razviz", build_vignettes = TRUE)

Finally, we’ll load the razviz package.

library(razviz)

Import Hydraulic Model Output

In this step we’ll import the RAS exports from several RAS model calibration runs.

Event 2008, Calibration #9

# Set event parameters
folder <- system.file("extdata/hydrographs/2008_calibration_9",
                      package = "razviz")
event <- "2008"
run_number <- 9
run_type <- "Calibration"
# Import event model results
cal_2008 <- razviz::import_ras_hydrographs(folder = folder,
                                           event = event,
                                           run_number = run_number,
                                           run_type = run_type)

Event 2013, Calibration #9

# Set event parameters
folder <- system.file("extdata/hydrographs/2013_calibration_9",
                      package = "razviz")
event <- "2013"
run_number <- 9
run_type <- "Calibration"
# Import event model results
cal_2013 <- razviz::import_ras_hydrographs(folder = folder,
                                           event = event,
                                           run_number = run_number,
                                           run_type = run_type)

Event 2014, Calibration #9

# Set event parameters
folder <- system.file("extdata/hydrographs/2014_calibration_9",
                      package = "razviz")
event <- "2014"
run_number <- 9
run_type <- "Calibration"
# Import event model results
cal_2014 <- razviz::import_ras_hydrographs(folder = folder,
                                           event = event,
                                           run_number = run_number,
                                           run_type = run_type)

Event 2017, Calibration #9

# Set event parameters
folder <- system.file("extdata/hydrographs/2017_calibration_9",
                      package = "razviz")
event <- "2017"
run_number <- 9
run_type <- "Calibration"
# Import event model results
cal_2017 <- razviz::import_ras_hydrographs(folder = folder,
                                           event = event,
                                           run_number = run_number,
                                           run_type = run_type)

Combine all model runs and events and recode

In this step we’ll get the model results ready for graphing.

# Combine hydrograph events 
hydrograph_list <- list(cal_2008, cal_2013, cal_2014, cal_2017)
cal_wide <- razviz::combine_hydrographs(hydrograph_list)

# Convert to long format suitable for plotting
cal <- razviz::lengthen_hydrographs(cal_wide)

# Rename factors for prettier plot labeling
cal$River <- forcats::fct_recode(cal$River, 
                                 "Mississippi" = "MISSISSIPPI")
cal$Reach <- forcats::fct_recode(cal$Reach, 
                                 "Big Muddy to Ohio"      = "BIG MUDDY_OHIO", 
                                 "Fox to Bear"            = "FOXTOBEAR",
                                 "Illinois to Mizzou"     = "ILLINOIS_MIZZOU",
                                 "Iowa to Des Moines"     = "IOWATODESM",
                                 "Kaskaskia to Big Muddy" = "KASKY_BIGMUDDY",
                                 "Meramec to Kaskaskia"   = "MERAMEC_KASKY",
                                 "Missouri to Meramec"    = "MISSOURI_MERAMEC",
                                 "North to Salt"          = "NORTHTOSALT",
                                 "Salt to Cuivre"         = "SALT_CUIVRE",
                                 "Wyaconda to Fabius"     = "WYACONDATOFABIUS")

Define hydrograph plot pages

In this step we’ll define the pages needed to draw the hydrograph plots.

cal_plots <- razviz::hydrograph_plot_pages(cal)

Output Folder

In this step we’ll define the output folder.

output_dir <- "C:/temp"
if (!dir.exists(output_dir)) {dir.create(output_dir)}

Hydrograph Report

In this step we’ll cal the hydrograph report.

#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> \newpage
#> png 
#>   2