Skip to content

Allow expected nan area in MRMS deaccumulation#496

Merged
aldenks merged 4 commits intomainfrom
fix/mrms-pass2-test-coverage
Mar 7, 2026
Merged

Allow expected nan area in MRMS deaccumulation#496
aldenks merged 4 commits intomainfrom
fix/mrms-pass2-test-coverage

Conversation

@aldenks
Copy link
Member

@aldenks aldenks commented Mar 7, 2026

About 5% of pass 1 & pass 2 data is expected to be a negative missing value sentinel outside radar coverage. This was triggering our default deaccumulation nan check.

Add argument to set expected allowed nan fraction to deaccumulation.

Also address race condition as both precipitation_surface and pass 2 download, decompress, read and delete the same file.

aldenks and others added 4 commits March 7, 2026 08:51
The backfill and operational update test was explicitly filtering out
pass1 and pass2 variables, which masked a production issue where shard
153 had all-NaN values for pass_2_surface after the variable was added
post-backfill. Including these variables in the test and asserting they
have the expected deaccumulation NaN pattern will catch similar gaps.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
… expected_invalid_fraction

The numba deaccumulation function was raising ValueError internally when encountering
negative values below threshold. For MRMS data, ~6.2% of pixels have -3.0 no-data
sentinels (over-ocean areas) that become invalid after deaccumulation, triggering this
error on every operational update. The old code caught this with a bare except ValueError
that silently skipped writing data, causing pass2 (and likely other vars) to remain all-NaN.

Changes:
- Move error counting from numba (raise) to Python wrapper (return counts + fraction check)
- Add expected_invalid_fraction parameter so callers can declare expected no-data levels
- MRMS region_job uses expected_invalid_fraction=0.07 and removes the try/except swallow
- Add tests for expected_invalid_fraction suppressing/still-raising errors

Co-Authored-By: Claude Opus 4.6 <[email protected]>
…st corrupt files

The try/except guards against individual corrupt files breaking the entire operational
update. The root cause fix (expected_invalid_fraction=0.07) prevents the -3.0 no-data
sentinels from triggering the error under normal conditions.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Atomic decompression: _decompress_gzip writes to temp file then renames,
  preventing corruption when precipitation_surface and precipitation_pass_2_surface
  concurrently decompress the same MultiSensor_QPE_01H_Pass2 file. Also deletes
  .gz after decompression to avoid stale cache.
- Add test_download_and_read_pass_1 and test_download_and_read_pass_2 slow tests
  for individual file download+read coverage.
- Revert backfill integration test to precipitation_surface + categorical only,
  avoiding the concurrent download collision in test.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@aldenks aldenks enabled auto-merge (squash) March 7, 2026 14:34
@aldenks aldenks merged commit ac101f4 into main Mar 7, 2026
5 checks passed
@aldenks aldenks deleted the fix/mrms-pass2-test-coverage branch March 7, 2026 14:38
@aldenks aldenks linked an issue Mar 7, 2026 that may be closed by this pull request
7 tasks
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.

MRMS analysis

1 participant