
Temporal and spatial quality control in hydroTSM
Daily and sub-daily precipitation, air temperature, and streamflow
Mauricio Zambrano-Bigiarini
2026-11-20
Source:vignettes/hydroTSM_QC_temporal_spatial_tests.Rmd
hydroTSM_QC_temporal_spatial_tests.RmdPurpose and scope
This vignette summarises the quality-control (QC) tests implemented
by the frequency-aware precipQC(), tempQC(),
and streamflowQC() workflows in hydroTSM.
Each wrapper detects the input frequency with sfreq() and
dispatches daily data to its _daily() function and minute
or hourly data to its _subdaily() function. The input must
be a univariate or multivariate numeric zoo object with one
uniquely named station per column.
The workflows are deliberately conservative. A statistical anomaly is
not automatically treated as an error: individual tests produce
auditable flags, the evidence-combination stage classifies observations
as review or reject, and a separate
station-level decision recommends accept or
discard. Every test can be activated or deactivated
through the named checks argument. Spatial QC is enabled by
default only when metadata is provided, although users may
explicitly enable correlation-only spatial QC without coordinates.
In-memory contract. The QC functions do not write files. They return flags, suspicious-point tables, station summaries, accepted/discarded metadata, accepted
zooseries, corrected acceptedzooseries, spatial diagnostics when available, and all resolved settings.
Workflow map
In the following table, Yes means that the test is active by default, Metadata means that it defaults to active only when station metadata are supplied, Adjunct means that a separate function is available but is not called automatically, and an em dash means that the workflow does not apply that test.
| Test family | Precipitation daily | Precipitation sub-daily | Temperature daily | Temperature sub-daily | Streamflow daily | Streamflow sub-daily |
|---|---|---|---|---|---|---|
| Index, frequency, and station-name validation | Yes | Yes | Yes | Yes | Yes | Yes |
| Physical range | Yes | Yes | Yes | Yes | Yes | Yes |
| Copied month/year blocks | Yes | — | Yes | — | Yes | — |
| Clustered frequent values | Yes | — | — | — | — | — |
| Distribution gap | Yes | — | — | — | — | — |
| Missing-interval gap | — | — | — | — | Yes | Yes |
| Seasonal climatology | Yes | Yes | Yes | Yes | Yes | Yes |
| Persistence or flat line | Yes | Yes | Yes | Yes | Yes | Yes |
| Isolated spike/dip | — | — | Yes | Yes | Yes | Yes |
| Rate of change | — | — | Yes | Yes | Yes | Yes |
| Rapid fluctuation | — | — | — | — | — | Yes |
| Misplaced accumulation | Yes | Yes | — | — | — | — |
| Systematic weekday false zero | Yes | Yes | — | — | — | — |
| Extreme/high-flow diagnostics | Climatology | Climatology | — | — | Yes | Yes |
| Spatial consistency/regression | Metadata | Metadata | Metadata | Metadata | Metadata | Metadata |
| Spatially inconsistent dry spell | Yes | Yes | — | — | — | — |
| Homogeneity breakpoint | Yes | Yes | Yes | Yes | Yes | Yes |
| Paired Tmin/Tmax consistency | — | — | Adjunct | Adjunct | — | — |
Shared validation, metadata, and decision rules
Structural and temporal validation
All workflows reject non-numeric data, duplicated or non-increasing
timestamps, empty or duplicated station names, unsupported index
classes, and incompatible frequencies. Daily workflows accept
Date or POSIXt indices and calculate
completeness across the calendar span. Sub-daily workflows require a
POSIXt index; gaps are allowed only when their duration is
an integer multiple of the modal interval. The optional
from and to arguments subset the in-memory
record before completeness, thresholds, spatial models, and station
decisions are calculated.
Station metadata and incomplete coordinates
Metadata are supplied as a data frame. Users identify the station,
longitude, latitude, and optional elevation fields with
station.id, coords, and
elevation; streamflow may additionally identify a
catchment-area field with area. Rows are matched to
colnames(x), so their incoming order is irrelevant. A
station is geographically located only when both longitude and latitude
are finite. Missing either coordinate does not disable QC:
- a located target applies the distance filter and prefers eligible located neighbours;
- an unlocated target uses deterministic correlation-based candidate screening;
- an unlocated candidate remains a conservative fallback for a located target;
- optional elevation similarity reduces the suitability and weight of stations with very different heights; and
- streamflow area metadata allow regressions in specific-discharge space before estimates are converted back to the target station’s units.
Spatial scalability
Spatial tests use compact target-specific candidate lists rather than
dense station-by-station distance matrices.
max.candidates=200L bounds the pool retained for exact
selection, and selection.samples=2048L bounds the
deterministic, evenly spaced time sample used for initial neighbour
screening. Final estimates and flags always use the full record. Setting
either control to Inf requests the corresponding exhaustive
behaviour. Work can be distributed with ncores,
parallel.type ("serial",
"socket", or "fork"), and optional
cluster.nodes.
Evidence and station recommendations
The workflows distinguish hard tests from tests that normally require corroboration:
- precipitation daily treats range, copied blocks, clustered frequent values, distribution gaps, persistence, misplaced accumulation, and spatially corroborated dry spells as hard evidence; sub-daily precipitation treats range, persistence, daily/monthly accumulation, and dry spells as hard;
- temperature daily treats range, copied blocks, persistence, and spikes as hard; sub-daily temperature treats range, persistence, and spikes as hard;
- streamflow daily treats range and copied blocks as hard, while sub-daily streamflow treats only range as hard because real operations and flashy catchments can resemble statistical errors.
Non-hard flags are confirmed when at least min.evidence
independent test families agree. Station recommendations additionally
use missing, review, confirmed-suspicious, record-duration, and optional
breakpoint criteria. The default correction is "none";
"set_na" removes confirmed points, and
"spatial" substitutes an available spatial estimate and
otherwise uses NA.
Precipitation QC
The precipitation design combines gross-error, temporal, climatological, and neighbour-consistency checks used in operational rain-gauge QC (Hamada et al. 2011; Scherrer et al. 2011; Lewis et al. 2021; El Hachem et al. 2022).
Daily precipitation
| Check key and function | Default behaviour | What is flagged |
|---|---|---|
range — precipQC_range()
|
lower=0, upper=1825 mm
d
|
Negative values or values above the configured physical limit. The upper default is a conservative 24-hour record screen, not a regional design threshold. |
duplicate — precipQC_duplicate()
|
At least 20 paired month positions or 300 paired year positions, with at least three wet values | Entire calendar months or years copied exactly at corresponding positions (Durre et al. 2010). |
frequency — precipQC_frequency()
|
Consecutive wet reports with 9/10, 8/10, 7/10, or 5/10 identical values, screened by 0.3, 0.5, 0.7, or 0.9 climatological probabilities | Suspicious clustering caused by rounding, coding, or repeated manual entries (Durre et al. 2010). |
gap — precipQC_gap()
|
A gap of at least 300 mm in a calendar-month wet-value distribution | Values in the separated upper tail above the first large distribution gap (Durre et al. 2010). |
climatology — precipQC_climatology()
|
15-day circular day-of-year window; probability 0.999; robust score 8; at least 30 samples | Upper extremes beyond both an empirical quantile and a robust
iterative log1p median/MAD limit. |
persistence — precipQC_persistence()
|
Five identical consecutive values of at least 10 mm d | Repeated high values consistent with stuck, copied, or artificial reports. |
accumulation —
precipQC_accumulation()
|
Candidate exceeds twice the station mean wet-day depth and follows a missing previous day | A multi-day amount plausibly assigned to one daily timestamp. It is a candidate flag, not proof of accumulation. |
weekday — precipQC_weekday()
|
At least 20 wet days in a station-year; chi-squared
alpha=0.001; observed/expected ratio at most 0.5 |
Dry reports on a strongly under-recorded weekday, targeting systematic false zeros in manually observed networks (Estevez et al. 2022). |
breakpoint — precipQC_breakpoint()
|
Pettitt tests on annual total, wet-day count, maximum, and extreme-day count; Holm adjustment | A station-level homogeneity change. It is diagnostic and does not
discard a station unless discard.breakpoint=TRUE (Stepanek et al.
2009). |
The daily spatial test is applied to rolling 1-, 3-, and 7-day totals
by default. One native-scale neighbour graph is selected with Spearman
correspondence on log1p precipitation and reused at every
scale. For each target and time, precipQC_spatial()
calculates an ordinary or distance/elevation-weighted neighbour median.
The critical ratio divides the positive transformed residual by the
larger of simultaneous neighbour dispersion, historical residual
dispersion, and a numerical floor. An accumulation endpoint flag is
expanded to all contributing daily values. Multi-scale testing prevents
an error hidden at one accumulation from being missed at another (El
Hachem et al. 2022).
precipQC_dryspell() separately examines default 15-day
target dry windows. A window is flagged when the requested neighbour
fraction (default 1) records at least three wet days. This targets false
zeros or missing rainfall that an upper-outlier test cannot detect (Lewis et
al. 2021; Golkhatmi and Farzandi
2024).
Sub-daily precipitation
| Check key | Default behaviour and difference from daily QC |
|---|---|
range |
The upper limit is max.rate=401 mm
h
multiplied by the detected interval duration; negative depths are
invalid (Lewis et al. 2021). |
climatology |
Month-specific log1p limits use probability 0.999,
robust score 8, and at least 100 observations. |
persistence |
Two identical high values are suspicious. When no high threshold is supplied, it is twice the station mean wet-day depth. Any identical wet value persisting for 24 hours is also flagged. |
daily.accumulation |
A large interval is screened against 23 dry hours before and after it. |
monthly.accumulation |
A large interval is screened against 28 preceding dry days and 23 following dry hours. |
weekday |
Native values are first aggregated to daily totals only when at least 90% of expected intervals are present; daily weekday flags are expanded back to finite dry native intervals. |
breakpoint |
Native precipitation is aggregated to daily totals before the annual multi-indicator Pettitt analysis. |
Spatial consistency is evaluated at the native interval and 1, 3, 6,
and 24 hours by default. Positive durations must be exact multiples of
the detected interval. Accumulated flags are expanded back to their
contributing native observations. The same 15-day dry-spell logic is
applied after in-memory daily wet/dry aggregation. Raw tipping-bucket
inter-tip checks cannot be reconstructed from already accumulated
zoo values; they require the original tip timestamps (Villalobos-Herrera et al. 2022).
Air-temperature QC
Temperature QC combines physical limits, robust seasonal references, temporal consistency, spatial regression, and homogeneity diagnostics (Durre et al. 2010; Feng et al. 2004; Hubbard et al. 2007; Brunet et al. 2020).
Daily air temperature
| Check key and function | Default behaviour | What is flagged |
|---|---|---|
range — tempQC_range()
|
to degrees C | Values outside global physical screening limits. Regional limits should be supplied when authoritative. |
duplicate — tempQC_duplicate()
|
At least 20 paired month or 300 paired year positions | Exactly copied complete months or years (Durre et al. 2010). |
climatology — tempQC_climatology()
|
Circular 15-day day-of-year window; robust absolute score 6; at least 100 samples | Values far from the local seasonal median relative to MAD/IQR dispersion (Feng et al. 2004; Durre et al. 2010). |
persistence — tempQC_persistence()
|
Seven observations with range no greater than zero | Exact flat lines consistent with a stuck sensor.
persistence.tolerance can admit near-flat lines. |
step — tempQC_step()
|
Month-specific first differences; robust score 3; at least 20 differences | Implausible consecutive-day changes; optional absolute rise/fall limits may also be imposed (Hubbard et al. 2007). |
spike — tempQC_spike()
|
Centre value at least 25 degrees from both neighbours in the same direction | An isolated spike or dip (Durre et al. 2010). |
breakpoint — tempQC_breakpoint()
|
Pettitt tests on sufficiently complete annual means and standard
deviations; at least 10 years; Holm-adjusted alpha=0.05;
shift at least 1 degree |
A station-level homogeneity change, diagnostic by default (Boulanger et al. 2010; Brunet et al. 2020). |
tempQC_spatial() selects up to five neighbours using
overall Pearson correlation and proximity-adjusted target-on-neighbour
regression error. It fits separate monthly regressions, combines their
predictions with geographic/elevation proximity and
inverse-error-variance weights, and flags a target only when both the
absolute residual (default 8 degrees) and the standardised residual
(default 4) are large. Pairwise intercepts estimate persistent station
offsets without imposing a universal lapse rate. This is a resistant
spatial-regression-test implementation for complex terrain (Hubbard et al. 2007; Estevez et al. 2018; Xiong et al. 2022,
2024).
Sub-daily air temperature
| Check key | Default behaviour and difference from daily QC |
|---|---|
range |
Uses the same configurable physical limits as daily temperature. |
climatology |
References are conditioned jointly on calendar month and hour; the robust score is 6 with at least 30 samples. |
persistence |
A range no greater than 0.05 degrees across a default three-hour duration is flagged; the observation count is derived from the detected interval (Beele et al. 2022). |
step |
Month-hour first differences use robust score 5 and at least 30 samples. |
spike |
The isolated spike/dip threshold is 12 degrees. |
spatial |
Regressions are fitted separately by month and hour, with minimum absolute residual 5 degrees, standardised residual 4, and preferred correlation at least 0.7 (Cheng et al. 2016). |
breakpoint |
Native observations are aggregated to daily means before annual homogeneity analysis. |
When paired Tmin and Tmax series are available, the adjunct
tempQC_internal() flags Tmin greater than Tmax, possible
interchange relative to the previous/current/following-day window, and
excessive lagged separation. This test is intentionally separate because
a single generic temperature matrix cannot reveal which member of an
inconsistent Tmin/Tmax pair is wrong.
Streamflow QC
Streamflow QC is cautious about hydrologically real extremes, intermittent zeros, regulation, tidal behaviour, and rapidly responding catchments. It therefore keeps physical impossibilities separate from statistical evidence and combines correlated high-flow diagnostics into one evidence family (Gudmundsson et al. 2018; Crochemore et al. 2020; U.S. Integrated Ocean Observing System 2018).
Daily streamflow
| Check key and function | Default behaviour | What is flagged |
|---|---|---|
range — streamflowQC_range()
|
lower=0, upper=Inf
|
Negative/non-finite non-missing discharge and optional station-specific upper-limit violations. |
duplicate — streamflowQC_duplicate()
|
At least 20 paired month or 300 paired year positions and one positive value | Exactly copied calendar blocks; all-zero intermittent-flow blocks are protected by default. |
gap — streamflowQC_gap()
|
Expected interval one day | The first finite observation after a missing value or missing calendar interval. |
climatology —
streamflowQC_climatology()
|
log(Q + 0.01); circular five-day window; mean
plus/minus six standard deviations; at least 30 samples |
Seasonally implausible low or high flow following the GSIM structure (Gudmundsson et al. 2018). |
flatline — streamflowQC_flatline()
|
More than 10 equal positive daily values (run=11);
zeros protected |
Extended constant or near-constant flow. |
spike — streamflowQC_spike()
|
Factor-five reversal or change larger than the station 0.99 quantile | An isolated peak or dip. |
rate — streamflowQC_rate()
|
Monthly robust log-difference score 6, optional absolute limits, and factor-five abrupt fall | Implausible consecutive changes. |
highflow — streamflowQC_highflow()
|
Global log-flow score 6; largest/second-largest AMAX ratio 2; GEV return period 1000 years after at least 10 annual maxima | Exceptionally high flows. Component flags and return-period diagnostics are retained, but they count as one evidence family. |
breakpoint —
streamflowQC_breakpoint()
|
Pettitt tests on annual mean, standard deviation, minimum, and
maximum; at least 10 years; Holm alpha=0.01; relative
change at least 0.5 |
A station-level change that may indicate measurement change, regulation, or catchment change. |
The daily spatial test selects up to five neighbours using Spearman correlation on log flow plus optional distance/elevation proximity. With area metadata, target-on-neighbour models operate on specific discharge. A target event must exceed its 0.99 quantile, have a spatial residual score of at least 3, and lack the required neighbour support (default one neighbour above its 0.95 quantile) within three days before or after the event. Thus a genuine regional flood is corroborated rather than rejected solely because it is extreme.
Sub-daily streamflow
| Check key | Default behaviour and difference from daily QC |
|---|---|
range |
Uses the same non-negative physical rule and optional upper limit. |
gap |
The expected interval is the detected modal interval in seconds. |
climatology |
Month-specific log(Q + 0.01) limits use score 6 and at
least 100 observations. |
flatline |
Ordinary flat lines use 168 hours; high-flow flat lines above the 0.99 quantile use 24 hours. Durations are converted to observation counts. |
spike |
Uses the same factor-five/0.99-quantile isolated-reversal logic. |
rate |
Monthly log-difference score 6, optional absolute limits, and factor-five abrupt fall. |
fluctuation —
streamflowQC_fluctuation()
|
More than eight derivative sign reversals in 16 observations after suppressing changes below the 0.05 absolute-difference quantile |
highflow |
Native values feed the same log-flow, AMAX-ratio, and GEV diagnostics. |
breakpoint |
Native values are aggregated to daily means before annual Pettitt tests. |
Sub-daily spatial event support uses a default 72-hour window rather than a fixed observation count. The target and neighbour quantiles, regression score, specific-discharge option, and conservative lack-of-support rule otherwise match the daily formulation. These rules generalise operational sub-daily flow QC to the actual modal interval (Fileni et al. 2023; Zhao et al. 2018).
Basic reproducible workflow
The following daily examples use the three frequency-aware wrappers.
Each dataset contains two plausible stations and one station named
S_bad with a deliberately impossible observation. The
examples activate only the tests needed to identify that observation,
disable spatial checking, and run serially so that they remain fast and
deterministic during vignette builds. The deliberately strict
max.suspicious=0 then makes one confirmed suspicious
observation sufficient to demonstrate a station-level discard. These
settings are pedagogical; production analyses should retain relevant
default tests and choose acceptance limits appropriate to the
network.
Shared station metadata
The metadata row order need not match the data-column order, but
identifiers must match colnames(x). Elevation is included
here to show the expected interface; it would be used when spatial
checks are active.
Run precipitation QC
Here a negative daily precipitation value is a confirmed physical-range failure. All checks are named explicitly because omitted names retain their workflow defaults.
# Construct plausible series and insert one impossible precipitation value.
p.values <- cbind(
S_good_1=rep(c(0, 1, 0, 3), 10),
S_good_2=rep(c(0, 2, 0, 4), 10),
S_bad=rep(c(0, 1.5, 0, 2.5), 10)
)
p.values[10, "S_bad"] <- -1
precipitation <- zoo::zoo(p.values, dates)
# Isolate the physical-range test for this basic example.
p.checks <- c(range=TRUE, duplicate=FALSE, frequency=FALSE, gap=FALSE,
climatology=FALSE, persistence=FALSE, accumulation=FALSE,
weekday=FALSE, spatial=FALSE, dryspell=FALSE,
breakpoint=FALSE)
p.qc <- precipQC(
precipitation, metadata=metadata, checks=p.checks, min.years=0,
max.missing=1, max.suspicious=0, verbose=FALSE,
parallel.type="serial"
)Run air-temperature QC
The impossible temperature is also an isolated spike, so two test names will appear in the audit trail for the same observation.
# Construct smooth temperature series and insert one isolated extreme.
t.base <- 15 + sin(seq_along(dates) / 5)
t.values <- cbind(S_good_1=t.base, S_good_2=t.base + 0.5,
S_bad=t.base - 0.5)
t.values[20, "S_bad"] <- 100
temperature <- zoo::zoo(t.values, dates)
# Retain range and spike checks to demonstrate overlapping evidence.
t.checks <- c(range=TRUE, duplicate=FALSE, climatology=FALSE,
persistence=FALSE, step=FALSE, spike=TRUE,
spatial=FALSE, breakpoint=FALSE)
t.qc <- tempQC(
temperature, metadata=metadata, checks=t.checks, min.years=0,
max.missing=1, max.suspicious=0, verbose=FALSE,
parallel.type="serial"
)Run streamflow QC
Streamflow uses the same wrapper pattern. max.review=1
prevents the separate review-fraction rule from obscuring the
deliberately tested rejection rule.
# Construct positive streamflow series and insert one impossible value.
q.base <- 5 + 0.2 * sin(seq_along(dates) / 4)
q.values <- cbind(S_good_1=q.base, S_good_2=q.base + 0.3,
S_bad=q.base - 0.2)
q.values[30, "S_bad"] <- -1
discharge <- zoo::zoo(q.values, dates)
# Isolate the physical-range test for this basic example.
q.checks <- c(range=TRUE, duplicate=FALSE, gap=FALSE,
climatology=FALSE, flatline=FALSE, spike=FALSE,
rate=FALSE, highflow=FALSE, spatial=FALSE,
breakpoint=FALSE)
q.qc <- streamflowQC(
discharge, metadata=metadata, checks=q.checks, min.years=0,
max.missing=1, max.review=1, max.suspicious=0, verbose=FALSE,
parallel.type="serial"
)Inspect results and audit a discarded station
Printing a result gives the main counts. The detailed station
decision is in station.summary; the same diagnostic columns
are appended to accepted.metadata and
discarded.metadata. The original and corrected accepted
series are in accepted.data and
accepted.corrected, respectively.
# Print concise summaries for all three variables.
p.qc## Precipitation quality-control result
## resolution : daily
## stations : 3
## accepted : 2
## discarded : 1
## review data: 1
## rejected : 1
t.qc## Air-temperature quality-control result
## resolution : daily
## stations : 3
## accepted : 2
## discarded : 1
## review data: 1
## rejected : 1
q.qc## Streamflow quality-control result
## resolution : daily
## stations : 3
## accepted : 2
## discarded : 1
## review data: 1
## rejected : 1
# Inspect the decision and contributing tests for every precipitation station.
audit.columns <- c("station", "recommendation", "reason",
"suspicious.count", "suspicious.percent",
"suspicious.tests")
p.qc$station.summary[, audit.columns]## station recommendation
## S_good_1 S_good_1 accept
## S_good_2 S_good_2 accept
## S_bad S_bad discard
## reason suspicious.count
## S_good_1 within acceptance limits 0
## S_good_2 within acceptance limits 0
## S_bad suspicious fraction exceeds limit (tests: range) 1
## suspicious.percent suspicious.tests
## S_good_1 0.000 <NA>
## S_good_2 0.000 <NA>
## S_bad 0.025 range
# Inspect the returned station partitions and point-level precipitation audit.
colnames(p.qc$accepted.data)## [1] "S_good_1" "S_good_2"
p.qc$discarded.metadata[, audit.columns]## station recommendation reason
## S_bad S_bad discard suspicious fraction exceeds limit (tests: range)
## suspicious.count suspicious.percent suspicious.tests
## S_bad 1 0.025 range
p.qc$suspicious## time station original spatial.estimate spatial.score n.tests tests
## 1 2020-01-10 S_bad -1 NA NA 1 range
## action corrected correction
## 1 reject -1 none
There are three related, but distinct, levels in that output:
-
flagsrecords whether each individual test flagged each observation. -
suspiciousrecords every flagged observation and labels its combined action as"review"or"reject";rejectedis the corresponding logicalzoomask for confirmed rejections. -
station.summaryapplies the station acceptance limits and recommends"accept"or"discard".
For a particular discarded station, first read reason
and suspicious.tests, then select its observation rows from
suspicious. This shows both why the station crossed an
acceptance limit and which tests flagged each underlying
observation.
# Select one station and inspect its station-level decision.
target.station <- "S_bad"
t.qc$station.summary[
t.qc$station.summary$station == target.station, audit.columns
]## station recommendation
## S_bad S_bad discard
## reason suspicious.count
## S_bad suspicious fraction exceeds limit (tests: range, spike) 1
## suspicious.percent suspicious.tests
## S_bad 0.025 range, spike
# Inspect every flagged observation and its combined review/reject action.
t.qc$suspicious[t.qc$suspicious$station == target.station, ]## time station original spatial.estimate spatial.score n.tests
## 1 2020-01-20 S_bad 100 NA NA 2
## tests action corrected correction
## 1 range, spike reject 100 none
# Count confirmed observations attributable to each individual test.
confirmed <- as.matrix(zoo::coredata(t.qc$rejected))[, target.station]
test.counts <- setNames(integer(length(t.qc$flags)), names(t.qc$flags))
for (test in names(t.qc$flags)) {
test.flag <- as.matrix(zoo::coredata(t.qc$flags[[test]]))[, target.station]
test.counts[test] <- sum(test.flag & confirmed, na.rm=TRUE)
} # FOR test end
sort(test.counts[test.counts > 0L], decreasing=TRUE)## range spike
## 1 1
The temperature example reports one confirmed observation for both
range and spike. Therefore, per-test counts
can sum to more than suspicious.count: several tests may
identify the same rejected observation. Replace t.qc with
p.qc or q.qc to apply the same audit to
precipitation or streamflow. The standard plot method provides a compact
graphical overview.
# Plot station decisions, affected stations, test counts, and rejection times.
plot(t.qc)
Temperature QC summary for the reproducible example.
Activating and deactivating tests
Names omitted from checks retain their workflow
defaults. This allows a small override rather than restating the
complete vector:
# Keep daily precipitation defaults but disable weekday and breakpoint tests.
p.qc <- precipQC_daily(
precipitation, metadata=metadata,
checks=c(weekday=FALSE, breakpoint=FALSE)
)
# Explicitly enable correlation-only spatial temperature QC without metadata.
t.qc <- tempQC_daily(
temperature,
checks=c(spatial=TRUE),
ncores=4, parallel.type="socket"
)
# Retain streamflow temporal tests but disable high-flow and spatial evidence.
q.qc <- streamflowQC(
discharge,
checks=c(highflow=FALSE, spatial=FALSE)
)Thresholds should be adapted when authoritative regional limits, instrument resolution, catchment behaviour, or network operating practices are known. The defaults are screening values grounded in the cited literature; they are not universal proof that an observation is wrong.
Returned audit trail
The three result classes share a common audit structure:
-
accepted.metadataanddiscarded.metadatapreserve user metadata; -
accepted.datacontains accepted station series without modification; -
accepted.correctedapplies the requested correction only to accepted stations; -
flagsretains every enabled point-level test separately; -
suspiciouslists station, timestamp, value, contributing tests, evidence, and action; -
station.summaryrecords completeness, review/rejection fractions, record length, breakpoint evidence, and recommendation; - spatial estimates, scores, neighbours, and streamflow event-support counts remain available when spatial QC ran; and
-
settingsrecords the resolved thresholds, subset bounds, and parallel backend for reproducibility.
Plots from plot.precipQC(), plot.tempQC(),
and plot.streamflowQC() summarise station recommendations,
the most affected stations, flags by test, and the timing of confirmed
suspicious observations.
Limitations
These workflows evaluate the zoo observations and
metadata supplied to them. They cannot reconstruct logger diagnostics,
raw tipping-bucket tip times, rating-curve revisions, maintenance logs,
observer notes, or upstream operations that are absent from those
inputs. Spatial agreement is also not independence: common radar
adjustments, shared telemetry, regional storms, or basin-wide regulation
can affect several stations together. Final rejection and correction
decisions should therefore retain the audit trail and, for high-impact
records, include expert review.