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

Cf/Radial1 writer #126

Merged
merged 25 commits into from
Sep 27, 2023
Merged

Cf/Radial1 writer #126

merged 25 commits into from
Sep 27, 2023

Conversation

syedhamidali
Copy link
Contributor

@syedhamidali syedhamidali commented Sep 18, 2023

I have incorporated the CFRadial1 writer into the code and tested it with four different CFRadial1 data files. It successfully processed three of the files. While it currently works with full radar volumes, I acknowledge that further refinement and compatibility with sweeps are necessary. I welcome any suggestions for improvement and am open to any modifications that enhance its suitability.

I also ran pre-commit run --all-files.

Thanks
Hamid

@kmuehlbauer kmuehlbauer reopened this Sep 18, 2023
@kmuehlbauer
Copy link
Collaborator

kmuehlbauer commented Sep 18, 2023

@syedhamidali I've fixed an issue on main to get the CI started here. I'll have a closer look later today if no one beats me to it.

@codecov
Copy link

codecov bot commented Sep 18, 2023

Codecov Report

Merging #126 (e807122) into main (e10a697) will increase coverage by 0.10%.
The diff coverage is 91.83%.

@@            Coverage Diff             @@
##             main     #126      +/-   ##
==========================================
+ Coverage   88.21%   88.31%   +0.10%     
==========================================
  Files          19       20       +1     
  Lines        3334     3431      +97     
==========================================
+ Hits         2941     3030      +89     
- Misses        393      401       +8     
Flag Coverage Δ
unittests 88.31% <91.83%> (+0.10%) ⬆️

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

Files Coverage Δ
xradar/io/export/__init__.py 100.00% <100.00%> (ø)
xradar/model.py 96.19% <100.00%> (ø)
xradar/io/export/cfradial1.py 91.66% <91.66%> (ø)

@syedhamidali
Copy link
Contributor Author

So, @kmuehlbauer, could you please explain how Codecov works? My understanding is that we need to create some tests for it. However, I couldn't find any tests for to_cfradial2, and I'm hesitant to make changes without a clear understanding of how it functions. I'd appreciate your assistance in this matter. Thank you!

@kmuehlbauer
Copy link
Collaborator

@syedhamidali Currently we use the notebooks to test this. That's no full featured unittest as it just checks that it runs without raising an error.

We'd decided to add tests while touching the codebase.

@syedhamidali
Copy link
Contributor Author

Thank you for this info! So, what is the solution here?

@kmuehlbauer
Copy link
Collaborator

kmuehlbauer commented Sep 23, 2023

OK, I can't give a very detailed answer now, but the idea would be to create some roundtrip tests first. Where we write and read back some predefined data and compare it against each other.

Finally, we would like to have tests for each function.

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.

@syedhamidali Thanks for tackling this issue. I've added a couple comments and suggestions.

For adding tests, maybe a simple roundtrip will be sufficient?

  1. read CfRadial1 file
  2. export to_cfradial1
  3. read back and compare with 1

xradar/io/export/cfradial1.py Outdated Show resolved Hide resolved
xradar/io/export/cfradial1.py Outdated Show resolved Hide resolved
xradar/io/export/cfradial1.py Outdated Show resolved Hide resolved
xradar/io/export/cfradial1.py Outdated Show resolved Hide resolved
@kmuehlbauer kmuehlbauer mentioned this pull request Sep 26, 2023
3 tasks
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

xradar/version.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.

@syedhamidali Let's try to get this in by tomorrow or Thursday latest. I'm really pushing for a release 0.4.0 on Thursday.

CITATION.cff Outdated Show resolved Hide resolved
CITATION.cff Outdated Show resolved Hide resolved
CITATION.cff Show resolved Hide resolved
xradar/io/export/cfradial1.py Outdated Show resolved Hide resolved
xradar/model.py Show resolved Hide resolved
Removed contributions
release 0.4.0
@syedhamidali
Copy link
Contributor Author

@kmuehlbauer Notebook for the tests or for the example?

@kmuehlbauer
Copy link
Collaborator

Good question, do you think it would make sense to combine it?

@syedhamidali
Copy link
Contributor Author

Separating them would be a better approach as it simplifies the user experience by not exposing the tests directly. Additionally, I attempted a this approach, and when we save it to cfradial1, the xarray does not preserve its mask. This discrepancy in the masking could be a potential reason for the lack of identity between the two datasets. What are your thoughts on this?
Screenshot 2023-09-26 at 9 04 58 AM

@syedhamidali
Copy link
Contributor Author

But this way it seems they are identical
Screenshot 2023-09-26 at 9 09 59 AM

@kmuehlbauer
Copy link
Collaborator

