html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/issues/5012#issuecomment-793256439,https://api.github.com/repos/pydata/xarray/issues/5012,793256439,MDEyOklzc3VlQ29tbWVudDc5MzI1NjQzOQ==,18426375,2021-03-09T01:49:35Z,2021-03-09T01:49:35Z,NONE,"good catch! I'm not sure why the model would've written it out this way, but the original dataset (along with the small subset I wrote out and attached) is indeed non-monotonic in the non-working example. That is strange but is almost certainly the reason for the error. This'll help me do what I need to do, and I'm not sure whether this is so much of an edge case that it's even worth a bigger fix.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,825079209
https://github.com/pydata/xarray/issues/5012#issuecomment-793204639,https://api.github.com/repos/pydata/xarray/issues/5012,793204639,MDEyOklzc3VlQ29tbWVudDc5MzIwNDYzOQ==,3460034,2021-03-09T00:38:37Z,2021-03-09T00:39:02Z,CONTRIBUTOR,"I'll leave the exact issue up to someone more acquainted with string and slice handling on `TimedeltaIndex`, but in case it is useful, here are two things I noticed (to hopefully speed along the troubleshooting):
1) Using pandas `Timedelta`s instead of strings (i.e., `ds.sel(time=slice(pd.Timedelta(""01:00:00""), pd.Timedelta(""01:15:00"")))`) works, giving
```
Dimensions: (time: 39, yh: 1, zh: 1)
Coordinates:
xh float32 ...
* yh (yh) float32 0.0
* zh (zh) float32 0.0
* time (time) timedelta64[ns] 01:00:00 01:07:30 ... 01:14:30 01:15:00
Data variables: (12/26)
x (time) float32 ...
y (time) float32 ...
z (time) float32 ...
u (time) float32 ...
v (time) float32 ...
w (time) float32 ...
... ...
b (time) float32 ...
vpg (time) float32 ...
zvort (time) float32 ...
rho (time) float32 ...
qsl (time) float32 ...
qsi (time) float32 ...
Attributes:
CM1 version: cm1r20.1
Conventions: CF-1.7
missing_value: -999999.9
```
However, notice that jump in the time coordinate...which leads to
2) In the failing example, the time coordinate is non-monotonic. If we `.sortby('time')`, then `ds.sel(time=slice(""01:00:00"",""01:15:00""))` works as expected:
```
Dimensions: (time: 47, yh: 1, zh: 1)
Coordinates:
xh float32 1.0
* yh (yh) float32 0.0
* zh (zh) float32 0.0
* time (time) timedelta64[ns] 01:00:00 01:00:30 ... 01:15:00 01:15:30
Data variables: (12/26)
x (time) float32 ...
y (time) float32 ...
z (time) float32 ...
u (time) float32 ...
v (time) float32 ...
w (time) float32 ...
... ...
b (time) float32 ...
vpg (time) float32 ...
zvort (time) float32 ...
rho (time) float32 ...
qsl (time) float32 ...
qsi (time) float32 ...
Attributes:
CM1 version: cm1r20.1
Conventions: CF-1.7
missing_value: -999999.9
```
(the working example also has a monotonic time coordinate)
And so, I would guess this is an example of string-based timedelta selection failing on non-monotonic coordinates.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,825079209