home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 610341352

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-610341352 https://api.github.com/repos/pydata/xarray/issues/3709 610341352 MDEyOklzc3VlQ29tbWVudDYxMDM0MTM1Mg== 1550771 2020-04-07T11:50:30Z 2020-04-07T11:50:56Z NONE

Having taken the ideas presented here as inspiration the latest HoloViews release actually extends what we had described above and provides the capability to use arbitrary xarray methods to transform the data and control the parameters of those transforms using Panel based widgets. The HoloViews docs show one such example built on xarray which is built around so call dim expressions:

```python import panel as pn import xarray as xr

air_temp = xr.tutorial.load_dataset('air_temperature')

We declare a dim expression which uses the quantile method from the xr namespace

and provides a panel FloatSlider as the argument to the expression

q = pn.widgets.FloatSlider(name='quantile') quantile_expr = hv.dim('air').xr.quantile(q, dim='time')

We now wrap the xarray Dataset in a HoloViews one, apply the dim expression and cast the result to an image

temp_ds = hv.Dataset(air_temp, ['lon', 'lat']) transformed = temp_ds.apply.transform(air=quantile_expr).apply(hv.Image)

Now we display the resulting transformation pipeline alongside the widget

pn.Column(q, transformed.opts(colorbar=True, width=400)) ```

I am likely to integrate this capability with hvPlot with a more intuitive API, e.g. in this case I'd expect to be able to spell this something like this:

python xrds = xr.tutorial.load_dataset('air_temperature') q = pn.widgets.FloatSlider(name='quantile') quantile_expr = hv.dim('air').xr.quantile(q, dim='time') xrds.hvplot.image(transforms={'air': quantile_expr})

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