Ouranosinc / xscen

A climate change scenario-building analysis framework.
https://xscen.readthedocs.io/
Apache License 2.0
15 stars 2 forks source link

Automatically use cftime for multi-file dataset going beyond 2262. #277

Open aulemahal opened 11 months ago

aulemahal commented 11 months ago

Addressing a Problem?

A bare extract_dataset on a dataset that has assets both inside and outside the datetime64 range will fail with : TypeError: Cannot combine along dimension 'time' with mixed types. Found: DatetimeProlepticGregorian, Timestamp. [...]

That's because files are opened individually. The ones inside the range were opened using numpy/pandas's default, while those outside reverted to cftime as told by a warning : SerializationWarning: Unable to decode time axis into full numpy.datetime64 objects, continuing using cftime.datetime objects instead, reason: dates out of range.

Potential Solution

xscen could inject use_cftime=True when it sees that df.date_start.min() < '1677-09-21T00:12:43.145224193' or df.date_end.max() > '2262-04-11T23:47:16.854775807'.

Additional context

Intake-esm has no notion of temporal coverage of the assets in the catalog, but xscen does.

Contribution