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 palette application for pps 2018 products #542

Merged
merged 5 commits into from
Dec 11, 2018

Conversation

mraspaud
Copy link
Member

@mraspaud mraspaud commented Dec 10, 2018

This PR fixes the palette handling for PPS 2018 products. It allows the use of the palette_meanings attribute when available (palette indices).

  • Tests added
  • Tests passed
  • Passes git diff origin/master -- "*py" | flake8 --diff
  • Fully documented

@coveralls
Copy link

coveralls commented Dec 10, 2018

Coverage Status

Coverage increased (+0.5%) to 75.429% when pulling e8b0260 on mraspaud:fix-palette-nwcsafpps into 2c86130 on pytroll:master.

@codecov
Copy link

codecov bot commented Dec 10, 2018

Codecov Report

Merging #542 into master will increase coverage by 0.48%.
The diff coverage is 86.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #542      +/-   ##
==========================================
+ Coverage   74.94%   75.42%   +0.48%     
==========================================
  Files         136      136              
  Lines       18657    18774     +117     
==========================================
+ Hits        13982    14161     +179     
+ Misses       4675     4613      -62
Impacted Files Coverage Δ
satpy/tests/compositor_tests/__init__.py 98.73% <100%> (+0.28%) ⬆️
satpy/readers/nc_nwcsaf.py 36.12% <16.66%> (-0.06%) ⬇️
satpy/composites/cloud_products.py 87.87% <66.66%> (+64.54%) ⬆️
satpy/composites/__init__.py 47.44% <87.5%> (+3.19%) ⬆️
satpy/tests/test_resample.py 98.89% <0%> (+0.27%) ⬆️
satpy/resample.py 88.79% <0%> (+7.19%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2c86130...e8b0260. Read the comment docs.

@@ -162,14 +162,17 @@ def scale_dataset(self, dsid, variable, info):
except AttributeError:
pass

if 'palette_meanings' in variable.attrs:
variable.attrs['palette_meanings'] = [int(val)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are NetCDF4 files right? Can't you store a series of numbers in an attribute? I know this is just the reader of these files and not the writer, just curious.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it's nc files, but I'm not sure attributes can store anything else than atomic types (numbers or strings)

dims=['value', 'band'])
palette.attrs['palette_meanings'] = [2, 3, 4]
cmap, sqpal = cmap_comp.build_colormap(palette, np.uint8, {})
self.assertTrue(np.allclose(cmap.values, [2, 3, 4]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do np.testing.assert_allclose(...) instead of self.assertTrue(np.allclose(...)). You may have known that already and prefer the unittest based assert and if so, no problem.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that, but I usually use unittest's assert to make use of self and avoid a style error of not using it.

@mraspaud mraspaud merged commit 12298a9 into pytroll:master Dec 11, 2018
@mraspaud mraspaud deleted the fix-palette-nwcsafpps branch December 11, 2018 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants