-
Notifications
You must be signed in to change notification settings - Fork 303
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
Fix swath builtin coordinates not being used #1541
Conversation
DeepCode failed to analyze this pull requestSomething went wrong despite trying multiple times, sorry about that. |
Thanks! My tests with avhrr and viirs data reading back with Will take a look at the code later. |
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, but I guess someone as to restart the tests
@@ -823,19 +823,31 @@ def _load_dataset_with_area(self, dsid, coords, **kwargs): | |||
if not file_handlers: | |||
return | |||
|
|||
area = self._load_dataset_area(dsid, file_handlers, coords, **kwargs) | |||
|
|||
try: |
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, but how will moving this below affect reading other netcdf data? We rely on the tests?
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 do rely on tests yes, and these are failing. I have to take a look at the problem
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 don't see anything wrong with this in principle. You mentioned Satpy wasn't able to make an area from the existing information in the YAML, why not?
@djhoese because there is no |
Codecov Report
@@ Coverage Diff @@
## master #1541 +/- ##
==========================================
+ Coverage 92.02% 92.03% +0.01%
==========================================
Files 249 249
Lines 36309 36384 +75
==========================================
+ Hits 33413 33486 +73
- Misses 2896 2898 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
To very small things otherwise I think I understand all the yaml reader changes.
satpy/readers/yaml_reader.py
Outdated
lats = coord | ||
if lons is None or lats is None: | ||
raise ValueError('Missing longitude or latitude coordinate: ' + str(coords)) | ||
return lats, lons |
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.
Nitpick, the return value is the opposite of the method name. Prefer lon, lats I think.
satpy/readers/yaml_reader.py
Outdated
if area is not None: | ||
ds.attrs['area'] = area | ||
ds = add_crs_xy_coords(ds, area) | ||
return ds | ||
|
||
@staticmethod | ||
def _assign_builtin_coords(coords, ds): |
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.
Thoughts on changing the name to something like _assign_existing_coords
or _assign_coords_from_data_array
? To me builtin
is ambiguous.
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 can not see any problems here. So
LGMT
self.assertTrue(np.all(scn_['image0'].data == self.scene['image0'].data)) | ||
self.assertTrue(np.all(scn_['lat'].data == self.scene['lat'].data)) # lat loaded as dataset | ||
self.assertTrue(np.all(scn_['image0'].coords['lon'] == self.scene['lon'].data)) # lon loded as coord | ||
finally: |
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.
Hm, never seen a try without an except. So any exceptions raise before finally
is kind of ignored with this approach? Instead of
except:
pass
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.
No, the exception isn't ignored, but 'finally' ensures its part of the code is executed before raising the exception.
This PR allows satpy to use longitudes and latitudes provided as coordinates to other dataarrays to create the dataarrays'
area
attribute.Consider for example:
This dataarray contains already populated longitude and latitude coordinates (it is being read from a well-constructed netcdf file), but satpy fails to create the necessary
area
attribute from it.This PR fixes it in a manner that uses the builtin coordinates if no other coordinates are provided from eg the dataset definitions of the reader's yaml file.
flake8 satpy