Stamp sample.station_uuid: the SWFSC station occupation an event belongs to
Source: R/keys.R
match_station_occupation.RdEvery sample root (an event with no parent within its own dataset — a
bottle cast, a CTD cast, an ichthyo site, ...) is matched to the ichthyo
site row (its source_uuid) representing the same SWFSC station
occupation, in priority order:
self — the root itself IS an ichthyo site (
dataset_key = 'swfsc_ichthyo'): its ownsource_uuid.order_occ — exactly one ichthyo site shares
(cruise_key, site_key, order_occ).datetime — exactly one ichthyo site at
(cruise_key, site_key)has adatetimewithintolerance_hoursof the root's (whether it is the only candidate at all, or the only one inside the window).otherwise
NULL(station_uuid_methodNULLtoo).
The match is computed once per ROOT and copied to every row sharing its
root_sample_key, which is what makes the crab's examined subsamples
(parented DIRECTLY to an ichthyo site via parent_sample_key /
root_sample_key — they never enter the match SQL, whose roots CTE only
sees rows where sample_key = root_sample_key) inherit that site's
station_uuid for free, with no separate matching logic needed. Their
station_uuid_method is relabeled "parent" rather than "self" in
that copy step, purely so a consumer can tell "this row IS the SWFSC
station occupation" ("self", ichthyo's own site/tow/net) apart from "this
row is a foreign dataset's row directly under one" ("parent").