View source: R/ms_calc_watershed_precip.R
ms_calc_watershed_precip | R Documentation |
Using precipitation gauge recordings (depth and/or chemistry) and locations, this function interpolates an estimated value at each cell of an automatically retrieved digital elevation model (DEM), then averages cell values to generate a watershed average at every time step. The local relationship between elevation and precipitation depth may also be leveraged for better prediction. If precipitation chemistry is supplied in addition to depth, then watershed-average precipitation depth, chemistry, and chemical flux estimates will all be generated.
ms_calc_watershed_precip(
precip,
ws_boundary,
precip_gauge,
pchem,
parallel = TRUE,
maxcores = Inf,
out_path,
elevation_agnostic = TRUE,
verbose = TRUE
)
precip |
optional |
ws_boundary |
|
precip_gauge |
|
pchem |
optional |
parallel |
logical. If TRUE (default), interpolation attempts to use |
maxcores |
numeric. Default |
out_path |
character. Directory to which output data will be saved. |
elevation_agnostic |
Logical. Should elevation data be ignored when interpolating precipitation data? TRUE means "ignore elevation." See details for more information. |
verbose |
Logical. If TRUE (default), prints more information during run. |
This function uses inverse distance weighted interpolation to extend gauge measurements
to every cell of a watershed DEM. If elevation_agnostic
is set to TRUE, the resulting
watershed average will be a simple arithmetic mean of all watershed cell values, ignoring
the local relationship between precipitation and elevation.
If FALSE (the default), the resulting watershed average will be a weighted mean of two separate estimates: the
mean of cell values (weight: 1) and the prediction of a linear regression with elevation (weight: absolute value of adjusted R^2 of modeled data).
At least 3 gauges must record at a given time step for the regression to be leveraged in generating the final prediction.
Note that these computations are performed at every time step, using all available
(non-missing, non-NA) gauges.
This function will interpolate only precipitation depth if no pchem is supplied. It will only interpolate precipitation chemistry if no precip data is supplied. If both precip and pchem are supplied, then precipitation depth, chemical concentrations, and precipitation chemical fluxes will all be calculated.
In general, elevation is a relevant predictor for precipitation depth, but not necessarily
concentration or flux of precip chemical components. As such, elevation_agnostic
is always set to TRUE (ignore the elev-precip relationship) when determining watershed-average precipitation chemistry in the case of both
precip
and pchem
being supplied. If only pchem
or precip
is
supplied and elevation_agnostic
is FALSE, then the elevation-pchem relationship
will be incorporated into the final estimate of the watershed average
for each time step.
Note that this function does not return the imputed watershed grid for each timestep–only the watershed-average estimate(s) as tibbles.
MacroSheds format (only date, site_code, var, and val are required as inputs. all are written to output files):
"date" in YYYY-mm-dd format
"site_code": Short name for MacroSheds site. See ms_load_sites()
.
"grab_sample": Boolean integer indicating whether the observation was obtained via grab sample or installed sensor. 1 = TRUE (grab sample), 0 = FALSE (installed sensor).
"var": Variable code. See ms_load_variables()
.
"val": Data value. See ms_load_variables()
for units.
"ms_status": Boolean integer. 0 = clean value. 1 = questionable value. See the MacroSheds data paper for details.
"ms_interp": Boolean integer. 0 = measured or imputed by primary source. 1 = interpolated by MacroSheds. See the MacroSheds data paper for details.
"val_err": The combined standard uncertainty associated with the corresponding data point, or NA if unknown. See "Detection limits and propagation of uncertainty" section of See the MacroSheds data paper for details.
Saves watershed-average precipitation depth and/or chemistry, and chemical flux (if both precip
and pchem are supplied) to out_path
as feather files in MacroSheds format (see details).
Output units for flux are kg/d. See ms_scale_flux_by_area()
to convert to kg/ha/d.
Spencer Rhea
Mike Vlah, vlahm13@gmail.com
Wes Slaughter
ms_load_product()
, ms_delineate_watershed()
, ms_scale_flux_by_area()
See vignette: https://github.com/MacroSHEDS/macrosheds/blob/master/vignettes/ms_interpolate_precip.md
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.