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
Implement generic set_orientation method for geostationary datasets #1194
Implement generic set_orientation method for geostationary datasets #1194
Conversation
Congratulations 🎉. DeepCode analyzed your code in 2.134 seconds and we found no issues. Enjoy a moment of no bugs ☀️. 👉 View analysis in DeepCode’s Dashboard | Configure the bot |
As mentioned in the video chat, it would be nice to allow omitting the dataset list if we want to set the orientation to all datasets. |
Codecov Report
@@ Coverage Diff @@
## master #1194 +/- ##
==========================================
+ Coverage 90.00% 90.03% +0.03%
==========================================
Files 218 218
Lines 31352 31498 +146
==========================================
+ Hits 28219 28360 +141
- Misses 3133 3138 +5
Continue to review full report at Codecov.
|
@mraspaud indeed, just implemented it! Along with support for StackedAreaDefinitions. |
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.
I have a couple of questions, but good work so far!
satpy/readers/yaml_reader.py
Outdated
logger.info("Dataset is not a geographical dataset and cannot be flipped.") | ||
return dataset | ||
|
||
if dataset.attrs['area'].proj_dict['proj'] != 'geos': |
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.
Is is possible to check the area's CRS here instead of the proj_dict?
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.
I guess so yes. What is the advantage of doing so?
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.
we're slowly migrating to using crs more instead of proj dicts
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.
also this here doesn't cover the projections defined by epsg code
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.
Understood. So I changed to:
if dataset.attrs['area'].crs.coordinate_operation.method_name not in ['Geostationary Satellite (Sweep Y)',
'Geostationary Satellite (Sweep X)']:
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.
👍 @mraspaud Can we be sure that the area def has a crs
property or do we need to fallback to the proj_dict?
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.
Iirc the crs is a property of the areadef so always there
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.
crs
should always exist if they are using a new-ish version of pyproj (2.0+).
Hi all, I noticed that the loading of ancillary variables was loosing the load kwargs, so I added that functionality as well. This is needed e.g. for the loading of pixel_quality maps in the FCI reader. So I would be very grateful if you could review it (again)! Thanks a lot in advance! |
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.
Nice work, and a very useful feature!
Oh, but some |
Yes, working on it! A hack that I used in my tests is getting back at me and is influencing other tests when running together. |
Tests are fixed and Travis is finally happy :) |
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, thanks for adding this nice feature. One question though: did you check that loading the ancillary variables still works and actually flips the data too?
Yes I checked using this: path_to_testdata = '/your/path/to/testdata/folder/'
scn = Scene(filenames=glob(path_to_testdata + "/*BODY*.nc"), reader=['fci_l1c_fdhsi'])
# load channel
scn.load(['ir_105'], upper_right_corner='NE')
plt.figure()
plt.imshow(scn['ir_105'].values)
# pixel quality was loaded automatically together with the channel as ancillary variable
# extract values and remove FillValue
pixel_quality = scn['ir_105'].ancillary_variables[0].values.astype('float32')
pixel_quality[pixel_quality == 255] = np.nan
plt.figure()
plt.imshow(pixel_quality)
# check that also the direct loading works
scn.load(['ir_105_pixel_quality'], upper_right_corner='NE')
pixel_quality_d = scn['ir_105_pixel_quality'].values.astype('float32')
pixel_quality_d[pixel_quality_d == 255] = np.nan
plt.figure()
plt.imshow(pixel_quality_d) the code yields these images: demonstrating that all variables are loaded and flipped correctly. |
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
This PR implements a generic set_orientation Scene method. This method allows to flip a dataset to a user-defined orientation, without having to resample the Scene.
Due to geometry constraints, this is only valid for Datasets in geos projection.
flake8 satpy