-
Notifications
You must be signed in to change notification settings - Fork 300
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 get_area_def
to cf reader
#1695
Add get_area_def
to cf reader
#1695
Conversation
Pyresample 1.20. 0 is being deployed right now. It looks like our test environment uses pyresample from conda-forge so we'll have to wait for that package to be pull requested, merged, released, and synced to the package repository. |
This is failing, so it'll have to go to the next release |
@zxdawn @BENR0 @mraspaud So I just ran this locally with pyresample main and it does actually fail even though the CI jobs here aren't pulling in the right version:
Edit: Note this is way better than the results from the old pyresample version:
|
It seems this was due to a switch of x and y in the test setup. Now it passes. One caveat though is that I had to add |
You may need to merge |
Indeed I totally forgot to do that. |
Codecov Report
@@ Coverage Diff @@
## main #1695 +/- ##
==========================================
+ Coverage 94.05% 94.13% +0.08%
==========================================
Files 290 293 +3
Lines 44639 45079 +440
==========================================
+ Hits 41987 42437 +450
+ Misses 2652 2642 -10
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@BENR0 sorry for the late reply. It looks good for the area case, but what happens if we are working with swath definitions (so we just have lons and lats)? will the reading crash then? |
I think that depends if this is covered by the implementations in pyresample. I can have a look at it even though I am not that familiar with the code. Maybe @TomLav can help because most of the code is from him. |
@BENR0 I just meant to verify that the changes you make do not change the behaviour of the lon/lat case, no need to implement it here. So if you can see that the lon/lat case still works as before, then this is good as it is now |
@mraspaud do I understand correctly that you mean if a netcdf written from a Satpy Scene which only has a swath definition is also read correctly? |
I haven't checked recently, but I would expect so. |
Although it might be the same problem as you are fixing here that the geolocation isn't actually read. |
Thanks for tagging me. I am maybe wondering if cf_reader should offer a richer interface to pyresample's from_cf() routine? For example, from_cf() offers the option to request the area_def attached to a specific netCDF variable which is not available from the cf_reader() at present. |
Indeed I think that would be something to think about to make it more generic in the future. Currently I think the reader is mainly for reading files written with Satpy which I think does not produce different area_defs in one file. So my opinion is to make this another PR (respectively create an feature issue for it). |
Thanks. Your approach is fine with me. |
@mraspaud regarding the swath definition case: You were right implementing the My opinion about this is that handling 2D lat/lon coordinate grids should also be implemented in the CF utils in pyresample because CF allows this kind of coordinates and therefore |
Hello. I think it is correct of pyresample's I don't know satpy. Can you link me to the current implementation of this feature in satpy, so that I can see how it is working? |
sounds good, feel free to refactor! |
@mraspaud ok will update this pr later today or tomorrow morning. |
@mraspaud I merged main and refactored out the instrument lines in the tests. |
@BENR0 regarding the failing tests on windows, I can recommend the usage of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@BENR0 Any time to look into the failing tests? |
@djhoese yes I looked at it and it seems that the failing test on windows is due to the same filename being used in two tests. I don't know if @mraspaud hint with the |
Yes the fixture seems to work better on windows than the tempdir functions |
@BENR0 if a single test function is writing multiple files then counting and produce unique filenames seems reasonable. Although this is probably a sign that the function should be split into multiple tests. Using |
@djhoese @mraspaud since the tests are using unittest.testcase the pytest Maybe I will have some time next week to work on this. If this should move forward faster I could just do the hacky filename numbering in the mean time. |
Give me 5 seconds. I'll fix it. |
Note I assume that if the filenames are in a separate tmp directory for each test that the filenames can be the same for each test. If that means the tests are no longer testing what they were before then we can make multiple fixtures for each filename format. |
:-D after I wrote my comment I started the same changes you made and tested it for the first test. But didn't have the time to finish it. Thanks for the work. |
Yeah, no problem. I'm avoiding my other work so this was a nice distraction and I've pytest'd quite a few test modules at this point. All you have to do now is merge the PR in your fork and the tests here should pass...I hope. |
Rewrite CF reader tests to use pytest
The unstable test failure seems to be a problem in rasterio...I hope. I'm going to try restarting the test and see what happens. If it fails again I think I'll merge this anyway and then work on figuring out what broke in a separate PR. |
Filed rasterio/rasterio#2591 with rasterio. Let's merge this and worry about the failing test somewhere else. |
This adds add area definition support for the cf reader. I fixed the tests and added a test area in geos projection as well as some preliminary assertions for testing the area.
I think the tests should be improved and extended to cover other areas. Currently the extent assertion is failing because of pytroll/pyresample#355.