library(rremat) library(dplyr)
This code reproduces the dataframe volumes
from the text files in
extdata/bathymetry. The volume lookup table is generated from a 1ft x 1ft
bathymetry raster with a vertical resolution as defined in
bathymetry/zgrid.csv
.
# load the bathymetry tables volpath = system.file("extdata/bathymetry/bathytables", package = "rremat") bathytables = dir(volpath, pattern = "*.csv$", full.names = TRUE) bathydat = read_bathymetry_tables(bathytables) # build the habitat table wses = seq(2.7, 3.0, by = 0.1) lookupvalues = setNames(expand.grid(unique(bathydat$bedelev), unique(bathydat$bedelev)), c("elev", "wse")) lookupvalues = filter(lookupvalues, elev <= wse) volumes = evalmany(build_habitat_table, e = lookupvalues$elev, w = lookupvalues$wse, method = "set", default.args = list(d = bathydat), packages = "dplyr", clusters = 3)[1:9] # add bathymetry resolution information respath = system.file("extdata/bathymetry/bathymetryresolution.csv", package = "rremat") attr(volumes, "resolution") = read.csv(respath)
The stage-volume curve is generated from the volume lookup table.
stage_volume = volumes %>% gather(type, habcount, count, count.littoral, count.limnetic, count.epibenthic, count.sublimnetic, count.profundal) %>% group_by(type, wse) %>% summarize(count = sum(habcount))
information on closures is contained in extdata/closures/closures.csv
.
This code reproduces the data frame closures
which provides meta data for
closures occurring during the monitoring periods.
closurepath = system.file("extdata/closures", package = "rremat") closures = read.csv(paste0(closurepath, "/closures.csv"), stringsAsFactors = FALSE, colClasses = c(start = "Date", end = "Date", code = "factor", note = "character"))
CTD transect meta data is contained in extdata/ctd_meta/transectdatetimes.csv
.
This code reproduces the dataframe ctdmeta
which provides meta data for the
transect data described in the following sections.
ctdmpath = system.file("extdata/ctd_meta", package = "rremat") ctdm = read.csv(paste0(ctdmpath, "/transectdatetime.csv"), stringsAsFactors = FALSE, colClasses = "character") ctdmeta = data.frame(id = factor(ctdm$id), start = as.POSIXct(paste(ctdm$date, ctdm$start), tz = "US/Pacific"), end = as.POSIXct(paste(ctdm$date, ctdm$end), tz = "US/Pacific"), numcasts = as.integer(ctdm$numcasts), note = ctdm$note) # cross-reference with closures ctdmeta["code"] = factor(unlist(sapply(as.Date(ctdmeta$start), function(x){ this = as.character(closures$code[which(x >= closures$start & x <= closures$end)]) if(length(this) > 0) this else "O" }))) # set time zones to UTC attr(ctdmeta$start, "tzone") = "UTC" attr(ctdmeta$end, "tzone") = "UTC"
CTD cast location data is contained in extdata/ctd_meta/CTDlocations.csv
.
Cast ID data is contained in extdata/ctd_meta/RR_station_IDs.mat
.
This code reproduces the dataframe ctdlocations
which provides
IDs thalweg distance, and GPS coordinates, for each of the 12
CTD cast locations for the transect data described in the
following sections.
ctdipath = system.file("extdata/ctd_meta", package = "rremat") ctdi = readMat(file.path(ctdipath, "RR_station_IDs.mat")) ctdid = with(ctdi$sitekey[,, 1], correct_dist(data.frame(station = unlist(stn), dist = unlist(dist)))) ctdlpath = system.file("extdata/ctd_meta", package = "rremat") ctdl = read.csv(paste0(ctdlpath, "/CTDlocations.csv"), stringsAsFactors = FALSE, colClasses = "character") ctdloc = data.frame(station = ctdl$Station.ID, name = ctdl$Station.Name, latitude = as.numeric(ctdl$Latitude), longitude = as.numeric(ctdl$Longitude) ) ctdlocations = merge(ctdloc, ctdid, by = "station") ctdlocations['station'] = factor(ctdlocations$station, 1:12) ctdlocations = ctdlocations[order(ctdlocations$station),]
This code reproduces the dataframe ctd
from the Matlab files in
extdata/ctd
.
ctdpath = system.file("extdata/ctd", package = "rremat") ctd.list = Map(function(fpath) read_rrectd(fpath, quiet = TRUE)[[1]], fpath = paste0(ctdpath, "/", dir(ctdpath))) ctd = correct_dist(depth_from_elev(merge_rrectd(ctd.list)))
This code reproduces the dataframe grids
from the matlab files
in extdata/ctd_interp
. These grids may contain extrapolated data including
regions outside of the estuary bathymetry and above the observed water-surface
elevation. Note that the dist
values have already been corrected as per the
function correct_dist
(see matlab-src/interpctd.m
). Volume information and
water-surface elevation is added to the gridded data
using the volume lookup table and and CTD cast data, respectively. Extrapolated
data occurring either outside of the estuary bathymetry (volume == 0
) or
above the water-surface elevation (elev > wse
) is removed.
gridpath = system.file("extdata/ctd_interp", package = "rremat") grid.list = Map(function(fpath) read_rrectdgrid(fpath, quiet = TRUE)[[1]], fpath = paste0(gridpath, "/", dir(gridpath))) grids = merge_rrectd(grid.list) grids = join_wse(grids, ctd) %>% mutate(wse = round(wse, 1)) %>% filter(elev <= wse) %>% join_volume(volumes) %>% filter(volume.total > 0) #usethis::use_data(grids, overwrite = TRUE)
This code reproduces the dataframe wll
from the Matlab files in
extdata/wll
.
wllpath = system.file("extdata/wll", package = "rremat") wll.list = Map(function(fpath) read_rrewll(fpath, quiet = TRUE)[[1]], fpath = paste0(wllpath, "/", dir(wllpath))) wll = merge_rrewll(wll.list) wll = wll[!is.nan(wll$depth),]
The following data sets are produced outside of the Largier Lab, but provide critical supplemental data.
This code reproduces the dataframe tides
generated from files in
extdata/tides
. The files contain data for the
NOAA Point Reyes Station
downloaded from the NOAA web API. Those files were created using the function
download_tides
.
tidespath = system.file("extdata/tides", package = "rremat") tides.list = Map(read.csv, file = paste0(tidespath, "/", dir(tidespath)), stringsAsFactors = FALSE) tides = merge_tides(tides.list)
This code reproduces the dataframe waves
generated from files in
extdata/waves
. The files contain data for the NOAA buoy at
Bodega Bay
(Station 46013/LLNR 390). Those files were scraped from the NDBC
historical data web page.
wavespath = system.file("extdata/waves", package = "rremat") waves.list = Map(read.csv, file = paste0(wavespath, "/", dir(wavespath)), stringsAsFactors = FALSE, encoding = "UTF-8", comment.char = "#") waves = merge_waves(waves.list)
This code reproduces the dataframe inflows
from the files in
extdata/streamflow
. The files contain streamflow data for from USGS gauges near
Guerneville, CA
(Russian River/Station 11467000) and near
Cazadero, CA
(Austin Creek/Station 11467200). Those files were downloaded from the USGS
National Water Information System.
sfpath = system.file("extdata/streamflow", package = "rremat") sf.list = Map(read.csv, file = paste0(sfpath, "/", dir(sfpath)), stringsAsFactors = FALSE) inflows = merge_streamflow(sf.list)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.