PcpFiltPosTh: Cleans up a cumulative precipitation time series

View source: R/PcpFiltPosTh.R

PcpFiltPosThR Documentation

Cleans up a cumulative precipitation time series

Description

Cleans up a cumulative precipitation time series by transferring changes below a specified threshold to neighbouring periods, and eliminating large negative changes associated with gauge servicing (bucket emptying). The filtering is done using a brute-force algorithm that identifies small or negative changes (below dPcpTh) then transfers them to neighbouring positive changes thus aggregating all changes to values above dPcpTh. The transfers are made in ascending order, starting with the lowest (most negative). The cumulative total remains unchanged. This description (and most of the comments in the code) were written by Alan Barr.

Usage

PcpFiltPosTh(Pcp, dPcpTh = 0.1, dpServicingTh = -100, quiet = TRUE)

Arguments

Pcp

Required. Measured cumulative precipitation (mm).

dPcpTh

Optional. Minimum interval precipitation (mm). Default is 0.1 mm.

dpServicingTh

Optional. Threshold for change in storage due to servicing (mm). Default is -100 mm.

quiet

Optional. Suppresses display of messages, except for errors. If quiet=FALSE, the output will pause for 5 seconds ever 100 iterations, which may be useful for debugging your parameters. If you are calling this function in an R script, you will usually leave quiet=TRUE (i.e. the default), which causes fewer parameters to be output, without pausing, every 1000 iterations.

Value

If unsuccessful, returns the value FALSE. If successful, returns a time series of cleaned values. Writes parameter values to screen.

Author(s)

Kevin Shook. The code is copied from a MATLAB program PcpFiltPosTh.m written by Alan Barr, 28 Aug 2012.

Examples

## Not run: 
testp <- PcpFiltPosTh(dl2$precip, dPcpTh = 0.05, dpServicingTh = -50)
## End(Not run)

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