pytroll / satpy

Python package for earth-observing satellite data processing
http://satpy.readthedocs.org/en/latest/
GNU General Public License v3.0
1.04k stars 287 forks source link

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

Open ameraner opened 2 weeks ago

ameraner commented 2 weeks ago

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.

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

codecov[bot] commented 2 weeks ago

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 6 commits behind head on main.

Files Patch % Lines
satpy/enhancements/__init__.py 92.85% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2817 +/- ## ======================================= Coverage 95.94% 95.94% ======================================= Files 366 366 Lines 53561 53611 +50 ======================================= + Hits 51389 51439 +50 Misses 2172 2172 ``` | [Flag](https://app.codecov.io/gh/pytroll/satpy/pull/2817/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytroll) | Coverage Δ | | |---|---|---| | [behaviourtests](https://app.codecov.io/gh/pytroll/satpy/pull/2817/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytroll) | `4.04% <1.96%> (-0.01%)` | :arrow_down: | | [unittests](https://app.codecov.io/gh/pytroll/satpy/pull/2817/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytroll) | `96.04% <98.03%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytroll#carryforward-flags-in-the-pull-request-comment) to find out more.

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

coveralls commented 2 weeks ago

Pull Request Test Coverage Report for Build 9500484605

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
satpy/enhancements/init.py 17 18 94.44%
<!-- Total: 34 35 97.14% -->
Totals Coverage Status
Change from base Build 9497248893: 0.002%
Covered Lines: 51589
Relevant Lines: 53715

💛 - Coveralls
ameraner commented 2 weeks ago

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 commented 1 week ago

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...

mraspaud commented 1 week ago

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

coveralls commented 1 week ago

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


Changes Missing Coverage Covered Lines Changed/Added Lines %
satpy/enhancements/init.py 13 14 92.86%
<!-- Total: 30 31 96.77% -->
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
ameraner commented 1 week ago

Tests passing again after blacklisting rioxarray 0.15.6

coveralls commented 4 days ago

Pull Request Test Coverage Report for Build 9694281199

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
satpy/enhancements/init.py 13 14 92.86%
<!-- Total: 30 31 96.77% -->
Totals Coverage Status
Change from base Build 9687731633: 0.009%
Covered Lines: 51642
Relevant Lines: 53768

💛 - Coveralls
ameraner commented 4 days ago

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.

coveralls commented 6 hours ago

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


Changes Missing Coverage Covered Lines Changed/Added Lines %
satpy/enhancements/init.py 13 14 92.86%
<!-- Total: 50 51 98.04% -->
Totals Coverage Status
Change from base Build 9687731633: 0.01%
Covered Lines: 51668
Relevant Lines: 53794

💛 - Coveralls