simpleHydrograph: Creates hydrograph from MESH output

Description Usage Arguments Value Note Author(s) See Also Examples

View source: R/simpleHydrograph.R

Description

Creates a ggplot hydrograph from MESH output. This function only uses values from a single MESH data frame (as read in using readOutputTimeseriesCSV), so does not work with outside sources, such as WSC files. Because this function returns a ggplot object, you can change its format in any way you like. The plots produced may be faceted using the commands facet_wrap or facet_grid.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
simpleHydrograph(
  MESHvals,
  stationNames = "",
  byStation = TRUE,
  byYear = FALSE,
  meas = TRUE,
  sim = TRUE,
  calStart = "",
  calEnd = "",
  alpha = 1
)

Arguments

MESHvals

Required. A data frame of output from a MESH run, as produced by read_MESH_OutputTimeseries_csv.

stationNames

Optional. A vector of strings holding station names. If specified, the station names will be used in the plots. Otherwise the MESH station numbers will be used.

byStation

Optional. If TRUE (the default) then the plots will be coloured according to the station names. You may want to set this to FALSE if you are facetting by station name.

byYear

Optional. If TRUE then the plots will be able to be facetted by year. Note that this means that the dates are all plotted using the year 2000, so you will see strange results if you set this to TRUE and don't facet by year. Default is FALSE

meas

Optional. Should the measured values be plotted? Default is TRUE. If FALSE, they will be omitted.

sim

Optional. Should the simulated values be plotted? Default is TRUE. If FALSE, they will be omitted.

calStart

Optional. The start date of the calibration period. Must be a string in the format yyyy-mm-dd. If specified, values on and after this date will be designated as the Calibration period. The remaining values will be designated as the Validation period.

calEnd

Optional. The start date of the calibration period. Must be a string in the format yyyy-mm-dd. If specified, values on and after this date will be designated as the Calibration period. The remaining values will be designated as the Validation period.

alpha

Optional. Sets the alpha channel (transparency) of the plots. The default value is 1, i.e. opaque. Setting alpha to less than 1 makes the plots transparent, which can be useful to see overlapping hydrographs.

Value

If successful, returns a ggplot2 object. If unsuccessful, returns FALSE. The object can be facetted by the name of the station (the variable is called station). If the option byYear = TRUE, then the object can be facetted by the variable YEAR.

Note

Specifying the calibration start and/or end dates will allow the resulting plot to be facetted by the variable period.

Author(s)

Kevin Shook

See Also

read_MESH_OutputTimeseries_csv hydroStats

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# plot hydrograph of all data on single graph
p1 <- simpleHydrograph(MESH_streamflows)
p1
# add station names, and replot
stations <- c("Station1", "Station2")
p2 <- simpleHydrograph(MESH_streamflows, stationNames = stations)
p2
# remove colouring by station, and facet, changing the axis label format
p3 <- simpleHydrograph(MESH_streamflows, stationNames = stations, byStation = FALSE)
# load in all of ggplot2 to modify plots
library(ggplot2)
p3 <- p3 + facet_wrap(~station, nrow = 2) + scale_x_date(date_labels = "%Y")
p3
# plot by year, then facet
p4 <- simpleHydrograph(MESH_streamflows, stationNames = stations, byYear = TRUE)
p4 <- p4 + facet_wrap(~YEAR, scales = "free_y")
p4
# remove colouring for stations, and facet by station and year
p5 <- simpleHydrograph(MESH_streamflows, stationNames = stations, byStation = FALSE, byYear = TRUE)
p5 <- p5 + facet_grid(YEAR~station, scales = "free_y")
# change colours
plotcols <- c("red", "blue")
p5 <- p5 + scale_colour_manual(values = plotcols)
p5

CentreForHydrology/MESHr documentation built on Jan. 11, 2021, 8:34 p.m.