Examples

The examples make more sense if you have familiarized yourself with the nchannel, npartfull, and nmetalpipe tables. There are instructions to view the tables, as a .pdf, in the View-PDF-table-vignette.

library(install.load)
load_package("iemiscdata", "data.table", "rivr") # load needed packages using the load_package function from the install.load package (it is assumed that you have already installed these packages)


# Use grep to find the row number matching the given description
# Use nchannel$"Type of Channel and Description" to select the column to search through
# Use nchannel[nlocation, 4] to select the row number from nlocation and column 4
# Similar steps are performed for each of these examples


# Example 1
# What is the maximum Manning's n value for a channel that has the following classification: "Natural streams - minor streams (top width at floodstage < 100 ft), Mountain streams, no vegetation in channel, banks usually steep, trees and brush along banks submerged at high stages and bottom: gravels, cobbles, and few boulders"?
# The 1st heading is "Manning's n for Channels"
# The 2nd heading is "Natural streams - minor streams (top width at floodstage < 100 ft)"
# The 3rd heading is "Mountain streams, no vegetation in channel, banks usually steep, trees and brush along banks submerged at high stages"
# The 4th heading is "bottom: gravels, cobbles, and few boulders"

data(nchannel)

nlocation <- grep("bottom: gravels, cobbles, and few boulders", nchannel$"Type of Channel and Description")

nlocation
## [1] 12
n <- nchannel[nlocation, 4] # 4 for column 4 - Maximum n

n
## [1] 0.05
# Example 2
# What is the minimum Manning's n value for a channel that has the following classification: "Closed Conduits Flowing Partly Full, Wood and Stave"?
# The 1st heading is "Manning's n for Closed Conduits Flowing Partly Full"
# The 2nd heading is "Wood"
# The 3rd heading is "Stave"

data(npartfull)

nlocation <- grep("Stave", npartfull$"Type of Conduit and Description")

nlocation
## [1] 26
n <- npartfull[nlocation, 2] # 2 for column 2 - Minimum n

n
## [1] 0.01
# Example 3
# What is the Manning's n value for a channel that has the following classification: "Corrugated Metal Pipe, Corrugations 6x2 inches and 60" diameter"?
# The 1st heading is "Manning's n for Corrugated Metal Pipe"
# The 2nd heading is "Corrugations 6x2 inches"
# The 3rd heading is "60" diameter"

data(nmetalpipe)

nnear <- grep("Corrugations 6x2 inches", nmetalpipe$"Type of Pipe, Diameter and Corrugation Dimension")
# nnear is the row number matching the description
nnear
## integer(0)
nlocation <- nlocation[which(grep("60\"\" diameter", nmetalpipe$"Type of Pipe, Diameter and Corrugation Dimension") > nnear)]
# which provides all locations matching the description > nnear gives the row number(s) greater than nnear since the requested diameter is in the section located after nnear
nlocation
## integer(0)
n <- nmetalpipe[nlocation, 2] # 2 for column 2 - n

n
## numeric(0)
# Example 4
# Example to compute the "gradually-varied flow profile of a prismatic channel" with these channel conditions used to find Manning's n (normal): "Natural streams - minor streams (top width at floodstage < 100 ft), Excavated or Dredged Channels, Earth, straight, and uniform, & clean, recently completed".
# Quote source: rivr's compute_profile

# The 1st heading is "Manning's n for Channels"
# The 2nd heading is "Natural streams - minor streams (top width at floodstage < 100 ft)"
# The 3rd heading is "Excavated or Dredged Channels"
# The 4th heading is "Earth, straight, and uniform"
# The 5th heading is "clean, recently completed"


# Using the data for the M1 profile example in rivr's compute_profile, except for the value of n to find the channel condition

nlocation <- grep("clean, recently completed", nchannel$"Type of Channel and Description")
# use grep to find the n's row number

nlocation
## [1] 36
n <- nchannel[nlocation, 3] # 3 for column 3 - Normal n

n
## [1] 0.018
compute_profile(0.001, n, 250, 2.7, 1.486, 32.2, 100, 0, stepdist = 50, totaldist = 3000)
## M1 profile specified. Computing upstream profile
## Simulation type:
##   Gradually-varied flow
## 
## Call:
##   compute_profile(So = 0.001, n = n, Q = 250, y0 = 2.7, Cm = 1.486, 
##     g = 32.2, B = 100, SS = 0, stepdist = 50, totaldist = 3000)
## 
## 
## Channel geometry:
##   So:0.001
##   n :0.018
##   B :100
##   SS:0
## 
## Model specification:
##   delta.x       :50
##   channel.length:3000
##   normal.depth  :0.982
##   critical.depth:0.579
## 
## Data:
##   x : num [1:61] 0 -50 -100 -150 -200 -250 -300 -350 -400 -450 ...
##   z : num [1:61] 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 ...
##   y : num [1:61] 2.7 2.65 2.6 2.55 2.51 ...
##   v : num [1:61] 0.926 0.943 0.961 0.979 0.998 ...
##   A : num [1:61] 270 265 260 255 251 ...
##   Sf: num [1:61] 3.59e-05 3.81e-05 4.05e-05 4.30e-05 4.58e-05 ...
##   E : num [1:61] 2.71 2.72 2.72 2.72 2.72 ...
##   Fr: num [1:61] 0.0993 0.102 0.1049 0.1079 0.1111 ...