-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-dimensional thresholds #1236
Conversation
…- spi cal as quantity
Removing PercentileDataArray would break a few things in icclim but nothing too serious I believe. |
Indeed, sorry I should have tagged you guys when I made the change. On our end, there were two motivations:
But if this breaks to many things in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat addition!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat indeed!
I would only suggest to use another name for Quantity
as it's shadowing pint's Quantity and could be confusing (especially since it is already confusing between pint.Quantity
and units.Quantity
)
Maybe "Threshold" would make sense or "QuantifiedThreshold" ?
Indeed you are right on this.
|
I haven't dived into the code yet but basically the 'threshold' in all cases will now be an array right? ... How about |
That's the other thing : the goal is to allow both arrays and scalar values. So the object can be either one of
In most cases, it wouldn't be an array. |
I think the small bug with the |
Sorry for late arrival here - thanks @aulemahal for this work! I will definitely try this out during my next foray into the heat wave work. In general, this capability is really relevant to on-the-ground work, even outside of heatwaves. |
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
I like "Quantified" best. As for PercentileDataArray, it would make sense to simply migrate it into icclim code base as it is used in icclim own Threshold class. |
Pull Request Checklist:
number
) and pull request (:pull:number
) has been addedWhat kind of change does this PR introduce?
Thresholds and other quantities passed as parameters of indicators can now be multi-dimensional
DataArray
s. xArray broadcasting mechanisms will apply. Those parameters are now annotated as "Quantity" in the signatures (xclim.core.utils.Quantity
), instead of "str" as before. Attributes where such thresholds where included will now read"<an array>"
(french:"<une matrice>"
) for these new cases.Does this PR introduce a breaking change?
No, I don't think so!
As expected, it was quite easy to implement this! Only a few indice needed modifications, and only a few are not compatible :
fire_weather_indices
(because of the use ofmap_blocks
) and[snow|rain]fall_approximation
(but only with the "brown" method). Both cases shouldn't be where this feature is used the most.Other information:
I did not add any checks about the dimensions of these thresholds. I thought we didn't need to be stricter than xarray. And that xclim users should expect xarray behaviour.
For example: if
tas
is ('lon', 'lat', 'time') andthresh
is ('lon',) then it gets broadcasted along thelat
andtime
dimensions automatically. But if the twolon
coordinates differ, then a combined (union)lon
coordinate is found in the output. And I made the choice that it's not our fault, nor is it for us to detect.@JeremyFyke if you have time to test this branch for your heat wave need, that would be wonderful. Writing tests for this will be harder than implementing it, simply because of the large number of indicators involved...