pydata / pydata/xarray

Dataset.resample() adds time dimension to independent variables

Open
#2,145 5 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic-groupby
Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

Code Sample, a copy-pastable example if possible
ds = ds.resample(time='1D',keep_attrs=True).mean()

Problem description

I'm downsampling in time a dataset which also contains timeless variables.
I've noticed that resample adds the time dimension to the timeless variables.
One workaround is:

  1. Split the dataset in a timeless and a time-dependent dataset
  2. Resample the time-dependent dataset
  3. Merge the two datasets

This is not a big deal, but I was wondering if I'm missing some flag that avoids this behavior.
If not, is it something that can be easily implemented in resample?
It would be very useful for datasets with variables on staggered grids.

Output of xr.show_versions()
INSTALLED VERSIONS ------------------ commit: None python: 3.6.1.final.0 python-bits: 64 OS: Linux OS-release: 3.10.0-693.17.1.el7.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: None LOCALE: None.None

xarray: 0.10.3
pandas: 0.20.2
numpy: 1.12.1
scipy: 0.19.1
netCDF4: 1.2.4
h5netcdf: 0.5.1
h5py: 2.7.0
Nio: None
zarr: None
bottleneck: 1.2.1
cyordereddict: None
dask: 0.17.4
distributed: 1.21.8
matplotlib: 2.0.2
cartopy: 0.16.0
seaborn: 0.7.1
setuptools: 39.1.0
pip: 9.0.1
conda: 4.5.3
pytest: 3.1.2
IPython: 6.1.0
sphinx: 1.6.2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Dataset.resample() entry point and reproduce the provided example with both time-dependent and timeless variables. Trace how resampling handles independent variables; done means timeless variables retain no time dimension while time-dependent variables are resampled as before.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.