You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Discovered that doing a date selection for a given year + month based on categorised coordinates, with an operation like month_data = cube.extract(Constraint(year=y, month=m)).
It seems much quicker to do
indices = (cube.coord('year').points == y) & (cube.coord('month').points == m)
month_data = cube[indices]
In short, this is because operation is not vectorised (unlike the above index-calculating solution).
This is worse for time coordinates, as a unit.num2date() is applied individually to each time cell (points + bounds), before calling the discriminator function.
This could definitely be fixed, within the existing API, at least for the non-user-function coordinate selection styles ("equals-point-value" and "in-list-of-values").
A useful addition would be an extension to the extract API to allow user functions to also be called with vector info.
E.G. either a recognised property visible on the function, or a keyword like vectorise_functions=True ?
TODO:
add a simple testcase demonstrating the performance hit
The text was updated successfully, but these errors were encountered:
Discovered that doing a date selection for a given year + month based on categorised coordinates, with an operation like
month_data = cube.extract(Constraint(year=y, month=m))
.It seems much quicker to do
In short, this is because operation is not vectorised (unlike the above index-calculating solution).
This is worse for time coordinates, as a
unit.num2date()
is applied individually to each time cell (points + bounds), before calling the discriminator function.This could definitely be fixed, within the existing API, at least for the non-user-function coordinate selection styles ("equals-point-value" and "in-list-of-values").
A useful addition would be an extension to the extract API to allow user functions to also be called with vector info.
E.G. either a recognised property visible on the function, or a keyword like
vectorise_functions=True
?TODO:
add a simple testcase demonstrating the performance hit
The text was updated successfully, but these errors were encountered: