home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 1265344088

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
1265344088 I_kwDOAMm_X85La55Y 6677 inconsistency between resample and plotting 15239248 open 0     0 2022-06-08T21:41:03Z 2022-06-08T21:41:03Z   NONE      

What is your issue?

I believe there is an inconsistency between using the resample function (left labeled) and the plotting function (center labeled). Maybe the example below help illustrating the issue:

```python d = [ [1,0,0,0,0,0,1,0,0,0,0,0], [0,0,1,1,0,0,0,1,1,1,1,0], [0,0,0,0,0,0,0,0,0,0,1,0], ]

t = pd.date_range('2000-01-01 00:05','2000-01-01 00:17',freq='1t',closed='left')

da = xr.DataArray(d,dims=['i','t'],coords={'t':t})

f,axs = plt.subplots(4,sharex=True,constrained_layout=True)

def plot(da,ax_): return da_.plot(ax=ax_,add_colorbar=False,vmin=0,vmax=1.001,levels=11)

for ax,tt in zip(axs[1:],['2t','3t','4t']): da_ = da.resample({'t':tt}).mean() gr = plot(da,ax) ax.set_title(f'resample: {tt}')

_plot(da,axs[0]) axs[0].set_title('orginal')

for ax in axs: ax.grid() ax.set_xticks(t) ax.set_xticklabels(t.strftime('%M')) ax.set_xlim(pd.to_datetime('2000-01-01 00:00'),pd.to_datetime('2000-01-01 00:20'))

f.colorbar(gr,ax=axs)

```

In the example above, the most relevant problem is the high value at min 11 in panel 1 that after resampling to 4 minutes in panel 4 gets shifted and displayed between minutes 6 and 10. I know that i can shift the results from resample with the parameter loffset (='30s' ). but this that not help since now the high value in panel 1 (min 11) is also shifted to minutes 6-10 in panel 4 ```python d = [ [1,0,0,0,0,0,1,0,0,0,0,0], [0,0,1,1,0,0,0,1,1,1,1,0], [0,0,0,0,0,0,0,0,0,0,1,0], ]

t = pd.date_range('2000-01-01 00:05','2000-01-01 00:17',freq='1t',closed='left')

da = xr.DataArray(d,dims=['i','t'],coords={'t':t})

f,axs = plt.subplots(4,sharex=True,constrained_layout=True)

def plot(da,ax_): return da_.plot(ax=ax_,add_colorbar=False,vmin=0,vmax=1.001,levels=11)

for ax,tt in zip(axs[1:],['2t','3t','4t']): da_ = da.resample({'t':tt},loffset='30s').mean() gr = plot(da,ax) ax.set_title(f'resample: {tt}')

_plot(da,axs[0]) axs[0].set_title('orginal')

for ax in axs: ax.grid() ax.set_xticks(t) ax.set_xticklabels(t.strftime('%M')) ax.set_xlim(pd.to_datetime('2000-01-01 00:00'),pd.to_datetime('2000-01-01 00:20'))

f.colorbar(gr,ax=axs)

```

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/6677/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 issue

Links from other tables

  • 1 row from issues_id in issues_labels
  • 0 rows from issue in issue_comments
Powered by Datasette · Queries took 0.719ms · About: xarray-datasette