stfl_calc_annual_stats: Compute the annualized statistics from daily data

Description Usage Arguments Value Examples

View source: R/stfl_calc_annual_stats.R

Description

Compute the annualized statistics from daily data using the fasstr routines.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
stfl_calc_annual_stats(
  daily.data,
  Statistic = "Mean",
  water_year_start = 1,
  months_in_year = 12,
  roll_days = 1,
  min_roll_days = c(1, 3, 7, 30),
  roll_align = "right",
  ignore_missing = FALSE,
  STATION_NUMBER.var = "STATION_NUMBER",
  Date.var = "Date",
  Value.var = "Value",
  Parameter.var = "Parameter"
)

Arguments

daily.data

Data frame (typically from the HYDAT data base) with the following fields

  • STATION_NUMBERStation number, usually taken from the HYDAT database

  • DateDate of the reading in YYYY-MM-DD format

  • ParameterType of measurement, typically either 'Flow' or 'Level'

  • ValueValue of the parameter for this date for this station. Numeric.

Statistic

A vector of statistics to be computed from the daily data. The list of available statistics is given gy stfl_get_avail_stat(). A column in the returned data frame will have the statistic names.

water_year_start

Start month for the water year.

months_in_year

How many months, starting from the water_year_start should be included in the water year. These two parameters allows you, for example, to select June - Sept with water_year_start=6 and months_in_year=4. If you specify water_year_start=10 and months_in_year=4, statistics will be computed using October, November, December, and January (of the next year). The year in which the water year starts is used as the label for the annualized value – this differs from ther fasstr package.

roll_days

Numeric value of number of days to apply a rolling mean (default 1) before statistics are computed.

min_roll_days

Numeric value of number of days to apply a rolling minimum (and similar statistics) (default 1). See fasstr::calc_annual_stats() for more details.

roll_align

Character string identify the direction of the rolling mean from the specified date. See fasstr::calc_annual_stats() for more details.

ignore_missing

Should missing values be ignored when computing statistics. The default value of FALSE implies that only complete water years (or portions selected using water_year_start) can be used in computing annualized statistics.

STATION_NUMBER.var

Character string with the name of the variable containing the station number in the daily data and in the output results..

Date.var

Character string with the name of the variable containing the date.

Value.var

Character string with the name of the variable containing the value to be analyzed.

Parameter.var

Character string with the name of the variable containing the name of the Parameter in the daily data and in the output results.

Value

Returns a data.frame with the following variables (sort order cannot be assumed)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
# needs the HYDAT package installed
station.id <- "08NM116"

daily <- hy_daily(station_number=station.id)
head(daily)

res <- stfl_calc_annual_stats(daily, Statistic=c("Mean","P90","Min"),
        water_year_start=1, months_in_year=2, ignore_missing=TRUE)
head(res1)
tail(res1)

## End(Not run)

bcgov/StreamFlowTrend documentation built on Dec. 19, 2021, 7:38 a.m.