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

Extrapolation when gridding data and better interpolators #44

Merged
merged 7 commits into from Aug 14, 2013

Conversation

Projects
None yet
1 participant
@leouieda
Member

leouieda commented Aug 13, 2013

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

This comment has been minimized.

Member

leouieda commented Aug 13, 2013

@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 added some commits Aug 13, 2013

Separated gridder.interp in 2 function: 1 interpolated at given points,
other interpolates on regular grid. Added function to extrapolated
masked arrays or NaNs
@leouieda

This comment has been minimized.

Member

leouieda commented Aug 13, 2013

@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

Merge pull request #44 from leouieda/extrapolation
Better interpolators and extrapolation for `gridder`

@leouieda leouieda merged commit 94e3725 into master Aug 14, 2013

1 check passed

default The Travis CI build passed
Details

@leouieda leouieda deleted the extrapolation branch Aug 14, 2013

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