| Title: | nwmTools |
|---|---|
| Description: | Tools for working with operational and historic National Water Model Output. |
| Authors: | Mike Johnson [aut, cre] (ORCID: <https://orcid.org/0000-0002-5288-8350>), Lauren Bolotin [ctb], CUAHSI [fnd], NSF [fnd], Lynker [fnd] |
| Maintainer: | Mike Johnson <[email protected]> |
| License: | CC0 |
| Version: | 0.0.4 |
| Built: | 2026-05-16 06:07:58 UTC |
| Source: | https://github.com/mikejohnson51/nwmTools |
Add Water Year Column
add_waterYear(dateVec)add_waterYear(dateVec)
dateVec |
raw data returned from readNWMdata |
vector of water years
Aggregate by DOWY
aggregate_dowy(rawData, fun = "mean", na.rm = TRUE)aggregate_dowy(rawData, fun = "mean", na.rm = TRUE)
rawData |
data extracted with |
fun |
function to be applied to the flows column default = 'mean' |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
NWM data is extracted as hourly values.
To aggregate hourly data to different time chunks the nwmHistoric package offers a family of aggregate functions.
Each of these begins with the prefix 'aggregate_' and is followed by the date symbol to aggregate to.
| Symbol | Aggregate |
| y | year |
| m | month |
| d | day |
| j | julien day |
| s | season |
| wy | water year |
Other aggregate functions:
aggregate_j(),
aggregate_m(),
aggregate_record(),
aggregate_s(),
aggregate_wymd(),
aggregate_wym(),
aggregate_wys(),
aggregate_wy(),
aggregate_yj(),
aggregate_ymd(),
aggregate_ym(),
aggregate_ys(),
aggregate_y()
## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)
Aggregate by Julien Day
aggregate_j(rawData, fun = "mean", na.rm = TRUE)aggregate_j(rawData, fun = "mean", na.rm = TRUE)
rawData |
data extracted with |
fun |
function to be applied to the flows column default = 'mean' |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
NWM data is extracted as hourly values.
To aggregate hourly data to different time chunks the nwmHistoric package offers a family of aggregate functions.
Each of these begins with the prefix 'aggregate_' and is followed by the date symbol to aggregate to.
| Symbol | Aggregate |
| y | year |
| m | month |
| d | day |
| j | julien day |
| s | season |
| wy | water year |
Other aggregate functions:
aggregate_dowy(),
aggregate_m(),
aggregate_record(),
aggregate_s(),
aggregate_wymd(),
aggregate_wym(),
aggregate_wys(),
aggregate_wy(),
aggregate_yj(),
aggregate_ymd(),
aggregate_ym(),
aggregate_ys(),
aggregate_y()
## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)
Aggregate by Month
aggregate_m(rawData, fun = "mean", na.rm = TRUE)aggregate_m(rawData, fun = "mean", na.rm = TRUE)
rawData |
data extracted with |
fun |
function to be applied to the flows column default = 'mean' |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
NWM data is extracted as hourly values.
To aggregate hourly data to different time chunks the nwmHistoric package offers a family of aggregate functions.
Each of these begins with the prefix 'aggregate_' and is followed by the date symbol to aggregate to.
| Symbol | Aggregate |
| y | year |
| m | month |
| d | day |
| j | julien day |
| s | season |
| wy | water year |
Other aggregate functions:
aggregate_dowy(),
aggregate_j(),
aggregate_record(),
aggregate_s(),
aggregate_wymd(),
aggregate_wym(),
aggregate_wys(),
aggregate_wy(),
aggregate_yj(),
aggregate_ymd(),
aggregate_ym(),
aggregate_ys(),
aggregate_y()
## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)
Aggregate by Record
aggregate_record(rawData, fun = "mean", na.rm = TRUE)aggregate_record(rawData, fun = "mean", na.rm = TRUE)
rawData |
data extracted with |
fun |
function to be applied to the flows column default = 'mean' |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
NWM data is extracted as hourly values.
To aggregate hourly data to different time chunks the nwmHistoric package offers a family of aggregate functions.
Each of these begins with the prefix 'aggregate_' and is followed by the date symbol to aggregate to.
| Symbol | Aggregate |
| y | year |
| m | month |
| d | day |
| j | julien day |
| s | season |
| wy | water year |
Other aggregate functions:
aggregate_dowy(),
aggregate_j(),
aggregate_m(),
aggregate_s(),
aggregate_wymd(),
aggregate_wym(),
aggregate_wys(),
aggregate_wy(),
aggregate_yj(),
aggregate_ymd(),
aggregate_ym(),
aggregate_ys(),
aggregate_y()
## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)
Aggregate by Season
aggregate_s(rawData, fun = "mean", na.rm = TRUE)aggregate_s(rawData, fun = "mean", na.rm = TRUE)
rawData |
data extracted with |
fun |
function to be applied to the flows column default = 'mean' |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
NWM data is extracted as hourly values.
To aggregate hourly data to different time chunks the nwmHistoric package offers a family of aggregate functions.
Each of these begins with the prefix 'aggregate_' and is followed by the date symbol to aggregate to.
| Symbol | Aggregate |
| y | year |
| m | month |
| d | day |
| j | julien day |
| s | season |
| wy | water year |
Other aggregate functions:
aggregate_dowy(),
aggregate_j(),
aggregate_m(),
aggregate_record(),
aggregate_wymd(),
aggregate_wym(),
aggregate_wys(),
aggregate_wy(),
aggregate_yj(),
aggregate_ymd(),
aggregate_ym(),
aggregate_ys(),
aggregate_y()
## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)
Aggregate by Water Year
aggregate_wy(rawData, fun = "mean", na.rm = TRUE)aggregate_wy(rawData, fun = "mean", na.rm = TRUE)
rawData |
data extracted with |
fun |
function to be applied to the flows column default = 'mean' |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
NWM data is extracted as hourly values.
To aggregate hourly data to different time chunks the nwmHistoric package offers a family of aggregate functions.
Each of these begins with the prefix 'aggregate_' and is followed by the date symbol to aggregate to.
| Symbol | Aggregate |
| y | year |
| m | month |
| d | day |
| j | julien day |
| s | season |
| wy | water year |
Other aggregate functions:
aggregate_dowy(),
aggregate_j(),
aggregate_m(),
aggregate_record(),
aggregate_s(),
aggregate_wymd(),
aggregate_wym(),
aggregate_wys(),
aggregate_yj(),
aggregate_ymd(),
aggregate_ym(),
aggregate_ys(),
aggregate_y()
## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)
Aggregate by Water Year - Month
aggregate_wym(rawData, fun = "mean", na.rm = TRUE)aggregate_wym(rawData, fun = "mean", na.rm = TRUE)
rawData |
data extracted with |
fun |
function to be applied to the flows column default = 'mean' |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
NWM data is extracted as hourly values.
To aggregate hourly data to different time chunks the nwmHistoric package offers a family of aggregate functions.
Each of these begins with the prefix 'aggregate_' and is followed by the date symbol to aggregate to.
| Symbol | Aggregate |
| y | year |
| m | month |
| d | day |
| j | julien day |
| s | season |
| wy | water year |
Other aggregate functions:
aggregate_dowy(),
aggregate_j(),
aggregate_m(),
aggregate_record(),
aggregate_s(),
aggregate_wymd(),
aggregate_wys(),
aggregate_wy(),
aggregate_yj(),
aggregate_ymd(),
aggregate_ym(),
aggregate_ys(),
aggregate_y()
## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)
Aggregate by Water Year - Month - Day
aggregate_wymd(rawData, fun = "mean", na.rm = TRUE)aggregate_wymd(rawData, fun = "mean", na.rm = TRUE)
rawData |
data extracted with |
fun |
function to be applied to the flows column default = 'mean' |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
NWM data is extracted as hourly values.
To aggregate hourly data to different time chunks the nwmHistoric package offers a family of aggregate functions.
Each of these begins with the prefix 'aggregate_' and is followed by the date symbol to aggregate to.
| Symbol | Aggregate |
| y | year |
| m | month |
| d | day |
| j | julien day |
| s | season |
| wy | water year |
Other aggregate functions:
aggregate_dowy(),
aggregate_j(),
aggregate_m(),
aggregate_record(),
aggregate_s(),
aggregate_wym(),
aggregate_wys(),
aggregate_wy(),
aggregate_yj(),
aggregate_ymd(),
aggregate_ym(),
aggregate_ys(),
aggregate_y()
## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)
Aggregate by Water Year - Season
aggregate_wys(rawData, fun = "mean", na.rm = TRUE)aggregate_wys(rawData, fun = "mean", na.rm = TRUE)
rawData |
data extracted with |
fun |
function to be applied to the flows column default = 'mean' |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
NWM data is extracted as hourly values.
To aggregate hourly data to different time chunks the nwmHistoric package offers a family of aggregate functions.
Each of these begins with the prefix 'aggregate_' and is followed by the date symbol to aggregate to.
| Symbol | Aggregate |
| y | year |
| m | month |
| d | day |
| j | julien day |
| s | season |
| wy | water year |
Other aggregate functions:
aggregate_dowy(),
aggregate_j(),
aggregate_m(),
aggregate_record(),
aggregate_s(),
aggregate_wymd(),
aggregate_wym(),
aggregate_wy(),
aggregate_yj(),
aggregate_ymd(),
aggregate_ym(),
aggregate_ys(),
aggregate_y()
## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)
Aggregate by Year
aggregate_y(rawData, fun = "mean", na.rm = TRUE)aggregate_y(rawData, fun = "mean", na.rm = TRUE)
rawData |
data extracted with |
fun |
function to be applied to the flows column default = 'mean' |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
NWM data is extracted as hourly values.
To aggregate hourly data to different time chunks the nwmHistoric package offers a family of aggregate functions.
Each of these begins with the prefix 'aggregate_' and is followed by the date symbol to aggregate to.
| Symbol | Aggregate |
| y | year |
| m | month |
| d | day |
| j | julien day |
| s | season |
| wy | water year |
Other aggregate functions:
aggregate_dowy(),
aggregate_j(),
aggregate_m(),
aggregate_record(),
aggregate_s(),
aggregate_wymd(),
aggregate_wym(),
aggregate_wys(),
aggregate_wy(),
aggregate_yj(),
aggregate_ymd(),
aggregate_ym(),
aggregate_ys()
## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)
Aggregate by Year-Julien Day
aggregate_yj(rawData, fun = "mean", na.rm = TRUE)aggregate_yj(rawData, fun = "mean", na.rm = TRUE)
rawData |
data extracted with |
fun |
function to be applied to the flows column default = 'mean' |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
NWM data is extracted as hourly values.
To aggregate hourly data to different time chunks the nwmHistoric package offers a family of aggregate functions.
Each of these begins with the prefix 'aggregate_' and is followed by the date symbol to aggregate to.
| Symbol | Aggregate |
| y | year |
| m | month |
| d | day |
| j | julien day |
| s | season |
| wy | water year |
Other aggregate functions:
aggregate_dowy(),
aggregate_j(),
aggregate_m(),
aggregate_record(),
aggregate_s(),
aggregate_wymd(),
aggregate_wym(),
aggregate_wys(),
aggregate_wy(),
aggregate_ymd(),
aggregate_ym(),
aggregate_ys(),
aggregate_y()
## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)
Aggregate by Year-Month
aggregate_ym(rawData, fun = "mean", na.rm = TRUE)aggregate_ym(rawData, fun = "mean", na.rm = TRUE)
rawData |
data extracted with |
fun |
function to be applied to the flows column default = 'mean' |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
NWM data is extracted as hourly values.
To aggregate hourly data to different time chunks the nwmHistoric package offers a family of aggregate functions.
Each of these begins with the prefix 'aggregate_' and is followed by the date symbol to aggregate to.
| Symbol | Aggregate |
| y | year |
| m | month |
| d | day |
| j | julien day |
| s | season |
| wy | water year |
Other aggregate functions:
aggregate_dowy(),
aggregate_j(),
aggregate_m(),
aggregate_record(),
aggregate_s(),
aggregate_wymd(),
aggregate_wym(),
aggregate_wys(),
aggregate_wy(),
aggregate_yj(),
aggregate_ymd(),
aggregate_ys(),
aggregate_y()
## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)
Aggregate by Year-Month-Day
aggregate_ymd(rawData, fun = "mean", na.rm = TRUE)aggregate_ymd(rawData, fun = "mean", na.rm = TRUE)
rawData |
data extracted with |
fun |
function to be applied to the flows column default = 'mean' |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
NWM data is extracted as hourly values.
To aggregate hourly data to different time chunks the nwmHistoric package offers a family of aggregate functions.
Each of these begins with the prefix 'aggregate_' and is followed by the date symbol to aggregate to.
| Symbol | Aggregate |
| y | year |
| m | month |
| d | day |
| j | julien day |
| s | season |
| wy | water year |
Other aggregate functions:
aggregate_dowy(),
aggregate_j(),
aggregate_m(),
aggregate_record(),
aggregate_s(),
aggregate_wymd(),
aggregate_wym(),
aggregate_wys(),
aggregate_wy(),
aggregate_yj(),
aggregate_ym(),
aggregate_ys(),
aggregate_y()
## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)
Aggregate by Year-Season
aggregate_ys(rawData, fun = "mean", na.rm = TRUE)aggregate_ys(rawData, fun = "mean", na.rm = TRUE)
rawData |
data extracted with |
fun |
function to be applied to the flows column default = 'mean' |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
NWM data is extracted as hourly values.
To aggregate hourly data to different time chunks the nwmHistoric package offers a family of aggregate functions.
Each of these begins with the prefix 'aggregate_' and is followed by the date symbol to aggregate to.
| Symbol | Aggregate |
| y | year |
| m | month |
| d | day |
| j | julien day |
| s | season |
| wy | water year |
Other aggregate functions:
aggregate_dowy(),
aggregate_j(),
aggregate_m(),
aggregate_record(),
aggregate_s(),
aggregate_wymd(),
aggregate_wym(),
aggregate_wys(),
aggregate_wy(),
aggregate_yj(),
aggregate_ymd(),
aggregate_ym(),
aggregate_y()
## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)## Not run: # Get flow record for COMID 101 flows = readNWMdata(comid = 101) # Aggregate to yearly average (y) yearly = aggregate_y(flows, fun = 'mean') # Aggregate to monthly # minimum and maximum per year (ym) ym = aggregate_ym(flows, fun = list(min, max)) # Aggregate to seasonal 95th percetile # with using custom function s95 = aggregate_s(flows, fun = function(x){quantile(x,.95)}) ## End(Not run)
Crop Flipped Raster
crop_flipped_nwm(x, AOI)crop_flipped_nwm(x, AOI)
x |
SpatRast object |
AOI |
a sf polygon |
SpatRast object (x cropped to AOI)
Download Remote Files
download_files(fileList, outdir = ".")download_files(fileList, outdir = ".")
fileList |
fileList object |
outdir |
directory to write files |
data.frame
Get GCP file list
get_aws_urls( version = 2.1, output = "CHRTOUT", config = NULL, ensemble = NULL, date = "2010-10-29", hour = "00", minute = "00", num = 3, outdir = NULL )get_aws_urls( version = 2.1, output = "CHRTOUT", config = NULL, ensemble = NULL, date = "2010-10-29", hour = "00", minute = "00", num = 3, outdir = NULL )
version |
NWM model version |
output |
the NWM model output type |
config |
the NWM model configurarion |
ensemble |
the NWM ensemble number |
date |
date of interest |
hour |
hour of interest |
minute |
minute of interest |
num |
number of files to get (forward from provides data-hour-minute) |
data.frame
Get GCP file list
get_gcp_urls( config = "short_range", domain = "conus", date, hour = "00", minute = "00", num, ensemble = NULL, output = "channel_rt" )get_gcp_urls( config = "short_range", domain = "conus", date, hour = "00", minute = "00", num, ensemble = NULL, output = "channel_rt" )
config |
the NWM model configurarion |
domain |
the NWM model domain |
date |
date of interest |
hour |
hour of interest |
minute |
minute of interest |
num |
number of files to get (forward from provides data-hour-minute) |
ensemble |
the NWM ensemble number |
output |
the NWM model output type |
data.frame
Extract Gridded Data from fileList
get_gridded_data(fileList, AOI, varname, outfile = NULL)get_gridded_data(fileList, AOI, varname, outfile = NULL)
fileList |
a list of gridded NWM outputs |
AOI |
area of interest (sf POLYGON) to subset |
varname |
the name of the variable to extract |
outfile |
filepath to save data (with .nc extension) |
data.frame
Get NOMADs File List
get_nomads_urls( config = "short_range", domain = "conus", date = NULL, hour = NULL, minute = "00", num, ensemble = NULL, output = "channel_rt", version = "prod", outdir = NULL )get_nomads_urls( config = "short_range", domain = "conus", date = NULL, hour = NULL, minute = "00", num, ensemble = NULL, output = "channel_rt", version = "prod", outdir = NULL )
config |
the NWM model configurarion |
domain |
the NWM model domain |
date |
date of interest |
hour |
hour of interest |
minute |
minute of interest |
num |
number of files to get (forward from provides data-hour-minute) |
ensemble |
the NWM ensemble number |
output |
the NWM model output type |
version |
server version (prod or para) |
data.frame
NWM metadata
get_nwm_meta(version = NULL)get_nwm_meta(version = NULL)
version |
Which version of NWM should be returned? (1.2, 2.0, 2.1) |
data.frame
Extract Timeseries from file list
get_timeseries( fileList, ids = NULL, index_id = "feature_id", varname = "streamflow", outfile = NULL )get_timeseries( fileList, ids = NULL, index_id = "feature_id", varname = "streamflow", outfile = NULL )
fileList |
a list of non-gridded NWM outputs |
ids |
a set of ids to limit the returned data to |
index_id |
the name of the id attributes |
varname |
the name of the variable |
outfile |
file path to save data to (.nc extension) |
data.frame
NWM Data Types
nwm_datanwm_data
An object of class tbl_df (inherits from tbl, data.frame) with 603 rows and 13 columns.
Download hourly flow values for an NHD COMID from the National Water Model version 1.2 or 2.0. Returned data is available between "1993-01-01 00" and "2017-12-31 23" but can be subset using a startDate and endDate.
readNWMdata( AOI = NULL, comid = NULL, siteID = NULL, startDate = NULL, endDate = NULL, tz = "UTC", version = 2.1, addObs = FALSE, add_nhd = FALSE )readNWMdata( AOI = NULL, comid = NULL, siteID = NULL, startDate = NULL, endDate = NULL, tz = "UTC", version = 2.1, addObs = FALSE, add_nhd = FALSE )
AOI |
spatial polygon or point to extract data for |
comid |
a NHD common identifier |
siteID |
a USGS NWIS site identifier (eight digits) |
startDate |
a start date (YYYY-MM-DD) or (YYYY-MM-DD HH) |
endDate |
an end date (YYYY-MM-DD) or (YYYY-MM-DD HH) |
tz |
the desired timezone of the data. Can be found with |
version |
the NWM version to extract (current = 1.2 or 2 (default)) |
addObs |
should observation data be added? Only available when !is.null(siteID) |
add_nhd |
should the NHD spatial features be added to the output |
data.frame or sf object
## Not run: readNWMdata(comid = 101) readNWMdata(comid = 101, version = 1.2) readNWMdata(comid = 101, tz = "US/Pacific") ## End(Not run)## Not run: readNWMdata(comid = 101) readNWMdata(comid = 101, version = 1.2) readNWMdata(comid = 101, tz = "US/Pacific") ## End(Not run)
Split Y-M-D-H into time components
split_time(rawData, time_col)split_time(rawData, time_col)
rawData |
rawData with time column |
time_col |
the column name holding dateTime |
data.frame with added time components
NWM THREDDS Servers
tds_metatds_meta
An object of class data.frame with 3 rows and 7 columns.