From e146959761c222bd617305542eeefd527564baea Mon Sep 17 00:00:00 2001 From: luen Date: Tue, 3 Nov 2026 12:51:05 +1000 Subject: [PATCH] Species: read GF / Gf1 as tawny nurse shark (#12) Jodie Rummer confirmed that the 2024-25 'GF Log Juv' sheet and its Gf1 code are the tawny nurse shark (Nebrius ferrugineus); the G probably comes from Ginglymostoma, the Atlantic nurse shark genus. Map GF to Nf, drop the placeholder 'Unidentified (GF)' species, bump IMPORTER_VERSION. Closes #12 Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 1 + src/lib/server/import/index.ts | 2 +- src/lib/server/import/logs.ts | 3 +-- src/lib/server/import/normalize.test.ts | 2 +- src/lib/server/import/normalize.ts | 5 +++-- src/lib/species.ts | 6 ------ 6 files changed, 7 insertions(+), 12 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index b2f0f76..5c4c081 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -60,6 +60,7 @@ samples/fixture/ synthetic workbooks for tests/CI (committed) - **Dates** a year outside their season (e.g. `2014-01-11` in 2014-15) are corrected by `fixSeasonYear` and logged. Seasons run Aug–Jul. - 2013-14 `Shark log physioshark` / `Set Log physioshark` duplicate `Catch data` / `Set Log` and are skipped (#9). 2013-14 recaptures are grouped in its `Recaptures` sheet; 2014-15 `Recaptures` holds extra catches; 2015-16 stores recaptures as horizontal column blocks (`1st Recap Site`…). - 2016-17 `Shark Log` has a date _value_ as its date header; 2021-22 `Set Log` has a garbled date header (`16(`). Both are handled. +- Species codes: `Cm` blacktip, `Na` sicklefin lemon, `Nf` tawny nurse shark. 2024-25 writes the nurse shark as `GF` / `Gf1` (`GF Log Juv`), probably from _Ginglymostoma_, the Atlantic nurse shark genus; it is read as `Nf` (confirmed by Jodie Rummer, #12). - Individuals: union-find over tags (PIT 15-digit, `COFA 12345`, re-tags) plus recapture groups. Conflicting sex/species/shrinking length is logged, not fixed. - Captures link to sets by season + set number (±1 day), then date + site, then a unique set that date. - CPUE = max(set-log count, linked captures) / net-hours. 2013-14 has no set times (no CPUE). diff --git a/src/lib/server/import/index.ts b/src/lib/server/import/index.ts index 1181100..42723c6 100644 --- a/src/lib/server/import/index.ts +++ b/src/lib/server/import/index.ts @@ -73,7 +73,7 @@ import { SITE_DEFS } from './sites'; import { readWorkbook } from './xlsx'; /** Bump when import logic changes so existing caches rebuild on the next start. */ -export const IMPORTER_VERSION = '4'; +export const IMPORTER_VERSION = '5'; const MIGRATIONS = import.meta.glob('/drizzle/*.sql', { query: '?raw', diff --git a/src/lib/server/import/logs.ts b/src/lib/server/import/logs.ts index ee31ae8..a8d108e 100644 --- a/src/lib/server/import/logs.ts +++ b/src/lib/server/import/logs.ts @@ -159,8 +159,7 @@ function speciesFromSheetName(name: string): SpeciesCode | null { const n = name.trim().toLowerCase(); if (/^cm|catch data cm/.test(n)) return 'Cm'; if (/^na|catch data na/.test(n)) return 'Na'; - if (/^nf|^nurse/.test(n)) return 'Nf'; - if (/^gf/.test(n)) return 'Gf'; + if (/^nf|^nurse|^gf/.test(n)) return 'Nf'; // 'GF Log Juv' is tawny nurse sharks (#12) return null; } diff --git a/src/lib/server/import/normalize.test.ts b/src/lib/server/import/normalize.test.ts index aca7f4e..7174b85 100644 --- a/src/lib/server/import/normalize.test.ts +++ b/src/lib/server/import/normalize.test.ts @@ -48,7 +48,7 @@ describe('cell parsers', () => { expect(speciesOf('C. melanopterus')).toBe('Cm'); expect(speciesOf('NA')).toBe('Na'); expect(speciesOf('Nurse')).toBe('Nf'); - expect(speciesOf('Gf1')).toBe('Gf'); + expect(speciesOf('Gf1')).toBe('Nf'); expect(ageClassOf('Juvenile 1y')).toBe('juvenile'); expect(ageClassOf('neonate')).toBe('neonate'); }); diff --git a/src/lib/server/import/normalize.ts b/src/lib/server/import/normalize.ts index 274e16c..7654d74 100644 --- a/src/lib/server/import/normalize.ts +++ b/src/lib/server/import/normalize.ts @@ -128,7 +128,7 @@ export function sexOf(v: CellValue | undefined): 'M' | 'F' | null { return null; } -export type SpeciesCode = 'Cm' | 'Na' | 'Nf' | 'Gf' | 'Unknown'; +export type SpeciesCode = 'Cm' | 'Na' | 'Nf' | 'Unknown'; export function speciesOf(v: CellValue | undefined): SpeciesCode | null { const s = str(v) @@ -139,7 +139,8 @@ export function speciesOf(v: CellValue | undefined): SpeciesCode | null { if (s === 'na' || s.includes('acutidens') || s.includes('lemon')) return 'Na'; if (s === 'nf' || s.includes('nurse') || s.includes('ferrugineus') || s.includes('nebrius')) return 'Nf'; - if (s.startsWith('gf')) return 'Gf'; + // 'GF' / 'Gf1' (2024-25) is the tawny nurse shark; G likely from Ginglymostoma, the Atlantic nurse shark genus (#12). + if (s.startsWith('gf')) return 'Nf'; if (s.includes('unknown') || s.includes('unknonw')) return 'Unknown'; return null; } diff --git a/src/lib/species.ts b/src/lib/species.ts index 8d0b09b..4d5135a 100644 --- a/src/lib/species.ts +++ b/src/lib/species.ts @@ -18,12 +18,6 @@ export const SPECIES = { latin: 'Nebrius ferrugineus', color: 'var(--series-3)' }, - Gf: { - code: 'Gf', - common: 'Unidentified ("GF")', - latin: 'species code GF, see issue #12', - color: 'var(--series-4)' - }, Unknown: { code: 'Unknown', common: 'Unknown', latin: '', color: 'var(--muted)' } } as const;