Skip to content

Cache linear interpolator#1997

Closed
corinnebosley wants to merge 1 commit intoSciTools:masterfrom
corinnebosley:trajectory_optimisation_1
Closed

Cache linear interpolator#1997
corinnebosley wants to merge 1 commit intoSciTools:masterfrom
corinnebosley:trajectory_optimisation_1

Conversation

@corinnebosley
Copy link
Member

@rhattersley @pp-mo @pelson
This is the first change that I implemented under PR #1946 which achieves a 25% increase in efficiency of nearest neighbour interpolation.

Richard suggested that I make this change in the original PR, but I would like to split up the issues brought up in that conversation and so I have made a fresh PR for this.

I would like to be involved in more changes to these routines (and I would like to do this soon, please don't let it all be forgotten about...) but I think this is a solid start. Let's not run before we can walk, and all that.

# Cache the linear interpolator
scheme = iris.analysis.Linear()
coords, points = zip(*sample_points)
interpolator = scheme.interpolator(cube, coords)
Copy link
Member

@rhattersley rhattersley May 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines need to be protected by if method in ('linear', None) - partly because it's wasted effort otherwise, but mostly because they will fail when trying to do nearest-neighbour interpolation over multi-dimensional coordinates.

NB. The docstring for iris.analysis.trajectory.interpolate is a little ambiguous about the default value of method, but it turns out that the default is not just simply "linear", but switches to "nearest" when using multi-dimensional coordinates. 👎 I definitely don't propose to change that behaviour in this PR, but it would be nice to clarify the docstring (again, possibly in a separate PR - small is beautiful).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants