-
Notifications
You must be signed in to change notification settings - Fork 211
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Problem description
In xarray.io.get_variable, if the datetime argument is an ISO8601 datetime like 2025-02-25T15:33:38Z with a date and a time, the time part of the datetime is dropped. This causes a problem for assets whose temporal dimension is more frequent than daily, because get_variable will always snap to the nearest day.
I think the fix is to simply remove the split by T and keep datetime intact.
titiler/src/titiler/xarray/titiler/xarray/io.py
Lines 175 to 187 in 28d33a6
| # TODO: Technically we don't have to select the first time, rio-tiler should handle 3D dataset | |
| if "time" in da.dims: | |
| if datetime: | |
| # TODO: handle time interval | |
| time_as_str = datetime.split("T")[0] | |
| if da["time"].dtype == "O": | |
| da["time"] = da["time"].astype("datetime64[ns]") | |
| da = da.sel( | |
| time=numpy.array(time_as_str, dtype=numpy.datetime64), method="nearest" | |
| ) | |
| else: | |
| da = da.isel(time=0) |
vincentsarago and j08lue
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working