## Calculate Flow Anomalies

### Description

Flow anomalies are a dimensionless term that reflects the difference in in current discharges compared to past discharges. A positive flow anomaly indicates the current time period, T_{1}, is wetter than the precedent time period, T_{2}.

### Usage

fa(discharge, dates, T_1, T_2, clean_up = FALSE, transform = "log10")


### Arguments

 discharge numeric vector of daily discharges dates vector of dates coresponding to daily discharge measurements. Must be class "Date". T_1 size of period T_{1} preceding a given day t. Specified in the same way as the by argument in seq.POSIXt. T_2 size of period T_{2} preceding a given day t. Specified in the same way as the by argument in seq.POSIXt. Period T_2 is expected to be longer than T_1. clean_up logical. runs .... prior to .... transform on of NA, log, log10,

### Details

The FA term describes how different the antecedent discharge conditions are for a selected temporal period compared to a selected period or day of analysis. Ryberg and Vecchia (2014) and Vechia et al. (2009) describe the flow anomaly (FA) term as:

FA(t)=X_{T_1}(t) - X_{T_2}(t)

The T_1 and T_2 arguments can be specified as character strings containing one of "sec", "min", "hour", "day", "DSTday", "week", "month", "quarter", or "year". This is generally preceded by an integer and a space. Can also be followed by an "s". Additionally, T_2 accepts "period" which coresponds with the mean of the entire flow record.

### Value

vector of numeric values corresponding to X_{T_1}(t) - X_{T_2}(t).

### References

Ryberg, Karen R., and Aldo V. Vecchia. 2012. “WaterData—An R Package for Retrieval, Analysis, and Anomaly Calculation of Daily Hydrologic Time Series Data.” Open Filer Report 2012-1168. National Water-Quality Assessment Program. Reston, VA: USGS. https://pubs.usgs.gov/of/2012/1168/.

Vecchia, Aldo V., Robert J. Gilliom, Daniel J. Sullivan, David L. Lorenz, and Jeffrey D. Martin. 2009. “Trends in Concentrations and Use of Agricultural Herbicides for Corn Belt Rivers, 1996-2006.” Environmental Science & Technology 43 (24): 9096–9102. doi:10.1021/es902122j.

### Examples

 ## examples from Ryberg & Vechia 2012
## Long-term Flow Anomaly LTFA
LTFA <- fa(lavaca$Flow, dates = lavaca$Date,
T_1 = "1 year",
T_2 = "period",
clean_up = TRUE,
transform = "log10")

## Mid-term Flow Anomaly MTFA
MTFA <- fa(lavaca$Flow, dates = lavaca$Date,
T_1 = "1 month",
T_2 = "1 year",
clean_up = TRUE,
transform = "log10")

## Short-term Flow Anomaly STFA
STFA <- fa(lavaca$Flow, dates = lavaca$Date,
T_1 = "1 day",
T_2 = "1 month",
clean_up = TRUE,
transform = "log10")