Skip to contents

Detects the sampling frequency of a precipitation zoo object with sfreq and dispatches to precipQC_daily or precipQC_subdaily. No files are written.

Usage

precipQC(
  x, metadata=NULL, station.id="station", coords=c("lon", "lat"), ...,
  elevation=NULL, elevation.scale=500,
  max.candidates=200L, selection.samples=2048L,
  verbose=TRUE, ncores=1L,
  parallel.type=c("socket", "fork", "serial"), cluster.nodes=NULL,
  from=start(x), to=end(x)
)

Arguments

x

A univariate or multivariate numeric zoo object. Each column is one precipitation station and must have a unique name.

metadata, station.id, coords, elevation, elevation.scale

Optional station metadata, field-name selectors, and elevation-decay control passed to the selected workflow. See precipQC_daily.

...

Arguments passed unchanged to the selected QC function. Because the daily and sub-daily functions have resolution-specific arguments, only arguments accepted by the detected workflow should be supplied. This includes max.suspicious, the maximum proportion of finite observations that may be confirmed as suspicious before a station is recommended for discard; see precipQC_daily and precipQC_subdaily.

max.candidates, selection.samples

Scalability controls passed to the selected workflow. See precipQC_daily.

verbose

Logical. If TRUE, informative messages report the detected frequency, the active QC stages, parallel workers/nodes, spatial scales, and the final QC summary. If FALSE, these informational messages are suppressed; warnings and errors are unaffected.

ncores

Positive integer giving the total requested number of worker R processes, across all machines rather than per machine. The effective number is capped at the number of station columns. ncores=1L uses the serial path and does not create a cluster. See precipQC_daily.

parallel.type

Parallel backend passed to the selected workflow: "socket", "fork", or "serial". Network hosts can be used only with "socket". See precipQC_daily.

cluster.nodes

NULL to place all socket workers on the local machine, or a character vector of host names on which PSOCK workers will be started. This argument selects worker locations; it does not set their number. Host names are recycled to the effective ncores. See precipQC_daily.

from, to

Starting and ending index bounds used to subset x before frequency detection and QC. They default to the complete record. See precipQC_daily.

Details

sfreq(x) returning "daily" selects precipQC_daily(x, ...). Values "minute" and "hourly" select precipQC_subdaily(x, ...). Weekly, monthly, quarterly, annual, or other frequencies are rejected with an informative error because the implemented thresholds and tests are not valid at those resolutions. Progress is emitted with message(), so it can be captured or suppressed without redirecting returned values. The default ncores=1L is serial and preserves the historical behaviour. When checks is not supplied through ..., spatial QC is enabled by default only when metadata is supplied. Spatial QC caches compact geographic/elevation candidate lists and symmetric pair statistics, reuses one precipitation neighbour graph across accumulation scales and the dry-spell check, and processes station-time calculations in bounded row blocks. Non-native accumulation scales retain flags only. With a PSOCK backend, large read-only data are broadcast once per worker. Setting max.candidates=Inf or selection.samples=Inf requests the corresponding exhaustive legacy-style selection.

Value

An object of class "precipQC"; see precipQC-class.

Author

Mauricio Zambrano-Bigiarini, mzb.devel@gmail.com

Examples

dates <- seq(as.Date("2020-01-01"), by="day", length.out=40)
x <- zoo(cbind(A=rep(0, 40), B=rep(0, 40)), dates)

qc <- precipQC(
  x, min.years=0,
  checks=c(climatology=FALSE, spatial=FALSE, dryspell=FALSE,
           breakpoint=FALSE)
)
#> [precipQC] Detected daily data; dispatching to precipQC_daily() ...
#> [precipQC] Starting daily QC for 40 observations at 2 station(s) ...
#> [precipQC] Using serial backend with 1 worker(s) across 1 node(s): runnervm0hi8g.
#> [precipQC] Running physical-range check ...
#> [precipQC] Running copied-block check ...
#> [precipQC] Running frequent-value check ...
#> [precipQC] Running distribution-gap check ...
#> [precipQC] Running persistence check ...
#> [precipQC] Running accumulated-total check ...
#> [precipQC] Running weekday false-zero check ...
#> [precipQC] Combining evidence and station recommendations ...
#> [precipQC] Completed daily QC: 2 accepted, 0 discarded; 0 flagged observation(s), 0 confirmed rejection(s).
qc$settings$resolution
#> [1] "daily"