Stream: python-questions

Topic: xarray sel doesn't handle inverted dimensions


view this post on Zulip Stephen Yeager (Sep 23 2021 at 21:16):

Here is some strange behavior that I'm not sure is desirable or not. I'm subsampling this dataset read in using xr.open_dataset:
/glade/campaign/cesm/development/espwg/verification_datasets/mon/SST/HadISST_sst.nc
The longitudes and latitudes are for a regular 1-degree grid, but latitude is inverted: 89.5,88.5,...,-89.5. I hadn't noticed this until I tried sel(latitude=slice(-5,5)) and got nothing back. However, sel(latitude(5,-5)) works as expected. Should the 'sel' method be smart enough to check whether the dimension is inverted?


Last updated: Jan 30 2022 at 12:01 UTC