9 Patterns and Templates
9.1 How to use pattern cards
Treat each card as a do-this-exactly runbook for a common scenario.
Each card tells you:
- when to use it,
- which layers it produces,
- which inputs are hard-coded or conditional,
- which intermediate artifacts must be reviewed,
- what to escalate.
9.2 Pattern Card 1 — Fraser Sockeye (dual stream layers + targeted gap fills)
9.2.1 Use when
- Species is Fraser Sockeye
- You need CU outputs plus pop/context outputs aligned with current production practice
- You expect CU-specific gap-fill logic and decoder-heavy matching
9.2.2 Repo and script
- Repo:
FRSK-WSPDataPrep - Script:
CODE/Prep4_CleanedFlatFile_Fraser_Sk_KDEdits2024.R
9.2.4 Required inputs
DATA_IN/SKAll (Nov YYYY).csvDATA_IN/Fraser Sockeye SR Data_YYYY.csvDATA_IN/Sockeye_Fraser_CU_Streams.csvDATA_IN/Sockeye_Fraser_SR_Streams.csvDATA_IN/Sockeye_Fraser_Expansion_Years.csvDATA_LOOKUP_FILES/MOD_MAIN_CU_LOOKUP_FOR_SOS.csvDATA_LOOKUP_FILES/Site_Info_GeneratedDecoder_Fraser_Sk.csv
9.2.5 Important notes before run
- Check whether the script expects literal file names.
- Keep trend-layer and abundance-layer stream lists distinct.
- Open the exception register before running; you will probably need it.
9.3 Pattern Card 2 — Interior Fraser Coho (WSP-only CU layer + all-stream pop layer)
9.3.1 Use when
- Species is Interior Fraser Coho
- You need CU outputs, pop outputs, and brood-year / decomposition support
9.3.2 Repo and scripts
- Repo:
FRCo-WSPDataPrep - Scripts:
CODE/SUB_Data extraction and clean up (Coho for now)_2023.RCODE/Prep5_CleanedFlatFile_Fraser_Coho.R
9.3.4 Required inputs
- latest
DATA_IN/IFC Data 1975-<year> ... for Salmon Scanner.csv DATA_IN/FRSK_CU_Info_masterUpdate.csvDATA_IN/Fraser Coho POPID Lookup...csvDATA_LOOKUP_FILES/MOD_MAIN_CU_LOOKUP_FOR_SOS.csvDATA_IN/IFC Infill exceptions.csvonly if the active path actually uses it
9.3.5 Important notes before run
- Document whether the CU layer is WSP-only and the pop layer is all-stream.
- Confirm how
Final.Estimate.Type == "NO"is treated. - Treat decomposition tables as QC evidence, not as optional extras.
9.4 Pattern Card 3 — Lower Fraser Chum (major-system CU layer with expected CU/pop non-equality)
9.4.1 Use when
- Species is Lower Fraser Chum
- You need the production CU layer and pop representation built from major systems and Harrison logic
9.4.3 Required inputs
DATA_IN/FR Chum Major Systems.csvDATA_IN/Harrison Chum Escapement Summary.csvDATA_IN/Chum extensive pivot.csvDATA_IN/FR Chum POPID Crosswalk.csv
9.4.4 Important notes before run
- Do not expect CU totals to equal the sum of pop rows.
- Review any row-name / unnamed-column CSV behaviour before downstream use.
- Log the Harrison and Squawkum handling explicitly.
9.5 Pattern Card 4 — Fraser Pink (official CU series + historical context layer)
9.5.1 Use when
- Species is Fraser Pink
- You need the official CU series plus the historical NuSEDS-based pop/context layer
9.5.3 Required inputs
DATA_IN/Fraser Pink esc_rec CU.csvDATA_IN/FR_Pink_Conservation_Unit_Data_NUSEDs_June 2023.csv
9.5.4 Important notes before run
- Keep the official CU series authoritative across the whole time series.
- Treat the historical NuSEDS layer as context, not as a replacement CU series.
- Review the Fraser aggregate pop row separately from ordinary pop rows.
9.6 Pattern Card 5 — CU/WSP bundle handoff
9.6.1 Use when
- final CU outputs passed release QC,
- you need a stable handoff for metrics, packaging, or another consumer.
9.6.2 Required inputs
cu_timeseries.csvwsp_metric_specs.csv- optional
wsp_cyclic_benchmarks.csv - optional
cu_metadata.csv - sidecars:
run-log.md,decision-log.md,qc-summary.md,metadata_notes.md