Ouranosinc / figanos

Outils pour produire des graphiques informatifs sur les impacts des changements climatiques.
Apache License 2.0
1 stars 0 forks source link

show_time doesn't work with cftime #61

Closed juliettelavoie closed 1 year ago

juliettelavoie commented 1 year ago

I have a dataset with my time axis as cftime object, not np.datetime. This breaks show_time ingridmap. It is a common type, spiro should be able to handle it.

@Beauprel I can provide you with an example in private.

Beauprel commented 1 year ago

CFTime indexes were causing more problems so the util check_timeindex() converts it to a standard calendar. This was implemented in timeseries() but not in gridmap(). Adding it should do the trick.

aulemahal commented 1 year ago

If I may, have this (check_timeindex) been tested with 360_day data ? I think the principal line would fail (it's missing the align_on arg). This could be ambiguous as the "best" align_on value may differ according to the data frequency and what you're trying to do.

Also, I suggest modifying plot_coords to stringify CFtime objects, rather than convert to numpy datetime. To be sure the plotted date is not modified or dropped. (Ex : gridmap with data on the 29 Feb. Rare, but possible with freq='M'). Both types have da.time.dt.strftime available.

Beauprel commented 1 year ago

Thanks @aulemahal, your suggestion looks good!

About support for 360_day data, check_timeindex doesn't exist for the sole purpose of plot_coords; there was an issue with plotting timeseries with a CFtime index. So I'll revisit this in a separate issue.