Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Extrapolation when gridding data and better interpolators#44

Merged
leouieda merged 7 commits intomasterfrom
extrapolation
Aug 14, 2013
Merged

Extrapolation when gridding data and better interpolators#44
leouieda merged 7 commits intomasterfrom
extrapolation

Conversation

@leouieda
Copy link
Member

A problem we had with grid interpolation was that the matplotlib.mlab.griddata function that was used didn't extrapolate the data outside of the convex hull of the data points. This is good because extrapolated data is usually meaningless and misleading. But this is bad because it looks bad on plots and sometimes you want extrapolated data.

Also, the nearest neighbors algorithm used by matplotlib.mlab.griddata is not very good. A better option is scipy.interpolate.griddata which has a cubic interpolation.

So I've added support for scipy griddata by default. You can still use the nearest neighbors of matplotlib by setting algorithm='nn'.

There is also an extrapolate option (True by default) that extrapolates the data using the nearest method of scipy griddata (takes the value of the closest data point).

interpolation

Update: Added 2 new functions, interp_at to interpolate on given points (e.g., for extracting profiles) and extrapolate_nans to replace NaNs or masked values using the nearest data value.

profile

@leouieda
Copy link
Member Author

@hbueno You were having trouble upward continuing the loaded data when there were NaNs or masked values. Now you can remove the NaNs from the data and interpolate the missing data using gridder.interp. Then you can use any transform on the data that requires gridded data.

@leouieda
Copy link
Member Author

@hbueno Even simpler now. You can use gridder.extrapolate_nans to fill the masked or nan values of an array. Don't have to run through the interpolation.

leouieda added a commit that referenced this pull request Aug 14, 2013
Better interpolators and extrapolation for `gridder`
@leouieda leouieda merged commit 94e3725 into master Aug 14, 2013
@leouieda leouieda deleted the extrapolation branch August 14, 2013 18:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant