compute.Q.stat.annual: Compute annual (calendar and water year) statistics.

Description Usage Arguments Value Examples

View source: R/compute.Q.stat.annual.R

Description

Computes many annual (calendar and water year) statistics and (optionally) saves the results in *.csv and *.pdf files.

Usage

1
2
3
4
5
6
compute.Q.stat.annual(Station.Code = "XXXXX", Station.Area = NA, flow,
  start.year = 9999, end.year = 0, write.cy.stat.csv = TRUE,
  write.wy.stat.csv = TRUE, write.stat.trans.csv = TRUE,
  write.flow.summary.csv = TRUE, write.lowflow.csv = TRUE,
  plot.stat.trend = TRUE, plot.cumdepart = TRUE, report.dir = ".",
  na.rm = list(na.rm.global = FALSE), csv.nddigits = 3, debug = FALSE)

Arguments

Station.Code

A character string. Used to name any *.csv or *.pdf files created so be careful that the Station.Code will be acceptable in a file name.

Station.Area

Area of the water basin (square km), used in computing some statistics

flow

Dataframe with two variables (1) Date with the date as a R date class variable and (2) Q a numeric variable with the flow for that day.

Missing values for Q can be explicitly represented using NA with the associated date, or implicitly represented by excluding the date from the data.frame.

The date range of flow can be wider than the start.year and end.year. This is useful for statistics on the water year (starting 1 October of the previous year) when you may wish to include flow data for the latter part of the year. Similarly, it may be useful for statistics that use a 3, 7, or 30 day rolling average as this will be missing for the first few days of each year.

A water year runs from 1 October of the previous year to 30 Sept of the current year

All other variables in the data frame will be ignored. Data does NOT have to be sorted by Date order.

start.year, end.year

Starting and ending year for statistics in YYYY format, e.g. start.year=2013.

write.cy.stat.csv

Should a file be created with the calendar year computed percentiles? The file name will be file.path(report.dir,paste(Station.Code,'-annual-cy-summary-stat.csv')).

write.wy.stat.csv

Should a file be created with the water year computed percentiles? The file name will be file.path(report.dir,paste(Station.Code,'-annual-wy-summary-stat.csv')).

write.stat.trans.csv

Should a file be created with the transposed of the annual statistics (both calendar and water year)? The file name will be file.path(report.dir,paste(Station.Code,'-annual-summary-stat-trans.csv')).

write.flow.summary.csv

Should a file be created with a flow summary over the years between the start.year and end.year (inclusive). This summary includes number of days, number of missing values, mean, median, minimum, maximum, and standard deviation of flow$Q. The file name will be file.path(report.dir, paste(Station.Code,"-period-record-summary.csv", sep="")).

write.lowflow.csv

Should a file be created with the minimum value of flow$Q and date the minimum occured. The file name will be file.path(report.dir,paste(Station.Code,"-lowflow-summary.csv",sep=""))

plot.stat.trend

Should a file be created with plots of the statistics over the years between start.year and end.year. The file name will be file.path(report.dir, paste(Station.Code,"-annual-trend.pdf",sep=""))

plot.cumdepart

Should a file be created with plots of the yearly and cumulative departures from the grand mean between start.year and end.year. The file name will be file.path(report.dir, paste(Station.Code,"-cumulative departure.pdf",sep=""))

report.dir

Directory in which *.csv or *.pdf files are stored.

na.rm

List of logical values indicating how to deal with missing values. na.rm$na.rm.global control if missing values are to be globally excluded (TRUE) or propogated (FALSE). If missing values are to be propogated, then any statistic computed over a missing value is also set to missing. For example, if a flow value was missing on 2014-01-03, then any statistics for January of 2014, JFM of 2014, calendar year 2014, water year 2014, 3 day rolling average of 1, 2, 3 of January 2014 and all statistics that depend on those rolling averages, will also be set to missing.

csv.nddigits

Number of decimal digits to be rounded to when creating *.csv files.

debug

Internal flag used for debugging

Value

A list with the following elements:

Q.flow.summary

Data frame with flow summary.

Q.stat.annual

Data frame with summary statistics as listed at SummaryStatistics.

Q.stat.annual.trans

Data frame with transposed summary statistics as listed at SummaryStatistics.

dates.missing.flow

Data framw with dates of missing flow$Q between start.year and end.year

file.cy.stat.csv

Object with file name of *.csv file with calendar year summary statistics.

file.wy.stat.csv

Object with file name of *.csv file with water year summary statistics.

file.stat.trans.csv

Object with file name of *.csv file with transposed summary statistics.

file.stat.trend.pdf

Object with file name of *.pdf file with plot of statistics over time.

file.cumdepart.pdf

Object with file name of *.pdf file with plot of yearly and cumulative departures.

file.summary.csv

Object with file name of *.csv file with summary statistics.

file.lowflow.csv

Object with file name of *.csv file with low flow summary statistics.

na.rm

Missing value flags.

Version

Version of this function.

Date

Date function was run.

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
stat.annual <- compute.Q.stat.annual(
                         Station.Code  ='ABCD',
                         Station.Area  =12345,
                         flow          =flow,
                         start.year    =1960,
                         end.year      =2014)

## End(Not run)

bcgov/BCWaterDischargeAnalysis documentation built on Dec. 21, 2020, 2:20 p.m.