You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When slicing over a dimension that is not ordered monotonously increasing, .sel returns an empty slice (which is ok) but it also doesn't complain (which is not very helpful).
importxarrayasxrprint(xr.__version__)
ds=xr.tutorial.open_dataset('rasm')
print('right order selects correctly:')
print(ds.sel(x=slice(10,15)))
ds['x'] =ds.x[::-1]
print('wrong order returns empty slice, silently:')
print(ds.sel(x=slice(10,15)))
Returns:
0.12.1
right order selects correctly:
<xarray.Dataset>
Dimensions: (time: 36, x: 5, y: 205)
Coordinates:
* time (time) object 1980-09-16 12:00:00 ... 1983-08-17 00:00:00
xc (y, x) float64 ...
yc (y, x) float64 ...
Dimensions without coordinates: x, y
Data variables:
Tair (time, y, x) float64 ...
Attributes:
title: /workspace/jhamman/processed/R1002RBRxaaa01a/l...
institution: U.W.
source: RACM R1002RBRxaaa01a
output_frequency: daily
output_mode: averaged
convention: CF-1.4
references: Based on the initial model of Liang et al., 19...
comment: Output from the Variable Infiltration Capacity...
nco_openmp_thread_number: 1
NCO: "4.6.0"
history: Tue Dec 27 14:15:22 2016: ncatted -a dimension...
wrong order returns empty slice, silently:
<xarray.Dataset>
Dimensions: (time: 36, x: 0, y: 205)
Coordinates:
* time (time) object 1980-09-16 12:00:00 ... 1983-08-17 00:00:00
xc (y, x) float64 ...
yc (y, x) float64 ...
* x (x) int64
Dimensions without coordinates: y
Data variables:
Tair (time, y, x) float64 ...
Attributes:
title: /workspace/jhamman/processed/R1002RBRxaaa01a/l...
institution: U.W.
source: RACM R1002RBRxaaa01a
output_frequency: daily
output_mode: averaged
convention: CF-1.4
references: Based on the initial model of Liang et al., 19...
comment: Output from the Variable Infiltration Capacity...
nco_openmp_thread_number: 1
NCO: "4.6.0"
history: Tue Dec 27 14:15:22 2016: ncatted -a dimension...
The text was updated successfully, but these errors were encountered:
When slicing over a dimension that is not ordered monotonously increasing,
.sel
returns an empty slice (which is ok) but it also doesn't complain (which is not very helpful).Returns:
The text was updated successfully, but these errors were encountered: