Skip to contents

Detects the sampling frequency of a numeric zoo object and dispatches daily data to streamflowQC_daily or minute/hourly data to streamflowQC_subdaily. No files are written.

Usage

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

Arguments

x

A numeric zoo object with one streamflow station per column.

metadata

NULL, or a data.frame with one row per station.

station.id

Name of the station-identifier field in metadata.

coords

Names of longitude and latitude fields in metadata, in that order.

...

Arguments passed unchanged to the selected workflow. 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 streamflowQC_daily and streamflowQC_subdaily.

area

NULL, or the name of a positive numeric catchment-area field. Units may be chosen by the user but must be consistent among stations.

elevation

NULL, or the name of a numeric station-elevation field.

elevation.scale

Positive elevation-decay scale used in spatial neighbour ranking.

verbose

Logical. If TRUE, informative messages report the detected frequency, effective parallel workers and nodes, enabled QC stages, evidence combination, and final QC summary. If FALSE, these messages are suppressed; warnings and errors remain visible.

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 streamflowQC_daily.

parallel.type

Parallel backend passed to the selected workflow: "socket", "fork", or "serial". Network hosts can be used only with "socket". See streamflowQC_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 streamflowQC_daily.

from, to

Start and end of the period retained before frequency detection and quality control. Defaults retain the complete time span of x.

max.candidates

Maximum reusable spatial candidates retained per target station. The default limits work for large networks; Inf requests exhaustive legacy-style selection.

selection.samples

Maximum deterministic time positions used to select spatial neighbours. Final regressions and flags still use all observations. Use Inf for exhaustive selection.

Details

The wrapper changes only the resolution-specific workflow. Test activation, thresholds, station metadata, evidence requirements, correction policy, and station recommendations remain explicit user controls. Daily and sub-daily observations must be in consistent discharge units. Duplicate timestamps are rejected because selecting among contradictory measurements would require provenance or agency-quality information not contained in a numeric zoo object.

The selected from–to period is applied before sampling frequency is detected. In the selected daily or sub-daily workflow, spatial defaults to TRUE when metadata is supplied and to FALSE when it is NULL. An explicit named checks["spatial"] value always takes precedence.

The design combines the point plausibility and homogeneity principles of Gudmundsson et al. (2018), the real-time hierarchy of U.S. IOOS (2018), and the sub-daily artefact and event-corroboration framework of Fileni et al. (2026).

Progress is emitted with message(), so it can be captured or suppressed without redirecting the returned object. The default ncores=1L is serial and preserves the historical behaviour. When spatial QC is active, verbose output also reports the effective candidate and timestamp limits. Large PSOCK inputs are broadcast once per worker.

Value

An object of class "streamflowQC"; see streamflowQC_class.

References

Fileni, F. et al. (2026). UK-Flow15-QC: A quality control framework for better river flow data in hydrological research. EGUsphere preprint. doi:10.5194/egusphere-2026-277.

Gudmundsson, L., Do, H. X., Leonard, M. and Westra, S. (2018). The Global Streamflow Indices and Metadata Archive (GSIM) - Part 2: quality control, time-series indices and homogeneity assessment. Earth System Science Data, 10, 787–804. doi:10.5194/essd-10-787-2018.

U.S. Integrated Ocean Observing System (2018). Manual for Real-Time Quality Control of Stream Flow Data Version 1.0. doi:10.25923/gszc-ha43.

Examples

dates <- as.Date("2020-01-01") + 0:29
x <- zoo::zoo(cbind(A=10 + sin(seq_along(dates)),
                    B=12 + sin(seq_along(dates))), dates)
qc <- streamflowQC(
  x, checks=c(range=TRUE, duplicate=FALSE, gap=FALSE,
              climatology=FALSE, flatline=FALSE, spike=FALSE,
              rate=FALSE, highflow=FALSE, spatial=FALSE,
              breakpoint=FALSE),
  min.years=0, max.missing=1, max.review=1, max.suspicious=1
)
#> [streamflowQC] Detected daily data; dispatching to streamflowQC_daily() ...
#> [streamflowQC] Starting daily QC for 30 observations at 2 station(s) ...
#> [streamflowQC] Using serial backend with 1 worker(s) across 1 node(s): runnervm0hi8g.
#> [streamflowQC] Running physical-range check ...
#> [streamflowQC] Combining evidence and station recommendations ...
#> [streamflowQC] Completed daily QC: 2 accepted, 0 discarded; 0 flagged observation(s), 0 confirmed rejection(s).
qc$station.summary
#>   station expected observed missing.percent review.count review.percent
#> A       A       30       30               0            0              0
#> B       B       30       30               0            0              0
#>   suspicious.count suspicious.percent breakpoint.year breakpoint.indicator
#> A                0                  0              NA                 <NA>
#> B                0                  0              NA                 <NA>
#>   breakpoint.p.value breakpoint.relative.change breakpoint.n.indicators
#> A                 NA                         NA                       0
#> B                 NA                         NA                       0
#>   breakpoint.flag record.years recommendation                   reason
#> A           FALSE   0.08213552         accept within acceptance limits
#> B           FALSE   0.08213552         accept within acceptance limits
#>   suspicious.tests
#> A             <NA>
#> B             <NA>