extractHydroVars: Extract hydrodynamic variables from WeStCOMS meshes

View source: R/loadAndExtract.R

extractHydroVarsR Documentation

Extract hydrodynamic variables from WeStCOMS meshes

Description

Given an input dataframe with site locations, dates, hours, and depths, this function extracts the corresponding WeStCOMS data. Output can be specific hours and depths, or summarised for the day or water column (surface to depth *d*) as given in 'daySummaryFn' and 'depthSummaryFn'.

Usage

extractHydroVars(
  sampling.df,
  westcoms.dir,
  hydroVars,
  daySummaryFn = NULL,
  depthSummaryFn = NULL,
  regional = F,
  sep = "/",
  cores = 1,
  progress = T,
  errorhandling = "remove",
  returnFullDf = FALSE
)

Arguments

sampling.df

Dataframe with a row for each sample. Columns must include 'site.id', 'obs.id', 'date' (YYYYMMDD), 'hour', 'depth', 'grid', 'site.elem', 'trinode_1', 'trinode_2', and 'trinode_3', which can be added through a spatial join with the mesh files (see vignette)

westcoms.dir

Character vector with directories for WeStCOMS v1 and WeStCOMS v2 hydrodynamic files

hydroVars

Character vector of hydrodynamic variables to extract

daySummaryFn

Vector of functions to summarise by day, one per var; if 'NULL' (default), single hour is extracted

depthSummaryFn

Vector of functions to summarise across depth, one per var; if 'NULL' (default), single hour is extracted

regional

Logical: does sampling.df include rows to calculate regional averages? Requires a row for each element to average for each site. For example, a row for each element within a 1km radius, with the results averaged

sep

Directory separation character (Windows: '\', Unix: '/')

cores

Number of cores for extracting in parallel; default is 1

progress

Logical: Show progress bar?

errorhandling

Passed to 'foreach': one of "stop", "remove", or "pass"

returnFullDf

Logical: return full dataframe or only obs.id + hydrovars?

Value

dataframe with site.id, date, and hydrodynamic variables


Sz-Tim/WeStCOMS documentation built on April 17, 2025, 3:10 p.m.