Skip to content

Add importer for DWD radar data products and reprojection onto a regular grid as part of #464 #483

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

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

m-rempel
Copy link

Implementation of an importer for DWD radar data products and a reprojection onto a regular grid. These are necessary to test the implementation of the reduced-space EnKF combination approach (Nerini et al., 2019) and to compare the results with the already existing code base that uses DWD data.

@RubenImhoff
Copy link
Contributor

Many thanks for this contribution, @m-rempel!

Although we have discussed within the pysteps community to limit the number of new importers, I can imagine that this importer is a useful addition to allow for the ensemble Kalman filter blending setup, testing and possibly some gallery examples. I will have a quick look to see if there is any overlap with other HDF5 importers to see if we can shorten the code a bit. @dnerini, what do you think?

Regarding the addition to the reprojection, the code looks good, but at this moment pysteps does not yet support xarray (we will from version 2). Is there a way to rewrite this approach without xarray? If not, we could consider these improvements as part of the pysteps v2 release. @dnerini, what is your take on this?


except:

d[key] = value.value
Copy link
Contributor

Choose a reason for hiding this comment

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

What exception are you expecting here?

Copy link
Author

Choose a reason for hiding this comment

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

I have removed this exception, since I had implemented this in my code for testing purposes. However, to read the HDF content np.array should be sufficient.


def _read_hdf5_cont(f, d):
"""
Recursively read nested dictionaries from a HDF5 file.
Copy link
Contributor

Choose a reason for hiding this comment

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

Good to add some extra docstrings here about what the input variables are and what you expect to return.

Copy link
Author

Choose a reason for hiding this comment

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

I have added here and in other functions the docstrings and have extended the descriptions.



def _identify_info_bits(data):

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also add some docstrings here?

----------
filename: str
Name of the file to import.
product: {'WX','RX','EX','RY','RW','AY','RS','YW','WN'}
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to call this variable product_name? Then the prod variable can get a longer, more descriptive name as well.

Copy link
Author

Choose a reason for hiding this comment

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

I followed your suggestion and changed it in product_name.

Geodata for RADOLAN products. Hard-coded here, cause there is only basic
information about the projection in the header of the binary RADOLAN
files.
"""
Copy link
Contributor

@RubenImhoff RubenImhoff Jul 1, 2025

Choose a reason for hiding this comment

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

Add some more docstrings here, too (input parameters and output). I have already added much more docstrings, but feel free to edit them from here.

@RubenImhoff
Copy link
Contributor

Almost forgot to mention it, but we will have to add some tests if we continue with this approach! :)

@RubenImhoff
Copy link
Contributor

Many thanks, @m-rempel! @dnerini, what is your take on adding one more importer to pysteps for the sake of testing and implementing the reduced-space Ensemble Kalman filter based blending?

@RubenImhoff RubenImhoff moved this to In Progress in Pysteps hackathon 2025 Aug 8, 2025
@m-rempel
Copy link
Author

Almost forgot to mention it, but we will have to add some tests if we continue with this approach! :)

Sure. This is the first version of the implementation. Also to see if you are happy with it.

@RubenImhoff RubenImhoff marked this pull request as ready for review August 12, 2025 06:21
@RubenImhoff
Copy link
Contributor

Almost forgot to mention it, but we will have to add some tests if we continue with this approach! :)

Sure. This is the first version of the implementation. Also to see if you are happy with it.

Perfect! I think the importer code looks good now. Could you add a data sample of the DWD data to https://github.com/pySTEPS/pysteps-data? Once it is there, we have a dataset we can use for setting up some simple tests.

Other than that, and if @dnerini also agrees with this setup, we are good to go. :)

Copy link

codecov bot commented Aug 12, 2025

Codecov Report

❌ Patch coverage is 9.61538% with 188 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.50%. Comparing base (abd1f52) to head (df0956b).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
pysteps/io/importers.py 8.47% 162 Missing ⚠️
pysteps/utils/reprojection.py 16.12% 26 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #483      +/-   ##
==========================================
- Coverage   84.56%   83.50%   -1.07%     
==========================================
  Files         162      162              
  Lines       13471    13670     +199     
==========================================
+ Hits        11392    11415      +23     
- Misses       2079     2255     +176     
Flag Coverage Δ
unit_tests 83.50% <9.61%> (-1.07%) ⬇️

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.

@dnerini
Copy link
Member

dnerini commented Aug 14, 2025

hi @RubenImhoff and @m-rempel, apologies for the slow response...

It's true that in principle we prefer to use plugins for importers instead of adding them into pysteps itself. This said, I'm personally OK with a few exceptions like in this case, especially if it can help implementing a new cool feature ;) but the new importers should come with some basic testing at least. Can we add some tests for the import_dwd_hdf5 and unstructured2regular methods before merging?

@m-rempel
Copy link
Author

Hi @dnerini !
In our last meeting, @RubenImhoff and I discussed the issue about the missing tests. I'll implement these by no later than next week.

"varname": "PR_GSP",
"grid_file_path": "./aux/grid_files/dwd/icon/R19B07/icon_grid_0047_R19B07_L.nc",
}
array_src, _, metadata_src = pysteps_nwp_importers.importer_dwd_nwp.import_dwd_nwp(
Copy link
Contributor

Choose a reason for hiding this comment

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

@m-rempel, pysteps won't find pysteps_nwp_importers as it is an optional additional package to pysteps. Hence, this test would only work with dummy data, or if you can make a very simple reproduction of the data import here in the tests. As you can see in the reprojection test above for the RMI data, some dummy data is created an put on the grid and projection that this data has. Would something like that be feasible? Other than that, this PR is good to go!

Copy link
Author

Choose a reason for hiding this comment

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

I thought about this also yesterday. One option could be to have unstructured2regular() within pysteps_nwp_importers, since it is needed solely for the ICON-D2 data. On the other side, pysteps_nwp_importers would then no longer be independent, since some regular grid is necessary for that test.
What do you think, @RubenImhoff and @dnerini?

@RubenImhoff RubenImhoff added the enhancement New feature or request label Aug 20, 2025
@RubenImhoff RubenImhoff added the good first issue Good for newcomers label Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants