Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DataMet backend for Italian Radar data #175

Merged
merged 17 commits into from
Jul 17, 2024
Merged

Conversation

wolfidan
Copy link
Contributor

@wolfidan wolfidan commented Jun 27, 2024

Dear xradar people, this is a first try at adding a new backend to read the data from the Italian radars provided by Gianfranco Vulpiani that we plan to use at the open radar course at ERAD2024.

https://zenodo.org/records/4897697

I must say that I had some trouble understanding all the classes that are required to wrap it into xarray, but I tried my best and it seems to work, as I was able to read all 165 provided files. I have added some tests but they are somewhat simplistic at the moment and only test the basic reader not the wrapper to xarray (other tests seem to do the same things).

The DataMet files are not consistent in which sweep corresponds to which elevation: sometimes sweep 1 could be 16° other times 90°. I find it a bit weird but left it as is and didn't try to remap it. I wonder if this could be an issue when reading them into pyart?

Thank you for your time.
Next week I will be in vacation and might not answer immediately, sorry about that.

@kmuehlbauer
Copy link
Collaborator

Thanks @wolfidan! The ruff and numpy2 issues should be resolved now by #177. I'll have a closer look here later.

xradar/version.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jun 28, 2024

Codecov Report

Attention: Patch coverage is 93.77593% with 15 lines in your changes missing coverage. Please review.

Project coverage is 91.70%. Comparing base (89d9a3e) to head (d12815d).
Report is 18 commits behind head on main.

Files with missing lines Patch % Lines
xradar/io/backends/datamet.py 93.72% 15 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #175      +/-   ##
==========================================
+ Coverage   91.58%   91.70%   +0.12%     
==========================================
  Files          21       22       +1     
  Lines        3991     4231     +240     
==========================================
+ Hits         3655     3880     +225     
- Misses        336      351      +15     
Flag Coverage Δ
notebooktests 77.21% <24.06%> (-3.22%) ⬇️
unittests 89.83% <93.77%> (+0.23%) ⬆️

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.

@kmuehlbauer
Copy link
Collaborator

@wolfidan I've taken the chance to fix this up to green CI. Looks good so far. We might just copy/adapt code/tests from the other backends to finish this.

Thanks for this nice addition!

@kmuehlbauer
Copy link
Collaborator

This works for me with different elevations. Looks that this is a top down strategy.

import open_radar_data
import xarray as xr
fname = open_radar_data.DATASETS.fetch("H-000-VOL-ILMONTE-201907100700.tar.gz")
with xr.open_dataset(fname, engine="datamet", group="sweep_8") as ds:
    display(ds)
    ds = ds.set_coords("sweep_mode")
    ds = ds.wrl.georef.georeference()
    ds.DBTH.wrl.vis.plot()

@kmuehlbauer
Copy link
Collaborator

The DataMet files are not consistent in which sweep corresponds to which elevation: sometimes sweep 1 could be 16° other times 90°.

Maybe it's that the 90deg sweep is not measured in every volume?

@wolfidan
Copy link
Contributor Author

That's amazing, thanks a lot @kmuehlbauer, I will add more tests the week after the next to increase codecov

@wolfidan
Copy link
Contributor Author

@kmuehlbauer
All tests and codecov should be fine now. I still had an issue.

    ds = xr.open_dataset(datamet_file, engine="datamet")

doesn't work. I had to use

   ds = xr.open_dataset(datamet_file, engine=xradar.io.backends.DataMetBackendEntrypoint)

in the unit tests

Maybe you can easily fix that. I'm looking forward to see you do this, so I can do it next time.
Thanks a lot

Copy link
Collaborator

@mgrover1 mgrover1 left a comment

Choose a reason for hiding this comment

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

Can you try adding back in the engine="datamet" now that the linting issues have been resolved?

tests/io/test_io.py Outdated Show resolved Hide resolved
tests/io/test_io.py Outdated Show resolved Hide resolved
tests/io/test_io.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@kmuehlbauer kmuehlbauer left a comment

Choose a reason for hiding this comment

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

Not sure why it doesn't work for you. But you would need to install the package first before being able to use the entrypoints.

tests/io/test_io.py Outdated Show resolved Hide resolved
tests/io/test_io.py Outdated Show resolved Hide resolved
tests/io/test_io.py Outdated Show resolved Hide resolved
tests/io/test_datamet.py Outdated Show resolved Hide resolved
@wolfidan
Copy link
Contributor Author

Thanks @mgrover1 @kmuehlbauer , I'll change it very soon and see if it passes the tests

@wolfidan
Copy link
Contributor Author

Ok I changed according to your propositions.

Copy link
Collaborator

@kmuehlbauer kmuehlbauer left a comment

Choose a reason for hiding this comment

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

Great work @wolfidan!

Copy link
Collaborator

@mgrover1 mgrover1 left a comment

Choose a reason for hiding this comment

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

Agreed - thanks so much for this contribution @wolfidan !!

@mgrover1 mgrover1 merged commit 2d266bb into openradar:main Jul 17, 2024
18 checks passed
rcjackson pushed a commit to rcjackson/xradar that referenced this pull request Aug 23, 2024
* ADD: datamet backend for italian C-band data

* ADD: add unit test for datamet backend

* ENH: support for .gz files in DataMet reader

* [ENH] black style formatting

* remove version.py

* make DataMetBackend discoverable

* fix tests

* fix entrypoint

* ENH: add tests for datamet xarray backend

* FIX: remove version.py

* ENH: added more tests for datamet format

* ENH: black fix

* FIX: fix E721 in type comparison (ruff)

* DOC: edited history.md

* FIX: changed xradar.io.backends.DataMetBackendEntrypoint to 'datamet'

* FIX: black formatting

---------

Co-authored-by: Kai Mühlbauer <[email protected]>
Co-authored-by: Kai Mühlbauer <[email protected]>
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.

3 participants