issue_comments: 390267025
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/2145#issuecomment-390267025 | https://api.github.com/repos/pydata/xarray/issues/2145 | 390267025 | MDEyOklzc3VlQ29tbWVudDM5MDI2NzAyNQ== | 22245117 | 2018-05-18T16:50:47Z | 2018-05-22T19:18:34Z | CONTRIBUTOR | In my previous comment I said that this would be useful for staggered grids, but then I realized that resample only operates on the time dimension. Anyway, here is my example: ```python import xarray as xr import pandas as pd import numpy as np Create coordinatestime = pd.date_range('1/1/2018', periods=365, freq='D') space = pd.np.arange(10) Create random variablesvar_withtime1 = np.random.randn(len(time), len(space)) var_withtime2 = np.random.randn(len(time), len(space)) var_timeless1 = np.random.randn(len(space)) var_timeless2 = np.random.randn(len(space)) Create datasetds = xr.Dataset({'var_withtime1': (['time', 'space'], var_withtime1), 'var_withtime2': (['time', 'space'], var_withtime2), 'var_timeless1': (['space'], var_timeless1), 'var_timeless2': (['space'], var_timeless2)}, coords={'time': (['time',], time), 'space': (['space',], space)}) Standard resample: this add the time dimension to the timeless variablesds_resampled = ds.resample(time='1M').mean() My workaround: this does not add the time dimension to the timeless variablesds_withtime = ds.drop([ var for var in ds.variables if not 'time' in ds[var].dims ]) ds_timeless = ds.drop([ var for var in ds.variables if 'time' in ds[var].dims ]) ds_workaround = xr.merge([ds_timeless, ds_withtime.resample(time='1M').mean()]) ``` Datasets: ```
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
323839238 |