weighingGauge3: Filters weighing gauge cumulative precipitation

View source: R/weighingGauge3.R

weighingGauge3R Documentation

Filters weighing gauge cumulative precipitation

Description

Thes functions is a wrapper for the Savitzky-Golay polynomial filter function sgolayfilt from the package signal. It passes the specified cumulative precipitation data, the filter length, the filter order (set to 1) and the derivative order (set to 0) to the filter. It is a good idea to use weighingGaugePlot to look at your data before and after calling this function. Note that this function is only intended to be used with very high frequency (i.e. 1 minute) gauged data, and should not be used with longer-period accumulations.

Usage

weighingGauge3(
  obs,
  precipCol = 1,
  filterLength = 0,
  polynomial_order = 1,
  quiet = TRUE,
  logfile = ""
)

Arguments

obs

Required. A standard CRHMr obs file.

precipCol

Optional. The number of the column containing the weighing guage cumulative precipitation data, not including the datetime. Default is column 1. This function can only work on 1 column of precipitation.

filterLength

Required. The number of time intervals used by the Savitzky-Golay polynomial filter. Note that this must be an ODD number. The appropriate value will depend on the type of your data, and the noise present.

polynomial_order

Optional. The order of the polynomial for the filter. Defaults to 1 by ECCC recommendation better smoothing is acheived with 3.

quiet

Optional. Suppresses display of messages, except for errors. If you are calling this function in an R script, you will usually leave quiet=TRUE (i.e. the default). If you are working interactively, you will probably want to set quiet=FALSE

logfile

Optional. Name of the file to be used for logging the action. Normally not used.

Value

If unsuccessful, returns FALSE. If sucessful, returns a modified version of the obs dataframe containing the adjusted precipitation values. Note that the name of the precipitation variable is modified: '_sg_filtered' is appended.

Note

This function is potentially destructive, as it smooths the accumulated precipitation. You may need to set the filter length by trial-and error. You can check the effects using the function weighingGaugePlot.

Author(s)

Kevin Shook

See Also

weighingGauge1 weighingGauge2 weighingGauge4 weighingGaugePlot weighingGaugeInterval

Examples

## Not run: 
test3 <- weighingGauge3(wg, filterLength=5)
## End(Not run)


CentreForHydrology/CRHMr documentation built on April 6, 2024, 5:27 p.m.