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

Fix tropomi_l2 reader not using y and x dimension names #1031

Merged
merged 1 commit into from Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions satpy/readers/tropomi_l2.py
Expand Up @@ -145,6 +145,15 @@ def get_metadata(self, data, ds_info):

return metadata

def _rename_dims(self, data_arr):
"""Normalize dimension names with the rest of Satpy."""
dims_dict = {}
if 'ground_pixel' in data_arr.dims:
dims_dict['ground_pixel'] = 'x'
if 'scanline' in data_arr.dims:
dims_dict['scanline'] = 'y'
return data_arr.rename(dims_dict)

def get_dataset(self, ds_id, ds_info):
"""Get dataset."""
logger.debug("Getting data for: %s", ds_id.name)
Expand All @@ -154,4 +163,5 @@ def get_dataset(self, ds_id, ds_info):
fill = data.attrs.pop('_FillValue')
data = data.squeeze()
data = data.where(data != fill)
data = self._rename_dims(data)
return data
6 changes: 5 additions & 1 deletion satpy/tests/reader_tests/test_tropomi_l2.py
Expand Up @@ -77,7 +77,7 @@ def get_test_content(self, filename, filename_info, filetype_info):
for key, val in file_content.items():
if isinstance(val, np.ndarray):
if val.ndim > 1:
file_content[key] = DataArray(val, dims=('y', 'x'))
file_content[key] = DataArray(val, dims=('scanline', 'ground_pixel'))
else:
file_content[key] = DataArray(val)
file_content['PRODUCT/latitude'].attrs['_FillValue'] = -999.0
Expand Down Expand Up @@ -139,6 +139,8 @@ def test_load_no2(self):
self.assertEqual(d.attrs['sensor'], 'TROPOMI')
self.assertIn('area', d.attrs)
self.assertIsNotNone(d.attrs['area'])
self.assertIn('y', d.dims)
self.assertIn('x', d.dims)

def test_load_so2(self):
"""Load SO2 dataset"""
Expand All @@ -155,6 +157,8 @@ def test_load_so2(self):
self.assertEqual(d.attrs['platform_shortname'], 'S5P')
self.assertIn('area', d.attrs)
self.assertIsNotNone(d.attrs['area'])
self.assertIn('y', d.dims)
self.assertIn('x', d.dims)


def suite():
Expand Down