This repository has been archived by the owner on Apr 30, 2021. It is now read-only.
esmlab.resample reverses order of dimensions in time bounds variable #163
Labels
bug
Something isn't working
When I run the commands in the following code snippet, I see from the first two lines of output that
esmlab.resample
has reversed the order of dimensions intime:bounds
, compared to the input xr.Dataset. This causes problems for code assuming thattime
is the first dimension and the length-2 dimension is second.esmlab.resample
appears to makes this assumption itself. If you attempt to callesmlab.resample
on a xr.Dataset returned byesmlab.resample
, you get aValueError
exception, with the Traceback below. If I transposetime:bounds
before callingesmlab.resample
a 2nd time, there is no fatal error.Code Snippet
ds_ann[tb_name] = ds_ann[tb_name].transpose()
ds_ann_ann = esmlab.resample(ds_ann, freq='ann')
Results from Code Snippet
time_bnds dims in ds
('time', 'nbnd')
time_bnds dims in ds_ann
('nbnd', 'time')
Traceback (most recent call last):
File "foo6.py", line 14, in
ds_ann_ann = esmlab.resample(ds_ann, freq='ann')
File "/glade/work/klindsay/analysis/CESM2_coup_carb_cycle_JAMES/esmlab_dev/esmlab/core.py", line 769, in resample
ds = dset.esmlab.set_time(time_coord_name=time_coord_name).compute_ann_mean(
File "/glade/work/klindsay/analysis/CESM2_coup_carb_cycle_JAMES/esmlab_dev/esmlab/core.py", line 349, in set_time
self.setup()
File "/glade/work/klindsay/analysis/CESM2_coup_carb_cycle_JAMES/esmlab_dev/esmlab/core.py", line 354, in setup
self.compute_time()
File "/glade/work/klindsay/analysis/CESM2_coup_carb_cycle_JAMES/esmlab_dev/esmlab/core.py", line 82, in compute_time
groupby_coord = self.get_time_decoded(midpoint=True)
File "/glade/work/klindsay/analysis/CESM2_coup_carb_cycle_JAMES/esmlab_dev/esmlab/core.py", line 187, in get_time_decoded
only_use_cftime_datetimes=True,
File "/glade/work/klindsay/miniconda3/envs/CESM2_coup_carb_cycle_JAMES_tst/lib/python3.7/site-packages/xarray/core/common.py", line 257, in setattr
object.setattr(self, name, value)
File "/glade/work/klindsay/miniconda3/envs/CESM2_coup_carb_cycle_JAMES_tst/lib/python3.7/site-packages/xarray/core/dataarray.py", line 563, in data
self.variable.data = value
File "/glade/work/klindsay/miniconda3/envs/CESM2_coup_carb_cycle_JAMES_tst/lib/python3.7/site-packages/xarray/core/variable.py", line 1971, in data
Variable.data.fset(self, data)
File "/glade/work/klindsay/miniconda3/envs/CESM2_coup_carb_cycle_JAMES_tst/lib/python3.7/site-packages/xarray/core/variable.py", line 345, in data
raise ValueError("replacement data must match the Variable's shape")
ValueError: replacement data must match the Variable's shape
Output of
esmlab.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 3.10.0-693.21.1.el7.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
esmlab: 2019.4.27.post43
xarray: 0.14.0
pandas: 0.25.2
numpy: 1.17.3
scipy: 1.3.1
xesmf: 0.2.1
cftime: 1.0.3.4
dask: 2.6.0
distributed: 2.6.0
setuptools: 41.4.0
pip: 19.3.1
conda: None
pytest: None
IPython: 7.9.0
sphinx: None
The text was updated successfully, but these errors were encountered: