Skip to content

Conversation

@aladinor
Copy link
Member

@aladinor aladinor commented Dec 4, 2025

This PR addresses backward compatibility issues with the NEXRAD Level2 backend when reading historical NEXRAD files and special scan modes.

The NEXRAD backend currently fails with:

  1. IndexError on older NEXRAD files (e.g., Build 8.0 from 2006) due to missing msg_2 metadata
  2. struct.error on VCP-0 files due to corrupted MSG_5 elevation data
  • Fixed IndexError: Added safe access check for msg_2 metadata with fallback to record 0
  • Added MSG_5 validation: Check for reasonable number_elevation_cuts values (0-25) before parsing
  • Improved error handling: Gracefully handle struct unpacking failures in elevation data
  • Enhanced metadata reading: Support different NEXRAD format versions and builds

The following publicly available files now work correctly:

  • s3://unidata-nexrad-level2/2006/05/19/KLOT/KLOT20060519_183423.gz
  • s3://unidata-nexrad-level2/2005/01/27/KLOT/KLOT20050127_154429.gz
  • s3://unidata-nexrad-level2/2025/11/19/KLOT/KLOT20251119_121045_V06

kmuehlbauer and others added 11 commits August 4, 2025 13:58
Addresses backward compatibility issues with historical NEXRAD files
and special scan modes:

- Fix IndexError when msg_2 metadata is missing (older builds like Build 8.0)
- Add validation for corrupted MSG_5 data in VCP-0 maintenance mode files
- Handle struct unpacking errors gracefully in MSG_5 elevation data
- Improve metadata reading to support different NEXRAD format versions

Fixes reading of files like:
- s3://unidata-nexrad-level2/2006/05/19/KLOT/KLOT20060519_183423.gz
- s3://unidata-nexrad-level2/2005/01/27/KLOT/KLOT20050127_154429.gz
- s3://unidata-nexrad-level2/2025/11/19/KLOT/KLOT20251119_121045_V06
@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

❌ Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.50%. Comparing base (6496432) to head (0be64b6).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
xradar/io/backends/nexrad_level2.py 91.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #312      +/-   ##
==========================================
- Coverage   93.52%   93.50%   -0.02%     
==========================================
  Files          27       27              
  Lines        5572     5587      +15     
==========================================
+ Hits         5211     5224      +13     
- Misses        361      363       +2     
Flag Coverage Δ
notebooktests 0.00% <0.00%> (ø)
unittests 93.50% <91.66%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Based on agent review recommendations:

- Replace complex inheritance mocking with unittest.mock patterns
- Add parametrized test for MSG_5 elevation validation scenarios
- Enhance documentation with historical NEXRAD context (Build 8.0, VCP-0)
- Simplify test structure while maintaining comprehensive coverage
- Add clear test descriptions for different corruption scenarios

Tests now cover:
- VCP-0 maintenance mode with corrupted elevation counts (40833)
- Normal VCP patterns with valid elevation cuts
- Empty VCP patterns
- Invalid elevation counts exceeding maximum (25)

Improves maintainability and follows xradar testing patterns.
@kmuehlbauer
Copy link
Collaborator

Great @aladinor, thanks for picking up #293!

@aladinor
Copy link
Member Author

aladinor commented Dec 8, 2025

Thanks @kmuehlbauer for mentioning #293, I totally forgot it. With this PR we can close both. Please let me know if something else is required.

@kmuehlbauer kmuehlbauer merged commit 93c33ea into openradar:main Dec 9, 2025
9 of 11 checks passed
@kmuehlbauer
Copy link
Collaborator

Thanks @aladinor!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

NEXRAD Level2 backend compatibility issues with older file formats

2 participants