Check hex7 on sample and sample_root against the positions and against the observations
Source: R/explore.R
check_sample_hex7.RdThe release gate for add_sample_hex7(). One row per rule and table:
Usage
check_sample_hex7(
con,
sample_tbl = "sample",
root_tbl = "sample_root",
obs_tbls = c("obs_bio", "obs_env")
)Arguments
- con
DuckDB connection.
- sample_tbl, root_tbl
the stamped
sampleand thebuild_sample_root()table.- obs_tbls
observation tables carrying
sample_key,latitude,longitude,hex7; those absent fromconare skipped.
Details
position_has_hex7—nrows with a finite position,n_badof them without ahex7;hex7_has_position—nrows with ahex7,n_badof them without a finite position. Together these two saycount(hex7)equals the count of finite positions, row for row;hex7_is_res7—nrows with ahex7,n_badwhose H3 resolution field is not 7;root_equals_sample—nroot samples (no parent),n_badroots whosehex7differs between the two tables, plus roots missing fromroot_tbl, plusroot_tblrows that are not a root sample;obs_same_position(per table ofobs_tblspresent) —nobservations sitting at exactly their own sample's position,n_badof them in another cell than their sample. This is the proof, on the data, that the sample side and the observation side share one definition;obs_other_cell—nobservations where both the row and its sample carry a cell,n_badin another cell than their sample. Reported, never a failure: an observation carries its own position (each scan of a CTD cast, a DIC draw), the sample carries the event's, and a cast that drifts across a cell edge puts some of its scans in the neighbouring hexagon.
A finite position is both coordinates present and neither NaN nor infinite. Needs no
extension: the resolution is read from the cell's own bits.