Skip to content

docs(major_chemistry): investigate mixed sampling dates in major-ion products (DIE-404) - #155

Merged
jirhiker merged 4 commits into
mainfrom
DIE-404-docs-major-chemistry-major-chemistry-layer-mixes-sampling-dates-across-analytes-for-a-well
Nov 20, 2026
Merged

jirhiker merged 4 commits into
mainfrom
DIE-404-docs-major-chemistry-major-chemistry-layer-mixes-sampling-dates-across-analytes-for-a-well

Conversation

@jirhiker

@jirhiker jirhiker commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Summary

DIE-404 asked us to check whether the major chemistry layer mixes sampling dates across analytes, and to recommend a fix. It does. This PR adds the investigation, the recommendation, the decisions made in review, and the list of tickets to create. No product code changes.

Jira: DIE-404

Changes

  • docs/major-chemistry-sampling-events.md (new):
    • Confirms that _pivot_by_well takes each analyte's own latest value and never compares dates.
    • Lists the seven affected products and which date fields each one publishes. Water type and ion balance publish no date at all.
    • Includes a reproduction: a well with a balanced 1985 analysis plus a 2019 Na/Cl resample comes out of ion balance as suspect (CBE 59.5%), only because the dates are mixed.
    • Recommends a fix, records the review decisions, and lists the tickets to create.

Recommendation in brief

  • The fix can't go inside _pivot_by_well: by then only each analyte's latest value is left. It can go one step earlier without new fetching, because each combine asset already loads the full per-observation timeseries (all_timeseries).
  • A sampling event is (source, well id, date_measured). Each product names the ions an event must have. Pick the most recent event that has all of them. If none does, pick the event with the most of them and set event_complete = false.
  • Add sample_date, n_analytes_in_event and event_complete to major chemistry, hardness, water type, SAR and ion balance.

Decisions (from review)

  1. MCL exceedance keeps the latest value per analyte.
  2. The required ion sets are accepted as proposed. There is no WQI rule yet, so WQI stays on per-analyte latest values for now.
  3. <analyte>_date stays for v1.1 alongside sample_date, and is removed in a follow-up once the front end uses sample_date.
  4. Calendar date is the event key for now. Whether sources expose a sample ID is a follow-up investigation across all sources.

Tickets to create

DIE backlog (this repo):

  1. Event-selection step plus major chemistry (sample_date, n_analytes_in_event, event_complete; keep <analyte>_date), with tests.
  2. Move hardness, water type, SAR and ion balance onto it, with tests.
  3. MCL exceedance abstract wording only.
  4. Remove <analyte>_date from the event-based products (blocked by 1, 2 and 7).
  5. Decide the WQI event rule, then move WQI or document why it stays per-analyte.
  6. Investigate sample or event IDs across all sources.

Front-end backlog (Weaver W10):

  1. Change the major chemistry detail panel to use sample_date instead of per-analyte dates (blocked by 1).

Testing

  • Docs only. I ran the reproduction snippet in the doc against the current code and got 59.5 suspect, as the doc states.
  • uv run pytest tests/test_product_docs.py: 3 tests fail, and they fail the same way on main without this change (test_every_linked_output_type_has_a_section, test_section_lists_its_products, test_registry_has_one_entry_per_backend_source).

Risk and rollout

  • Risk: none. Docs only.
  • Migrations / config: none.
  • Rollback: revert the squash commit.

Follow-ups

  • The tickets listed above.
  • The 3 failing tests in tests/test_product_docs.py already fail on main and need their own ticket.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RzW3G1jrDotQka8MrAyvpq

…products (DIE-404)

Confirms that _pivot_by_well combines each analyte's own latest value,
so hardness, water type, SAR, ion balance and WQI can compute from ions
measured on different dates. Includes a reproduction and a recommended
event-based fix with open decisions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RzW3G1jrDotQka8MrAyvpq
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Your pull request is automatically being deployed to Dagster Cloud.

Location Status Link Updated
die-orchestration View in Cloud Nov 19, 2026 at 09:41 PM (UTC)

@jirhiker
jirhiker marked this pull request as ready for review November 18, 2026 22:59
…ercion (DIE-404)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RzW3G1jrDotQka8MrAyvpq

@chasetmartin chasetmartin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answered some of the outstanding questions. Please update accordingly, especially to update the list of implementation or follow up tickets needed. Once merged I will use that ticket list to build the backlog items. Thanks!

Comment thread docs/major-chemistry-sampling-events.md Resolved
Comment thread docs/major-chemistry-sampling-events.md Resolved
Comment thread docs/major-chemistry-sampling-events.md Resolved
Comment thread docs/major-chemistry-sampling-events.md Resolved

@chasetmartin chasetmartin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. I can use the doc to create Jira implementation tickets after the merge.

@jirhiker
jirhiker merged commit f54092a into main Nov 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants