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

Implement support to set alpha range in create_colormap and yaml colorize enhancements #2817

Merged
merged 14 commits into from
Jul 8, 2024

Conversation

ameraner
Copy link
Member

@ameraner ameraner commented Jun 13, 2024

This PR adds the possibility to define an alpha channel range to be applied to a colorise colormap, e.g. through the yaml enhancement configuration.

  • Tests added
  • Fully documented

With this, composites like the one below are more easily achievable, with e.g.

  flash_area:
    standard_name: flash_area
    operations:
    - name: colorize
      method: !!python/name:satpy.enhancements.colorize
      kwargs:
        palettes:
        - {colors: ylorrd, min_value: 0, max_value: 20,
           min_alpha: 100, max_alpha: 255}

image

@ameraner ameraner added enhancement code enhancements, features, improvements documentation component:enhancements PCW Pytroll Contributors' Week labels Jun 13, 2024
@ameraner ameraner self-assigned this Jun 13, 2024
Copy link

codecov bot commented Jun 13, 2024

Codecov Report

Attention: Patch coverage is 98.03922% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.94%. Comparing base (834f45d) to head (85f11a3).
Report is 351 commits behind head on main.

Files with missing lines Patch % Lines
satpy/enhancements/__init__.py 92.85% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2817   +/-   ##
=======================================
  Coverage   95.94%   95.94%           
=======================================
  Files         366      366           
  Lines       53561    53611   +50     
=======================================
+ Hits        51389    51439   +50     
  Misses       2172     2172           
Flag Coverage Δ
behaviourtests 4.04% <1.96%> (-0.01%) ⬇️
unittests 96.04% <98.03%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@coveralls
Copy link

coveralls commented Jun 13, 2024

Pull Request Test Coverage Report for Build 9500484605

Details

  • 34 of 35 (97.14%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.002%) to 96.042%

Changes Missing Coverage Covered Lines Changed/Added Lines %
satpy/enhancements/init.py 17 18 94.44%
Totals Coverage Status
Change from base Build 9497248893: 0.002%
Covered Lines: 51589
Relevant Lines: 53715

💛 - Coveralls

Copy link
Member

@djhoese djhoese left a comment

Choose a reason for hiding this comment

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

The colormap logic was actually moved to trollimage a while ago (by @gerritholl I think) but I don't think we ever migrated Satpy to use the trollimage function or required satpy to use the newer version of trollimage. I think this PR should maybe be migrated to trollimage and a separate PR be setup to switch to requiring the version of trollimage that introduced this logic. Sorry I don't have more details about what changed and what should be changed. It's been a while since I've looked at this.

https://github.com/pytroll/trollimage/blob/640fb8aca6cf384fa17721ed1ab982df459e5ac2/trollimage/colormap.py#L417-L422

@ameraner
Copy link
Member Author

ameraner commented Jun 14, 2024

Hi Dave, thanks for the review! Indeed, at the beginning I thought of this only as an improved interface from satpy to the Colorbar, but then I also realised that this functionality is probably useful and better places in trollimage directly.

So I created a new method in trollimage: pytroll/trollimage#170

I updated this PR accordingly, but kept the tests for the new functionality here, and and of course they're failing now since we need the trollimage PR released first.

@ameraner ameraner requested a review from djhoese June 14, 2024 10:20
@ameraner ameraner added the dependencies Pull requests that update a dependency file label Jun 24, 2024
@ameraner
Copy link
Member Author

After the released update in pytroll/trollimage#170, and the according change in the required trollimage version, the tests related to this PR are passing again as expected, so from that point of view I believe this PR is ready.

However, now there are failures on the sar_c_safe reader tests that are unrelated to this PR...

@mraspaud
Copy link
Member

The SAR tests broke because of backwards incompatibility introduced in rioxarray release 0.15.6 and in particular this PR corteva/rioxarray#787
I suggest blacklisting rioxarray 0.15.6 for now, until we figure a solution with @snowman2 on that PR

@coveralls
Copy link

coveralls commented Jun 24, 2024

Pull Request Test Coverage Report for Build 9647136913

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 30 of 31 (96.77%) changed or added relevant lines in 2 files are covered.
  • 8 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.002%) to 96.044%

Changes Missing Coverage Covered Lines Changed/Added Lines %
satpy/enhancements/init.py 13 14 92.86%
Files with Coverage Reduction New Missed Lines %
satpy/readers/olci_nc.py 8 94.5%
Totals Coverage Status
Change from base Build 9596553856: 0.002%
Covered Lines: 51616
Relevant Lines: 53742

💛 - Coveralls

@ameraner
Copy link
Member Author

Tests passing again after blacklisting rioxarray 0.15.6

@coveralls
Copy link

coveralls commented Jun 27, 2024

Pull Request Test Coverage Report for Build 9694281199

Details

  • 30 of 31 (96.77%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.009%) to 96.046%

Changes Missing Coverage Covered Lines Changed/Added Lines %
satpy/enhancements/init.py 13 14 92.86%
Totals Coverage Status
Change from base Build 9687731633: 0.009%
Covered Lines: 51642
Relevant Lines: 53768

💛 - Coveralls

@ameraner
Copy link
Member Author

I reverted the rioxarray blacklist after Martin's fix, and tests pass again now after Dave's fixes yesterday.

So from my side this is good to go again.

Copy link
Member

@djhoese djhoese left a comment

Choose a reason for hiding this comment

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

Looks pretty good. Just a few small requests.

satpy/tests/enhancement_tests/test_enhancements.py Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Jul 1, 2024

Pull Request Test Coverage Report for Build 9743559474

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 50 of 51 (98.04%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 96.048%

Changes Missing Coverage Covered Lines Changed/Added Lines %
satpy/enhancements/init.py 13 14 92.86%
Totals Coverage Status
Change from base Build 9687731633: 0.01%
Covered Lines: 51668
Relevant Lines: 53794

💛 - Coveralls

@ameraner ameraner requested a review from djhoese July 1, 2024 13:32
Copy link
Member

@djhoese djhoese left a comment

Choose a reason for hiding this comment

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

Looks good to me. I'm not in love with color_scale = being accessed outside of _get_cmap_from_palette_info as that information is part of the palette, but I don't see an obvious better solution given what you need to do.

If we can get one other maintainers review that'd be great, but if no one is available in the next day or so I can merge this for you so you can continue your work.

@djhoese djhoese merged commit 3a742c2 into pytroll:main Jul 8, 2024
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:enhancements dependencies Pull requests that update a dependency file documentation enhancement code enhancements, features, improvements PCW Pytroll Contributors' Week
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants