Skip to content

ENH: When importing ODIM files, extract the global attributes ‘wmo__i…#385

Open
chfer wants to merge 1 commit into
openradar:mainfrom
chfer:enh/global-attrs-from-odim-what-source
Open

ENH: When importing ODIM files, extract the global attributes ‘wmo__i…#385
chfer wants to merge 1 commit into
openradar:mainfrom
chfer:enh/global-attrs-from-odim-what-source

Conversation

@chfer

@chfer chfer commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR extends the ODIM backend to extract additional global attributes from the /what/source metadata field when importing ODIM files.

The extracted values are mapped onto the following FM301 global attributes in the xradar memory model:

  • wmo__id
  • site_name
  • node
  • wmo__originating_centre
  • wmo__wsi

Details

The ODIM /what/source string is parsed as key-value metadata and used to populate dataset global attributes during import.

This change also handles source strings containing non-ASCII station names encoded through surrogate-escaped UTF-8 byte sequences, so values such as for example Sürgavere are preserved correctly.

Tests

Added coverage to verify:

  • parsing of /what/source into global attributes
  • correct recovery of UTF-8 text from surrogate-escaped source strings

…d’, ‘node’, ‘wmo__originating_centre’ and ‘wmo__wsi’ from the ODIM ‘/what/source’ attribute.

 * ADD: Added to xradar/model.py the FM301 global attributes ‘wmo__id’,  ‘wmo__originating_centre’ and ‘wmo__wsi’ as required global attributes. Also one proposed OPERA FM301 extension, ‘node’ ,was added.

 * ADD: In the ODIM backend (‘xradar/io/backends/odim.py’), enhanced the method ‘OdimStore.get_attrs’ for extracting the global attributes ‘wmo__id’, ‘node’, ‘wmo__originating_centre’ and ‘wmo__wsi’ from the ODIM /what/source attribute. Also adding the global attribute ‘source’, which is set to ‘radar’, assuming that ODIM will only carry radar files and no LIDAR files.

 * TST: Added pytest fixtures in ‘conftest.py’ for accessing extra ODIM files.

 * TST: In ‘tests/io/test_odim.py’  added tests ‘test_odim_source_global_attributes’, ‘test_parse_odim_source_extensive’,  ‘test_parse_odim_source_handles_non_string_input’ and test_parse_odim_source_surrogate_repair_unicodeerror_fallback’.

 * TST: Adapted test ‘tests/io/test_odim.py::test_open_odim_datatree’ to take into account one extra global attribute (site_name)

 * DOC: Adapted history.md.
@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.23%. Comparing base (79ba495) to head (7a08bf1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #385      +/-   ##
==========================================
+ Coverage   94.20%   94.23%   +0.02%     
==========================================
  Files          29       29              
  Lines        6417     6449      +32     
==========================================
+ Hits         6045     6077      +32     
  Misses        372      372              
Flag Coverage Δ
notebooktests 0.00% <0.00%> (ø)
unittests 94.23% <100.00%> (+0.02%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

@chfer chfer marked this pull request as ready for review June 4, 2026 14:04
@kmuehlbauer

Copy link
Copy Markdown
Collaborator

Thanks @chfer, that looks like a missing part. Are you up to adding/updating also the writing part? If not we can defer that to a follow-up PR.

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.

2 participants