Skip to content

Performance improvements to AreaWeighted with sparse matrices #5365

Closed
@stephenworsley

Description

@stephenworsley

📰 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.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions