Audit distances in the master table – sanity v1.
auditDistances.RdFlags each row with the FIRST applicable reason from a fixed precedence: lat/lon NA, lat/lon out of range, depth negative, Repi above outlier threshold, Rhyp < Repi (geometric impossibility). Rows with no issue are dropped from the output.
Details
Does NOT read record.json or provider flatfiles. Comparison against
raw/flatfile distances is deferred to v2.
Examples
x <- data.table::data.table(
EventLatitude = c(0, 95),
EventLongitude = c(0, 0),
StationLatitude = c(0.1, 0.1),
StationLongitude = c(0.1, 0.1),
EventDepth = c(10, 10),
Repi = c(15, 20),
Rhyp = c(18, 25)
)
auditDistances(x)
#> EventLatitude EventLongitude StationLatitude StationLongitude EventDepth
#> <num> <num> <num> <num> <num>
#> 1: 95 0 0.1 0.1 10
#> Repi Rhyp Reason
#> <num> <num> <char>
#> 1: 20 25 eventLatOOR