knitr::opts_chunk$set( collapse = TRUE, comment = "#>")
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.
Begin by loading the needed packages.
library(forcats) 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)
In this step we'll import the RAS exports from several RAS model calibration runs.
razviz::import_ras_hydrographs
function to import the example RAS model results included in the package for each modeled event. # 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)
# 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)
# 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)
# 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)
In this step we'll get the model results ready for graphing.
razviz::combine_hydrographs
function. razviz::lengthen_hydrographs
function. # 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")
In this step we'll define the pages needed to draw the hydrograph plots.
cal_plots <- razviz::hydrograph_plot_pages(cal)
In this step we'll define the output folder.
output_dir <- "C:/temp" if (!dir.exists(output_dir)) {dir.create(output_dir)}
In this step we'll cal the hydrograph report.
razviz::hydrograph_report(cal, cal_plots, output_dir)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.