NCAS-CMS / NCAS-CMS/cf-plot

Remove unnecessary move to `numpy` space w/ slow `array` calls

Open
#92 0 comments 0 reactions 1 assignee View on GitHub

@sadielbartholomew is already working on this.

Since Apr 4, 2025.

enhancement performance
Dominant language
Python
Stars
21
Forks
11
Avg merge
7h 11m
Merged PRs (30d)
1

Description

The cf-plot code frequently calls the array attribute to extract some data array to store as a an variable and process using numpy operations, which is slow(er) because it bypasses the lazy and optimised Dask approach of cf-python for handling the underlying arrays, ultimately calling a compute to calculate the whole array at that point. Such calls to array and subsequent use of numpy operations is very often avoidable.

So, we should do a pass through of the code and survey as to cases where this is done, then convert them to stay in cf-python/dask space unless there is a very good reason not to. The ideal point to compute the underlying data array is at the end of the logical chain when the data is immediately required for the generation of the plot in being sent to a Cartopy or matplotlib method to make the appropriate marks on the image file. Calculating the array any earlier than this could well be unnecessary and degrade performance.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.