[SciPy-user] 2D interpolation from a set of irregularly spaced
eric jones
eric at enthought.com
Fri Jul 22 12:46:19 EDT 2005
Eric Emsellem wrote:
> wonderful; Seems to work fine!!
> In fact in the meantime I had solved this problem by wrapping a
> routine I had (trmesh) with SWIG...
Yes, is toms algorithm 624. If 526 didn't work well for our needs, that
was the next one on the list to try. :-)
> However your implementation is quite nice since I can easily install
> it in my python lib. 1 question for a naive python user: how do I
> manage to include your interp.py in? At the moment it only created the
> interp_526.so in my lib path so I can access that routine but not
> interp2d for example (is it as simple as creating a dir "interp" and
> putting it in the right place?)
For this version of the code, I have set it up as a package named
"interp." Hmmm. I just noticed the setup.py doesn't contain the
package information in it. Here is a new setup.py file that installs
everything as a package:
#!/usr/bin/env python
# setup.py
from scipy_distutils.core import Extension
def dot_join(*args):
return '.'.join(args)
package = 'interp'
ext1 = Extension(name = dot_join(package,'interp_526'),
sources = ['interp_526.pyf','interp_526.f'])
if __name__ == "__main__":
from scipy_distutils.core import setup
setup(name = 'interp_526',
package_dir = {package:''},
packages = [package],
description = "Bivariate interpolation",
author = "Eric Jones",
author_email = "eric at enthought.com",
ext_modules = [ext1]
)
# file end
When it is installed, it should become a directory in your python
"site-packages" directory with three files in it:
interp
__init__.py
interp.py
interp_526.so
Once this is installed correctly, you should be able to do the following:
>>> from interp.interp import interp2d
Now, this looks a little silly, but that is the configuration at the
moment. Names and the organization of things will change to protect the
innocent once it goes into SciPy. We should probably put 624 in when we
everything to SciPy also.
Also, looking at the toms list, http://www.netlib.no/netlib/toms/, there
are a ton of methods that handle interpolation. Does anyone no of a
survey or study that categorizes these in a convenient way?
thanks,
eric
>
> thanks again,
>
> Eric
>
> eric jones wrote:
>
>> Hey Eric,
>>
>> We recently wrapped toms 526:
>>
>> Algorithm 526: Bivariate Interpolation and Smooth Surface Fitting
>> for Irregularly Distributed Data Points
>>
>> It is available here:
>> http://www.netlib.no/netlib/toms/526
>> Algorithm paper info here:
>> http://portal.acm.org/citation.cfm?id=355787
>>
>> The wrapper is "good enough" for what we needed, but hasn't gotten
>> the attention it needs to go into SciPy yet. So, I've attached the
>> code as a zip file. If you are on windows, the binaries are included
>> for you. Otherwise, run setup.py.
>> Here is what I usually do when testing: setup.py build_ext --inplace
>>
>> example2.py provides an example of using the algorithm.
>> There is also a png file showing a plot of the results from example2.py.
>>
>> hope that helps,
>> eric
>>
>> Eric Emsellem wrote:
>>
>>> Hi again,
>>> Robert Kern provided me some input with a link to Scientific Python
>>> (thanks!)
>>>
>>> ==> However this is again using an ORTHOGONAL GRID!
>>> The set of points I am using are NOT on an orthogonal grid but are
>>> RANDOMLY positioned points...
>>>
>>> So any idea on how to interpolate a set of randomly positioned x,y ??
>>> (so I have three 1D arrays: x, y for the positions, and z for the
>>> values. I need to know z at other positions...)
>>>
>>> Thanks
>>>
>>> Eric
>>> P.S.: please cc to my email too.
>>>
>>
>
More information about the SciPy-User
mailing list