home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 577436046

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/3709#issuecomment-577436046 https://api.github.com/repos/pydata/xarray/issues/3709 577436046 MDEyOklzc3VlQ29tbWVudDU3NzQzNjA0Ng== 1550771 2020-01-22T23:33:17Z 2020-01-23T13:21:37Z NONE

I think the real power in this proposal is in the ability to chain operations on interactive components using an API that will be familiar to xarray users. We have a similar concept in HoloViews which allows you to build complex processing and visualization pipelines. I'll work through some examples in HoloViz ecosystem to show what is possible there and maybe provide some ideas or approaches that might work here.

Let's work with a relatively contrived but simple example and load the air_temperature sample dataset:

python airtemps = xr.tutorial.open_dataset('air_temperature') ds = hv.Dataset(airtemps)

In this example you explode your dataset into individual chunks for each longitude, then apply a reduction along the latitude and finally cast the output to a Curve giving us a Curve of the mean temperature at each longitude:

python curves = ds.groupby('lon', dynamic=True).apply.reduce(lat=np.mean).apply(hv.Curve).opts(width=600, framewise=True)

Now we decide we want to resample the data too, so we import the resample operation and apply it to our existing pipeline:

from holoviews.operation.timeseries import resample resample(curves, rule='7d')

But really we don't just want to compute the mean we want to pick the reduce function and we also want to be able to set the resampling frequency and pick a color. By combining Panel and HoloViews you can inject widget parameters at every stage:

```python function = pn.widgets.Select(name='Function', options={'mean': np.mean, 'min': np.min, 'max': np.max}) color = pn.widgets.ColorPicker(name='Color', value='#000000') rule = pn.widgets.TextInput(name='Rule', value='7d')

obj = (ds.groupby('lon', dynamic=True) .apply.reduce(lat=function) .apply(hv.Curve) .apply.opts(width=600, color=color, framewise=True) .apply(resample, rule=rule) )

hv_pane = pn.pane.HoloViews(obj)

pn.Row( hv_pane[0], pn.Column(*hv_pane[1][0], function, color, rule) ) ```

So this shows pretty clearly how useful this kind of chaining/pipeline building can be, especially when built on top of an API like xarray which allows for very powerful data manipulation. I don't have enough of a perspective to say how feasible it would be to implement something like this that comprehensively wraps xarray's API but I'd certainly love to see it. Whether it is built on Panel (which I am of course partial to as the author) or ipywidgets or even supporting both.

My main comments therefore are about the API, it is not clear to me based on what you have said so far which parts of the API are actually interactive, e.g. in this case:

python ida = da.interactive.isel(lat=50, lon=60) ida = (ida - ida.mean('time')).std(dim='time')

Is only sel/isel ever interactive or can other methods also be interactively set? If the answer is no then that's all clear enough and the scope relatively narrow but well defined. If however you intend the entire API (or at least some well defined subset of it) to be interactive then I think there should be some explicit way to declare which parts are interactive and where the values are coming from (and what the values should be if they can't be automatically determined). In the HoloViews example I showed above you explicitly supply widgets but if you don't want users to deal with manually laying things out then you could also just let the user supply the specification of the valid values. Something like in your first example:

python interactive.isel(da, plot_mean_over_time, time=slice(100, 500))

but expanded to include support for discrete lists of items, explicit widgets, and so on.

Hope that's at all helpful! I think the idea is really neat and it could be very powerful indeed.

{
    "total_count": 4,
    "+1": 4,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  552500673
Powered by Datasette · Queries took 0.806ms · About: xarray-datasette