satpy icon indicating copy to clipboard operation
satpy copied to clipboard

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

Open ameraner opened this issue 1 year ago • 10 comments

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.

  • [x] Tests added
  • [x] 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 avatar Jun 13 '24 11:06 ameraner

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 :warning:
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%) :arrow_down:
unittests 96.04% <98.03%> (+<0.01%) :arrow_up:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jun 13 '24 11:06 codecov[bot]

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%
<!-- Total: 34 35
Totals Coverage Status
Change from base Build 9497248893: 0.002%
Covered Lines: 51589
Relevant Lines: 53715

💛 - Coveralls

coveralls avatar Jun 13 '24 13:06 coveralls

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: https://github.com/pytroll/trollimage/pull/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 avatar Jun 14 '24 10:06 ameraner

After the released update in https://github.com/pytroll/trollimage/pull/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...

ameraner avatar Jun 24 '24 11:06 ameraner

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

mraspaud avatar Jun 24 '24 13:06 mraspaud

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%
<!-- Total: 30 31
Files with Coverage Reduction New Missed Lines %
satpy/readers/olci_nc.py 8 94.5%
<!-- Total: 8
Totals Coverage Status
Change from base Build 9596553856: 0.002%
Covered Lines: 51616
Relevant Lines: 53742

💛 - Coveralls

coveralls avatar Jun 24 '24 14:06 coveralls

Tests passing again after blacklisting rioxarray 0.15.6

ameraner avatar Jun 24 '24 15:06 ameraner

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%
<!-- Total: 30 31
Totals Coverage Status
Change from base Build 9687731633: 0.009%
Covered Lines: 51642
Relevant Lines: 53768

💛 - Coveralls

coveralls avatar Jun 27 '24 10:06 coveralls

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.

ameraner avatar Jun 27 '24 11:06 ameraner

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%
<!-- Total: 50 51
Totals Coverage Status
Change from base Build 9687731633: 0.01%
Covered Lines: 51668
Relevant Lines: 53794

💛 - Coveralls

coveralls avatar Jul 01 '24 12:07 coveralls