home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 392070454

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/2007#issuecomment-392070454 https://api.github.com/repos/pydata/xarray/issues/2007 392070454 MDEyOklzc3VlQ29tbWVudDM5MjA3MDQ1NA== 17162724 2018-05-25T14:11:20Z 2018-05-25T14:11:20Z CONTRIBUTOR

I was going to suggest this feature so glad others are interested.

In my use case I would like to smooth a daily climatology. My colleague uses matlab and uses https://www.mathworks.com/matlabcentral/fileexchange/52688-nan-tolerant-fast-smooth

Using the slice solution as @mathause showed above, it would look something like (using code from http://xarray.pydata.org/en/stable/examples/weather-data.html#toy-weather-data)

``` import numpy as np import pandas as pd import xarray as xr

times = pd.date_range('2000-01-01', '2010-12-31', name='time') annual_cycle = np.sin(2 * np.pi * (times.dayofyear.values / 366 - 0.28)) noise = 15 * np.random.rand(annual_cycle.size) data = 10 + (15 * annual_cycle) + noise da = xr.DataArray(data, coords=[times], dims='time')

da.plot()

Check variability at one day

da.groupby('time.dayofyear').std('time')[0]

da_clim = da.groupby('time.dayofyear').mean('time') _da_clim = xr.concat([da_clim[-15:], da_clim, da_clim[:15]], 'dayofyear') da_clim_smooth = _da_clim.rolling(dayofyear=31, center=True).mean().dropna('dayofyear')

da_clim_smooth.plot()

```

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