Closed saschahofmann closed 4 months ago
Digging deeper the problem seems to happen in sdba/utils.py add_cyclic_bounds
L304. When its trying to compute the difference between coordinates da.coords[att].diff(att)
it doesn't work because seasons arent numeric.
I had a look at what happens for .month
and it looks like it adds two months 0 and 13 that are equal to 12 and 1 respectively?
What should be the expected behaviour for seasons happy to implement that, I guess we could either not perform making it cyclic or invent some string? e.g. ABC
or XYZ
?
Hi @saschahofmann ! Sorry for the delay.
Indeed, we might have completely overlooked the seasonal grouping when implementing the other parts.
I'm not sure inventing strings will completely solve this. But I would still try that first, in add_cyclic_bounds
.
But if it still doesn't work, may be we must abandon the idea of having strings as coordinates... If numbers are needed, I think the Grouper
object should be the one ensuring a time.season
grouping always uses a numerical coordinate, even if that means overriding the xarray behaviour...
Would it make sense to replace the grouped coordinates in the beginning with numbers and finally return them to the array strings of seasons after the operations have been performed?
Making it specific for the seasonal grouping wouldn't be very elegant but right now I can not come up with another case where this would happen? I think there is no grouping that e.g. returns weekday names? Alternatively, it could be something that's applied to all string groups?
Yes it would make sense, but I'm not sure where that would take place ? In utils.interp_in_quantiles
maybe?
I don't think it makes much sense to support weekdays... Even then, these have a standard (pythonic) translation into integers, which we could use. As such, season
might be the only problematic case and it is acceptable to have a specific workaround I believe.
Setup Information
Description
There seems to be a bug when trying to adjust a QuantileDeltaMapping with seasonal grouping. The training seems to work just fine.
See below for modified version of the example on the xclim docs
Steps To Reproduce
Create the data as in the official example
Trigger failing adjustment
Fails with this in xclim/sdba/base.py:703:
As mentioned above something like this passes just fine (monthly grouping)
Additional context
No response
Contribution
Code of Conduct