Skip to content
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

Performance improvements to AreaWeighted with sparse matrices #5365

Closed
stephenworsley opened this issue Jun 29, 2023 · 2 comments · Fixed by #5543
Closed

Performance improvements to AreaWeighted with sparse matrices #5365

stephenworsley opened this issue Jun 29, 2023 · 2 comments · Fixed by #5543
Assignees
Milestone

Comments

@stephenworsley
Copy link
Contributor

📰 Custom Issue

As a subtask of #4754 is to rewrite the algorithm for AreaWeighted to use sparse matrices as the standard (if this improves performance). Looking at the code for area weighted regridding, it looks like there are a few opportunities to improve performance.

  1. Weight calculation happens in a nested for loop over x and y dimensions, e.g:
    for i, (x_0, x_1) in enumerate(grid_x_bounds):
    This calculation ought to be seperable into two different loops with their results then combined.
  2. The weights are applied using numpy average functions where matrix multiplication may be more appropriate
    def _regrid_area_weighted_array(
  3. It may turn out to be even more performant to store two weight matrices, one for each dimension. Each may then be applied independently.
  4. Note: In order for the application of weights to be separated, normalisation due to masked data will have to be handled after the application of weights as a separate step. This is not possible when using numpy average methods where the normalisation step is built in.

This would require rewriting much of the code for AreaWeighted from the ground up. This may be slightly simplified by following templates set by the use of sparse matrices in other Iris regridders.

@stephenworsley
Copy link
Contributor Author

See https://gist.github.com/stephenworsley/c5982af7b20870b186390b732e39937c

@trexfeathers trexfeathers added this to the v3.8 milestone Aug 16, 2023
@stephenworsley
Copy link
Contributor Author

Note: it may make sense to simultaneuously tackle #5461 while rewriting this algorithm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🏁 Done
Status: 🏁 Done
Development

Successfully merging a pull request may close this issue.

3 participants