Skip to content

Charts: compare sampling conditions within nursery-months - #149

Merged
Luen merged 3 commits into
mainfrom
codex/124-sampling-conditions
Nov 4, 2026
Merged

Luen merged 3 commits into
mainfrom
codex/124-sampling-conditions

Conversation

@Luen

@Luen Luen commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Adds a nursery/month selector on /effort and paired distributions of daily rainfall, daily maximum wind and OISST on sampling dates versus all available dates in that same month. Repeat sets on one date count once. Both groups use identical daily measurements; missing values and group denominators are shown and exported.

Closes #124. Uses per-stratum comparisons rather than pooling months or nurseries. The reference includes sampled dates, so these are descriptive charts without independent-sample significance tests.

Validation: lint, svelte-check (0 errors/warnings), 87 unit tests, read-only real-data import, production build, and 32 Playwright tests including the new mobile and light/dark accessibility check. Browser tests used an ignored local config to isolate their server port from other active checkouts. No private data or local config committed.

@Luen Luen added enhancement New feature or request analytics Charts, statistics and analyses environment Weather, ocean, tide, climate and astronomy data labels Nov 4, 2026
- SST was always empty: it read ocean.oisst, which has no values at all
  (#154). It now uses the same series as the per-set SST.
- One nursery-month holds a median of two fieldwork nights (97% have
  three or fewer), so each histogram compared about two nights with a
  month. The comparison now pools every month with fieldwork, weighting
  each month's days by its fieldwork nights, as #124 allows with
  explicit weights. Nights count once across nurseries and sets, since
  the weather is one island-wide series.
- A within-month randomisation test (seeded, 5,000 draws) backs each
  chart, instead of no test: the reference contains the fieldwork
  nights, so a two-sample test would be wrong. Fieldwork nights are a
  little drier and calmer than their months.
- Shared bins with labels (rain on an open-ended scale), percentages in
  a grouped bar chart, the reference in a muted colour, missing values
  counted per chart, plainer copy.
- No query-string form: the section is part of the memoised /effort
  load and sits after the sampling calendar.
- Tests: duplicate dates and nurseries, other sites and gear, month
  weights, month boundaries and leap days, missing values, a selection
  the test must flag, and a seeded p.
- AGENTS.md: its own section, out of "Cyclones and heavy rain".
- Merged main; IMPORTER_VERSION already 9 there, no bump needed here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Luen

Luen commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Reviewed against the real data (aggregates only) and current main. Several parts were right and stay:

  • Fieldwork days count once.
  • Both sides use the same daily quantity.
  • Missing values stay missing.
  • The page avoids a two-sample test on overlapping groups.

Two problems on the real data meant the charts couldn't answer #124's question, so I reworked the analysis. Pushed in 8c8f433, after merging main in b2dd638.

1. The SST chart was always empty. It read ocean.oisst, which has no values at all: 0 of 4,840 days. The OISST fetch has never worked, and the rest of the site falls back to Coral Reef Watch SST while crediting OISST. I filed that as #154. Here, SST now uses the same series as the per-set SST, so it switches over when #154 is fixed.

2. One nursery-month is too small to plot. Across 693 nursery-months with fieldwork, the median is two fieldwork nights, and 97% have three or fewer. The default view (Apaura, February 2025) compared 2 nights with 28 days, so each 10-bin histogram moved in 50% steps.

#124 allows pooling with explicit weights, so the section now pools:

  • The comparison: every month with fieldwork, Dec 2013 to Feb 2026 (79 months).
  • Fieldwork nights: each date with a nursery gillnet set, 1,246 in all. The weather and SST are one series for the whole island, so a night counts once however many nurseries or sets it had. That also answers Environment: compare conditions on sampling days with the available seasonal record #124's "explain how shared weather and multiple sites are counted".
  • The reference: every day of those months, 2,393 with a value. Each month's days are weighted by its fieldwork nights ÷ its days with a value, so the reference has the same seasonal mix as the fieldwork and wet season isn't compared with dry.

3. A test that respects the overlap. #119 wants a test behind each chart, and #124 rules out independent-sample tests here, rightly. The fit is a within-month randomisation test: draw the same number of days from each month as were fished, 5,000 times with a fixed seed, and see how often the gap is as large. On the real data:

Fieldwork nights Same months, weighted p
Rain that day 6.5 mm 7.2 mm 0.004
Strongest wind that day 23.1 km/h 23.5 km/h 0.02
Sea-surface temperature 27.94 °C 27.94 °C 0.84

The rain gap sits mostly in the heaviest days: 40 mm or more fell on 2.5% of fieldwork nights against 3.7% of days in the same months. The copy calls this coverage, not weather stopping trips, as #124 asks.

4. Smaller fixes

  • Bins: shared across both groups and labelled, in a grouped bar chart of percentages. Rain uses an open-ended top bin (0–1, 1–5, 5–10, 10–20, 20–40, 40+ mm), because daily rain is heavy-tailed; wind uses 5 km/h steps and SST 0.5 °C.
  • Colours: the reference is muted, so it doesn't read as a second category.
  • Missing values: each chart counts its nights and days with and without a value.
  • Load: the query-string form is gone. The section is part of the memoised /effort load, where before it called dataset() on every request, and it sits after the sampling calendar instead of opening the page.
  • Tests: duplicate dates across sets and nurseries; other sites and gear; month weights (a wet and a dry month); month boundaries and a leap day; missing values; a selection the test must flag; and the same p on every run. The e2e spec is renamed sampling-conditions.spec.ts.
  • AGENTS.md: the note was in "Cyclones and heavy rain"; it now has its own section.
  • IMPORTER_VERSION: main is already at 9, so merging it drops the bump.

Merging with #151 and #152. A trial merge of all three is clean and passes pnpm check.

Checks after the fixes:

  • pnpm lint, pnpm check and pnpm test (100 passed), plus the opt-in real-data import.
  • pnpm build and the full Playwright suite (34 passed, including the phone-width and light/dark axe check).
  • /effort in the browser on the real data.

@Luen
Luen merged commit f3bc707 into main Nov 4, 2026
5 checks passed
@Luen
Luen deleted the codex/124-sampling-conditions branch November 4, 2026 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

analytics Charts, statistics and analyses enhancement New feature or request environment Weather, ocean, tide, climate and astronomy data

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Environment: compare conditions on sampling days with the available seasonal record

1 participant