gjoseph92 / stackstac

Turn a STAC catalog into a dask-based xarray
https://stackstac.readthedocs.io
MIT License
232 stars 49 forks source link

Slicing KeyError #226

Closed J6767 closed 8 months ago

J6767 commented 10 months ago

I have adapted the basic example for L1C Sentinel-2 and in most cases it is running fine. However, I have encountered some rare cases where the following fails:

aoi = b11_b12_rgb.loc[..., y_utm + m_buffer:y_utm - m_buffer, x_utm - m_buffer:x_utm + m_buffer]

raise KeyError(
KeyError: "cannot represent labeled-based slice indexer for coordinate 'time' with a slice over integer positions; the index is unsorted or non-unique"

Printing the time values, they look unique and sorted, but one product has a NaT, is that causing the error?:

 '2021-11-17T18:04:02.427000000' '2021-11-25T18:13:53.443000000'
 '2021-11-27T18:04:01.973000000' '2021-11-30T18:13:57.535000000'
 '2021-12-02T18:03:57.464000000' '2021-12-05T18:13:52.999000000'
 '2021-12-12T18:03:56.314000000' '2021-12-17T18:04:02.454000000'
 '2021-12-17T18:04:02.455000000'                           'NaT']

If so, how can I remove that product? Many thanks!

Berhinj commented 10 months ago

can you provide a reproducable example ? We'd have to see why does that stac item doesn't provide a timestamp, could be a faulty object from the stac

gjoseph92 commented 8 months ago

Without a reproducible example, there's not much we can help with here, so I'm going to close this. @J6767, if you'd like to provide a reproducer, feel free to re-open.