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

Implements a html representation for the Scene #2171

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

BENR0
Copy link
Collaborator

@BENR0 BENR0 commented Aug 11, 2022

While many users use Satpy in automated scripts in a more interactive workflow in Jupyter notebooks printing the Scene just outputs a concatenated list of the string representation of xarray DataArrays.
In my opinion this does not give a good overview of the Scene and what is contained in it.

Inspired by the xarray html representation of Datasets and DataArrays (in fact for some parts I reused code/css from xarray, more about that below) I implemented a html representation for the Scene.

The Scene can potentially contain data from different platforms/sensors with different areas, resolutions and extents. The current implementation tries to capture this and give a somewhat structured overview of the Scene resulting in the following design idea:

  • it lists the contained data by platform/sensor first (collapsible)
  • for each platform/sensor it lists the data by area definition (projection)
  • for each area definition (projection) the area properties and a map overview is included which can be folded out followed by the contained xarray DataArrays by resolution (here the html representation of xarray Datasets is reused)

Collapsed view

satpy_scene_repr_html_folded

Uncollapsed view

satpy_scene_repr_html_unfolded

In progress "features"

  • Add some information e.g. number of data items, etc. to the headers when sections area collapsed
  • Add other information other than dataset name from DataId to each data item row?

Todos

Right now this mixes in some code/css from pytroll/pyresample#450 because when I started working on this I thought that I might reuse the html representation of the area definition. Turns out I wanted it to look
a little different in the html view of the Scene :-D. Apart from that I duplicated some code/css from xarray for the display of the data (this also leads to a little display bug when somewhere in the notebook another xarray object is shown). So obvious todos are:

  • refactor css
    • refactor xarray code/css to use satpy css class names
    • seperate pyresample code/css completely from satpy
  • refactor the formatting code

Design questions and ideas

Obviously "design" is always opinionated so some of my questions/ideas are:

  • Does it make sense to list by platform/sensor, area/projection, resolution or should it be something different?
  • How do you feel about the layout/look?
  • One thing that I did not cover yet is: what to do if there are different extents? One thing I am probably going to implement is to also show the extent with the area attributes when it is the same for all data items, which should cover the most basic situation.
  • Is there something missing that would be informative to show?
  • Should there be an option to activate showing available but not yet loaded datasets based on the reader (greyed out)? This would make it a lot easier for users to get the dataset names interactively and also see what is supported.
  • in Area definition html representation for Jupyter notebooks pyresample#450 @djhoese suggested to maybe move the css/icon html inline. Haven't done that in Area definition html representation for Jupyter notebooks pyresample#450 yet but tried it out here. It does have some advantages (not needing extra files/directories in the repo, no loading function). I didn't really test if the caching as done in xarray and which I reused is better performance wise when more than one Scene is view in a notebook.
  • Curently I use toolz for groupby's on dictionaries. I guess one could reimplement this funcionality if that dependency is not wanted. So what's the opinion about that?
  • other things/ideas?

Another note: while I got it looking and working the way I wanted it the css/html probably is a mess (haven't done any in a long time). So if there are any html/css wizards out there help is appreciated :-).

@mraspaud
Copy link
Member

Maybe some food for thought: I like the way the xsar project shows the coverage of the data on a map, see here https://cyclobs.ifremer.fr/static/sarwing_datarmor/xsar/examples/xsar_advanced.html#Open-a-dataset-with-a-xsar.Sentinel1Meta-object

@BENR0
Copy link
Collaborator Author

BENR0 commented Aug 16, 2022

@mraspaud yes I also have been thinking about a more interactive variant with bokeh plots. But since this would introduce quite a view new dependencies I first wanted to keep it "low profile". Additionally the question would be showing a view of the AreaDefinition or showing the coverage of the data as a plot. The latter, especially in the case of interactive plots, would be nice for very local areas where one would not necessarily know where they are located just by the country borders. In that case one could "zoom" out. For the non interactive case I have been thinking if an inset feature for the plot would be something worth implementing.

Copy link

codecov bot commented Nov 25, 2024

Codecov Report

Attention: Patch coverage is 23.40426% with 72 lines in your changes missing coverage. Please review.

Project coverage is 95.96%. Comparing base (80c93cb) to head (5fde8ca).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
satpy/formatting_html.py 21.97% 71 Missing ⚠️
satpy/scene.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2171      +/-   ##
==========================================
- Coverage   96.08%   95.96%   -0.13%     
==========================================
  Files         377      378       +1     
  Lines       55155    55249      +94     
==========================================
+ Hits        52997    53019      +22     
- Misses       2158     2230      +72     
Flag Coverage Δ
behaviourtests 3.97% <23.40%> (+0.03%) ⬆️
unittests 96.05% <23.40%> (-0.13%) ⬇️

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.


🚨 Try these New Features:

@coveralls
Copy link

Pull Request Test Coverage Report for Build 12010382256

Details

  • 23 of 95 (24.21%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.1%) to 96.07%

Changes Missing Coverage Covered Lines Changed/Added Lines %
satpy/scene.py 2 3 66.67%
satpy/formatting_html.py 21 92 22.83%
Totals Coverage Status
Change from base Build 11979875132: -0.1%
Covered Lines: 53264
Relevant Lines: 55443

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants