Learn R Programming

EGRET (version 3.0.2)

runPairs: Runs a comparison of any two years in the record.

Description

runPairs provides comparisons of results, in terms of flow-normalized concentration and flow-normalzed flux for any pair of years in the water quality record. Comparison could involve the use of the "wall" and/or use of "generalized flow normalization". These two concepts are described in detail in the vignette.

Usage

runPairs(eList, year1, year2, windowSide, flowBreak = FALSE,
  Q1EndDate = NA, QStartDate = NA, QEndDate = NA, wall = FALSE,
  oldSurface = FALSE, sample1EndDate = NA, sampleStartDate = NA,
  sampleEndDate = NA, paStart = 10, paLong = 12, minNumObs = 100,
  minNumUncen = 50, fractMin = 0.75, windowY = 7, windowQ = 2,
  windowS = 0.5, edgeAdjust = TRUE)

Arguments

eList

named list with at least the Daily, Sample, and INFO dataframes

year1

integer the ending year of the first year in the pair

year2

integer the ending year of the second year in the pair

windowSide

integer. The width of the flow normalization window on each side of the year being estimated. A common value is 7, but no default is specified. If stationary flow normalization is to be used, then windowSide = 0 (this means that flow-normalization period for all years is the same).

flowBreak

logical. Is there an abrupt break in the discharge record, default is FALSE.

Q1EndDate

The Date (as character in YYYY-MM-DD) which is the last day, just before the flowBreak.

QStartDate

The first Date (as character in YYYY-MM-DD) used in the flow normalization method. Default is NA, which makes the QStartDate become the first Date in eList$Daily.

QEndDate

The last Date (as character in YYYY-MM-DD) used in the flow normalization method. Default is NA, which makes the QEndDate become the last Date in eList$Daily.

wall

logical. Whether there is an abrupt break in the concentration versus discharge relationship. Default is FALSE

oldSurface

logical specifying whether to use the original surface, or create a new one. Default is FALSE.

sample1EndDate

The Date (as character in YYYY-MM-DD) of the last date just before the wall. Default = NA. A date must be specified if wall = TRUE.

sampleStartDate

The Date (as character in YYYY-MM-DD) of the first sample to be used. Default is NA which sets it to the first Date in eList$Sample.

sampleEndDate

The Date (as character in YYYY-MM-DD) of the last sample to be used. Default is NA which sets it to the last Date in eList$Sample.

paStart

numeric integer specifying the starting month for the period of analysis, 1<=paStart<=12, default is 10 (used when period is water year).

paLong

numeric integer specifying the length of the period of analysis, in months, 1<=paLong<=12, default is 12.

minNumObs

numeric specifying the miniumum number of observations required to run the weighted regression, default is 100

minNumUncen

numeric specifying the minimum number of uncensored observations to run the weighted regression, default is 50

fractMin

numeric specifying the minimum fraction of the observations required to run the weighted regression, default is 0.75. The minimum number will be the maximum of minNumObs and fractMin multiplied by total number of observations.

windowY

numeric specifying the half-window width in the time dimension, in units of years, default is 7

windowQ

numeric specifying the half-window width in the discharge dimension, units are natural log units, default is 2

windowS

numeric specifying the half-window with in the seasonal dimension, in units of years, default is 0.5

edgeAdjust

logical specifying whether to use the modified method for calculating the windows at the edge of the record. The edgeAdjust method tends to reduce curvature near the start and end of record. Default is TRUE.

Value

data frame with the following columns:

Name Description Total Change
The difference between the results for year2 - year1 CQTC this number is the difference between between the two years, but only the part that is due to the change in the CQR. It is x20 - x10. In the results reported above as, "Concentration v. Q Trend Component" it is computed as 100 * (x20 - x10) / x11
QTC The difference between the two years, but only the part that is due to the change in the QD. It is the Total Change - CQTC. Or it can be stated as x22 - x11 - x20 + x10. In the results reported above as, "Q Trend Component" it is computed as 100 * (x22 - x11 - x20 + x10) / x11. x10
The results using the concentration versus discharge relationship (CQR) for year 1, but using the discharge distribution (QD) for the entire period of record (starting with QStartDate and ending with QEndDate, or if they aren't specified, it is all the discharge data in the Daily data frame). x11 The results using the CQR for year 1, but using the QD specified by the user for year 1.
x20 The results using the CQR for year 2, but using the QD for the entire period.
x22 The results for the CQR for year 2, but using the QD specified by the user for year 2. Name

Additionally, there is an attribute on the data frame "Other", containing a list that includes minNumObs=minNumObs, minNumUncen, windowY, windowQ, windowS, wall, edgeAdjust, QStartDate, QEndDate, PercentChangeConc, and PercentChangeFlux.

PercentChangeConc, and PercentChangeFlux are vectors with: Total Percent Change is the Total Change divided by x11 CQTC Percent is the CQTC divided by x11 QTC Percent is the QTC divided by x11

Examples

Run this code
# NOT RUN {
eList <- Choptank_eList
year1 <- 1985
year2 <- 2010

# }
# NOT RUN {
# Automatic calculations based on windowSide=7
# four possible ways to do generalized flow normalization:

#Option 1: Use all years for flow normalization.

pairOut_1 <- runPairs(eList, year1, year2, windowSide = 0)

# Option 2:  Use different windows for flow normalization for year1 versus year2
#            In each case it is a 15 year window (15 = 1 + 2*7)

pairOut_2 <- runPairs(eList, year1, year2, windowSide = 7)

# Option 3: Flow normalization is based on splitting the flow record at 1990-09-30
#          But year1 uses all flow data from before the break, 
#          year2 uses all flow data after the break

pairOut_3 <- runPairs(eList, year1, year2, 
                      windowSide = 0, flowBreak = TRUE,
                      Q1EndDate = "1990-09-30")

# Option 4: Flow normalization is based on splitting the flow record at 1990-09-30
#           but year1 uses a 15 year window before the break
#           year2 uses a 15 year window after the break

pairOut_4 <- runPairs(eList, year1, year2, 
                      windowSide = 7, flowBreak = TRUE,
                      Q1EndDate = "1990-09-30")
                      

# }

Run the code above in your browser using DataLab