OK, then I'd suggest an example notebook and unit tests under xradar/tests/io -> test_cfradial1.py.

You could use xr.testing.assert_identical(ds1, ds2) for testing.

@syedhamidali
Copy link
Contributor Author

OK, then I'd suggest an example notebook and unit tests under xradar/tests/io -> test_cfradial1.py.

You could use xr.testing.assert_identical(ds1, ds2) for testing.

I tried that one, check this out #126 (comment), I feel that is masked_arrays/fill_value vs NaNs

@kmuehlbauer
Copy link
Collaborator

xr.testing.assert_identical(dtree["sweep_0"].ds, dtree2["sweep_0"].ds)
xr.testing.assert_equal(dtree["sweep_1"].ds, dtree2["sweep_1"].ds)
xr.testing.assert_equal(dtree["sweep_2"].ds, dtree2["sweep_2"].ds)

Something like this works for me.

@kmuehlbauer
Copy link
Collaborator

I attempted a this approach, and when we save it to cfradial1, the xarray does not preserve its mask. This discrepancy in the masking could be a potential reason for the lack of identity between the two datasets. What are your thoughts on this?

I think you can't write masked arrays to netcdf with xarray. You would need _FillValue attribute in any case. Maybe I'm misunderstanding the issue.

@kmuehlbauer
Copy link
Collaborator

@syedhamidali I think the roundtrip test is sufficient for now. Please let me know when this is ready for merge. There might be some clean-up needed in the CfRadial1 Notebook. Maybe we can have the release already tomorrow. 🚀

@syedhamidali
Copy link
Contributor Author

I tried to make a notebook, but the problem is that I don't know yet how this datatree.DataTree works and its documentation is also not clear enough. Would you like to take a look at this notebook and suggest your changes, so that I can just upload that to the notebooks? Here https://github.com/syedhamidali/test_scripts/blob/test/CfRadial1_Export.ipynb

@kmuehlbauer
Copy link
Collaborator

@syedhamidali The notebook looks nice for the first setup, you can extend it any time by adding additional information to it.

Add it to the examples and we are almost ready to get this in.

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.

@syedhamidali This is a great first contribution! I've added another couple of comments and suggestions. After addressing those we can get this in and have a release party.

examples/notebooks/CfRadial1.ipynb Outdated Show resolved Hide resolved
xradar/io/export/cfradial1.py Outdated Show resolved Hide resolved
xradar/io/export/cfradial1.py Outdated Show resolved Hide resolved
xradar/io/export/cfradial1.py Outdated Show resolved Hide resolved
xradar/io/export/cfradial1.py Outdated Show resolved Hide resolved
xradar/io/export/cfradial1.py Outdated Show resolved Hide resolved
xradar/io/export/cfradial1.py Outdated Show resolved Hide resolved
xradar/io/export/cfradial1.py Outdated Show resolved Hide resolved
xradar/io/export/cfradial1.py Show resolved Hide resolved
xradar/io/export/cfradial1.py Outdated Show resolved Hide resolved
@kmuehlbauer
Copy link
Collaborator

Please also add an entry to docs/history.md!

@kmuehlbauer kmuehlbauer added the enhancement New feature or request label Sep 27, 2023
@kmuehlbauer kmuehlbauer added this to the 0.4.0 milestone Sep 27, 2023
@syedhamidali
Copy link
Contributor Author

Hello Kai,

Just a quick question before I run pre-commit, should I use tempfile generated filename, or just comment this xd.io.to_cfradial1 statement in the notebook

@kmuehlbauer
Copy link
Collaborator

Just a quick question before I run pre-commit, should I use tempfile generated filename, or just comment this xd.io.to_cfradial1 statement in the notebook

Which notebook? If you mean your example notebook just keep the filename and write to the current directory.

@kmuehlbauer
Copy link
Collaborator

OK, we are very close now @syedhamidali. There are minimal tweakings needed to hook the example notebooks at the proper place in the docs. I can do this work after merging this while preparing the release. WDYT? Shall we merge?

@syedhamidali
Copy link
Contributor Author

OK, we are very close now @syedhamidali. There are minimal tweakings needed to hook the example notebooks at the proper place in the docs. I can do this work after merging this while preparing the release. WDYT? Shall we merge?

Thank you, @kmuehlbauer, please go ahead whenever you're ready.

@kmuehlbauer kmuehlbauer merged commit f46e5d1 into openradar:main Sep 27, 2023
12 checks passed
@kmuehlbauer
Copy link
Collaborator

Thanks @syedhamidali, 👍 💯 !

@mgrover1
Copy link
Collaborator

Thanks for all your hard work here @syedhamidali !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

Cf/Radial1 writer
3 participants