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

Add compute method to Scene #1015

Closed
BENR0 opened this issue Dec 11, 2019 · 3 comments · Fixed by #1017
Closed

Add compute method to Scene #1015

BENR0 opened this issue Dec 11, 2019 · 3 comments · Fixed by #1017
Labels
component:scene enhancement code enhancements, features, improvements

Comments

@BENR0
Copy link
Collaborator

BENR0 commented Dec 11, 2019

Feature Request

Sometimes I am in the situation that I need to compute all DataAarrays in the Scene. For example if I want to use a resampled Scene in two different processing streams and don't want to calculate the resampling twice.

Describe the solution you'd like
The Scene could have a "compute()" method which just calls "compute()" on each DataArray:

def compute():
    for k in scn_msg.datasets.keys():
        scn[k] = scn[k].compute()

Maybe this can even be more generic like an "apply" method. This could then be used for all DataArray methods like "chunks()" etc.

Describe any changes to existing user workflow
This would not change the existing user workflows.

@djhoese
Copy link
Member

djhoese commented Dec 11, 2019

I think it would best to reflect the xarray interfaces for this. My hope is in the future that the Scene could be almost entirely replaced by an xarray Dataset object, but we aren't there yet. With that in mind, it would be nice to have a compute() and a persist() method. And actually @BENR0 based on what you've said you may actually want the persist() method for your workflow instead of compute(). Using persist computes things but makes them appear as dask arrays which means they should work better with the rest of Satpy.

@djhoese djhoese added component:scene enhancement code enhancements, features, improvements labels Dec 11, 2019
@BENR0
Copy link
Collaborator Author

BENR0 commented Dec 11, 2019

Hey @djhoese you are right and most of the time I am actually using persist. Yes I think reflecting the interfaces was basically what I wanted to say. The replacement with xarray Datasets would be nice I think I talked about this with @mraspaud during the meeting at Eumetsat in Darmstadt last year in the context of the Multiscene and the DatasetID.

Sometime ago I started a list with some changes that would be needed as far as I could see but I can't find it right now. Is there a "timeline" if and when this transition is roughly planned or has somebody started development on this already?
Up to then maybe the xarray interfaces can be included in the Scene as it is right know? Probably the example above is not the optimal way to implement it. If you have an idea about it let me know I would be willing to put something together.

@djhoese
Copy link
Member

djhoese commented Dec 11, 2019

I think the example code you have above is good and should be used for persist and compute. There is no timeline for moving the Scene to be more xarray.Dataset-y. There are too many things that the Scene can do that don't fit in the generic "container" style of an xarray Dataset (composite dependency handling and generation is the big one). It is just something I'm keeping in mind as we continue forward with features. Even if the Scene was transitioned to be a Dataset, the interfaces currently established would have to be preserved for at least a couple versions if we don't want to completely anger the entire userbase.

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
None yet
Development

Successfully merging a pull request may close this issue.

2 participants