time_series_analysis: Get time series output

Description Usage Arguments Value Examples

View source: R/analyze_data.R

Description

Function takes flow data and summarizes flood occurrence through time at both the gage and county level.

Usage

1
2
time_series_analysis(flow_data, peaks, gages, county_cd, q2_val, threshold,
  weight = "Q2", Q2_magnitude = "Moderate", filter_data = TRUE)

Arguments

flow_data

A data frame with discharge data for each USGS gage found for the specified data range. Output from get_flow_data function.

peaks

A data frame of USGS gage IDs and flood values obtained from either the find_Q2 or find_NWS function.

gages

A data frame of all USGS gages and metadata obtained from the get_gages function. This input is used to add lat/long and county codes to the summarized output.

county_cd

Character vector with the county FIPS code(s)

q2_val

A data frame with values of the median annual flood to be used to compare relative sizes of streams at gage locations (from the find_Q2 function).

threshold

Character string of the flood threshold to be used in the analysis (either "Q2" or "NWS"). Defaults to "Q2".

weight

Character string of variable to be used to scale by river size for weighted averages and scaling point sizes on maps. Options are median annual flood ("Q2") or drainage area ("DA"). Defaults to "Q2".

Q2_magnitude

Character string of ratio of daily streamflow to Q2 used as a binary flood threshold. One of "Minor" (1 < Flow / Q2 < 1.5), "Moderate" (< 2), "Major" (< 5), and "Extreme" (> 5). Defaults to "Moderate".

filter_data

Logical. If TRUE only dates with a flood occurring are returned for both gage and county-level data. If FALSE, all dates are returned.

Value

A list with two data frames, summarizing the results by gage and by county:

Gage:

Name Type Description
site_no character USGS gage ID
date date Date of observation
lat numeric Gage latitude
long numeric Gage longitude
county_cd character FIPS code of gage county location
Q2 numeric Median annual discharge (cubic feet per second)
DA numeric Drainage area of the gage (square miles)
size numeric Relative river size, logarithm of either Q2 or DA depending on user specified weight
discharge numeric Observed mean daily discharge (cubic feet per second)
flood_val numeric Selected threshold flood value. Either Q2 or an NWS flood threshold.
flood_ratio numeric Ratio of the observed discharge divided by the defined flood threshold
state character State name
county character County name
flood character Flood magnitude category based on peak

County:

Name Type Description
date date Date of observation
county character County name
state character State name
num_gage numeric Number of analyzed gages in county
max_peak numeric Maximum observed flood ratio
avg_peak numeric Average flood ratio among county gages
minor numeric Percentage of gages at or above "minor" flood class (flood ratio > 1)
moderate numeric Percentage of gages at or above "moderate" flood class (flood ratio > 1.5)
major numeric Percentage of gages at or above "major" flood class (flood ratio > 2)
extreme numeric Percentage of gages at or above "extreme" flood class (flood ratio > 5)
flood_metric numeric Fraction of gages in county experiencing a flood, weighted by river size (size from gage-level output)

If threshold = "NWS", the columns "minor", "moderate", "major", and "extreme" are replaced with two columns: "no_flood" and "yes_flood" which show the percentage of gages in the county with or without flooding.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
va_counties <- get_county_cd("Virginia")
va_gages <- get_gages(va_counties, start_date = "2015-01-01",
                      end_date = "2015-12-31")
va_flow_data <- get_flow_data(va_gages, start_date = "2015-01-01",
                      end_date = "2015-12-31")
va_peaks <- find_q2(va_gages$site_no)
va_time_series <- time_series_analysis(flow_data = va_flow_data, peaks = va_peaks,
                        gages = va_gages, county_cd = va_counties,
                        q2_val = dplyr::rename_(va_peaks, .dots = list(q2 = "flood_val")),
                        threshold = "Q2")

## End(Not run)

countyfloods documentation built on May 2, 2019, 2:38 a.m.