
Generate Catch-Level Validation Flags
get_catch_flags.RdThis function validates catch-level data from KEFS surveys and generates alert flags for inconsistencies in sample weights relative to total catch weights. It focuses on submissions where catch outcome was "yes" and checks for logical inconsistencies in the relationship between sample weights and total weights.
Arguments
- dat
A data frame containing KEFS survey catch data with columns:
submission_id: Unique identifier for the submission
catch_outcome: Whether catch was recorded ("yes" or "no")
total_sample_weight: Total weight of all samples in kilograms
total_catch_weight: Total weight of the entire catch in kilograms
sample_weight: Weight of individual sample in kilograms
sample_price: Price of the sample
length_max_cm: Largest fish measured for the row's species, if any
- max_length_cm
Numeric. Absolute upper bound on
length_max_cm, in centimetres. Defaults to 500. The largest fish is tested rather than the mean, which one impossible fish among normal ones can stay under.
Value
A data frame with columns:
submission_id: The original submission identifier
alert_flag_catch: Comma-separated string of alert codes (NA if no alerts):
"5.1": Total sample weight exceeds total catch weight
"5.2": Individual sample weight exceeds either total sample weight or total catch weight
"5.3": Length exceeds
max_length_cm
alert_catches: For 5.2 and 5.3, the species sample each was raised on: its number in the form (
catch_number, 1 for the first species),code,speciesand thevaluerecorded. NULL when none was.
Details
The function only processes submissions where catch_outcome is "yes". It identifies two types of weight inconsistencies:
The sum of all samples exceeds the total reported catch
An individual sample weighs more than the total it's supposed to be part of
Alert 5.3 is an absolute ceiling, not a per-species check. Zanzibar and Mozambique bound length per taxon from FishBase morphometrics; Kenya has no morphometrics table, so there is no species-specific bound to apply here. The default only catches the physically impossible