Skip to content

Add Scene function to use Hvplot backend visualization - #2106

Merged
mraspaud merged 42 commits into
pytroll:mainfrom
bornagain1981:main
Dec 15, 2023
Merged

mraspaud merged 42 commits into
pytroll:mainfrom
bornagain1981:main

Conversation

@bornagain1981

Copy link
Copy Markdown
Contributor

This pull request is my attempt to do something similar to "to_geoviews" function.
Hvplot syntax is easier than geoviews. In this case input datasets are optional. If no dataset is selected as input all scene variable keys is plotted and available in the output as obj.variable
It is no very fast, especially when there are many datasets and/or high definition coastlines. But for the time being it is ok. Future improvements may be to use multiprocessing library inside the function.

New function to plot Scene datasets as Hvplot Overlay
to_hvplot  function plot the  Scene datasets as Hvplot Overlay.
Added Luca Merucci in  authors.md  (we create this function together )
Comment thread satpy/scene.py Outdated
Comment thread satpy/scene.py Outdated
Comment thread satpy/scene.py Outdated
Comment thread satpy/scene.py Outdated
Comment thread satpy/scene.py Outdated
Comment thread satpy/scene.py Outdated
Comment thread satpy/scene.py Outdated
Comment thread satpy/scene.py Outdated
Comment thread satpy/scene.py Outdated
Comment thread satpy/scene.py Outdated
@bornagain1981 bornagain1981 changed the title Add Scene function to use Hvplot backend visualisation Add Scene function to use Hvplot backend visualization May 6, 2022
trying to follow and correct stickler-ci messages
Comment thread satpy/scene.py Outdated
Comment thread satpy/scene.py Outdated
@pnuu pnuu added enhancement code enhancements, features, improvements component:scene labels May 6, 2022
Comment thread satpy/scene.py Outdated
Comment thread satpy/scene.py Outdated
Comment thread satpy/scene.py Outdated
Comment thread satpy/scene.py Outdated
Comment thread satpy/scene.py Outdated
Comment thread satpy/scene.py Outdated
Comment thread satpy/scene.py Outdated
@bornagain1981

Copy link
Copy Markdown
Contributor Author

I added hvplot in extra and test sections of setup.py . But hvplot not found error keeps happening

@djhoese

djhoese commented May 7, 2022

Copy link
Copy Markdown
Member

Add it to https://github.com/pytroll/satpy/blob/main/continuous_integration/environment.yaml

Also, please wrap the import in scene.py in a try/except like:

try:
    import hvplot
except ImportError:
    hvplot = None

then later in your code do something like if hvplot is None: raise ImportError("'hvplot' must be installed to use this feature")

@codecov

codecov Bot commented May 7, 2022 •

Copy link
Copy Markdown

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (56df5da) 95.35% compared to head (9b0bcae) 95.35%.

Files Patch % Lines
satpy/scene.py 90.90% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2106      +/-   ##
==========================================
- Coverage   95.35%   95.35%   -0.01%     
==========================================
  Files         371      371              
  Lines       52464    52521      +57     
==========================================
+ Hits        50028    50082      +54     
- Misses       2436     2439       +3     
Flag Coverage Δ
behaviourtests 4.15% <3.44%> (-0.01%) ⬇️
unittests 95.97% <94.82%> (-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

coveralls commented May 7, 2022 •

Copy link
Copy Markdown

Coverage Status

Coverage: 95.264% (-0.06%) from 95.329% when pulling 09ad15d on bornagain1981:main into b92fe9e on pytroll:main.

@pnuu pnuu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some initial thoughts.

  1. Couple of suggestions inline for better wording and docstring formatting.
  2. Could there be some unit tests for .to_hvplot() with different scenarios that use all the sub-methods? That way possible syntax errors would be revealed. Then perhaps the returned plot could be inspected to have the correct attributes or something like that.

Comment thread satpy/scene.py Outdated
Comment thread satpy/scene.py Outdated
Comment thread satpy/scene.py Outdated
@mraspaud

Copy link
Copy Markdown
Member

Looks good, but would there be a way to add a unittest?

@coveralls

coveralls commented May 5, 2023 •

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 4892941043

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

  • 12 of 39 (30.77%) changed or added relevant lines in 1 file are covered.
  • 52 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.5%) to 94.914%

Changes Missing Coverage Covered Lines Changed/Added Lines %
satpy/scene.py 12 39 30.77%
Files with Coverage Reduction New Missed Lines %
satpy/utils.py 4 90.81%
satpy/scene.py 48 88.55%
Totals Coverage Status
Change from base Build 4859674839: -0.5%
Covered Lines: 39039
Relevant Lines: 41131

💛 - Coveralls

Comment thread satpy/scene.py Outdated
Comment on lines +1115 to +1116
if hvplot_xarray is None:
raise ImportError("'hvplot' must be installed to use this feature")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if hvplot_xarray is None:
raise ImportError("'hvplot' must be installed to use this feature")
import hvplot.xarray as hvplot_xarray

@bornagain1981

Copy link
Copy Markdown
Contributor Author

I added the holoviews module in setup file but Sphinx keep reporting "missing module error"

@bornagain1981

Copy link
Copy Markdown
Contributor Author

Couple more requests after running the code. And the tests :-)

I added the tests :)

@bornagain1981
bornagain1981 requested a review from pnuu December 15, 2023 10:32

@mraspaud mraspaud left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@mraspaud
mraspaud merged commit 7d1810b into pytroll:main Dec 15, 2023
@djhoese

djhoese commented Dec 15, 2023

Copy link
Copy Markdown
Member

Could we please get a follow up pull request that moves this functionality to a function in:

https://github.com/pytroll/satpy/blob/main/satpy/_scene_converters.py

This is a lot of code to add to an already bloated scene.py module. This _scene_converters.py module was created (admittedly after this PR was started but before it was merged) as a "dumping ground" for these types of conversions.

bornagain1981 added a commit to bornagain1981/satpy that referenced this pull request Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:scene enhancement code enhancements, features, improvements

Projects

Development

Successfully merging this pull request may close these issues.

7 participants