On Wed, Feb 23, 2011 at 2:09 PM, bhargav vaidya <coolas...@gmail.com> wrote:
> Hello Matplotlib Users. > > I am trying to work my way out to interpolate a surface from polar > coordinates (R,Theta,Z) to rectangular co-ordinates(X,Y,Z) > Basically I am looking for an equivalent for POLAR_SURFACE.pro routine in > IDL using matplotlib/Scipy? > > http://idlastro.gsfc.nasa.gov/idl_html_help/POLAR_SURFACE.html > > Does anyone of you have done that before or could tell me what functions > can I use to get that? > > Regards > Bhargav Vaidya > > (Quick Note: technically, you have cylindrical coordinates because you have Z, not Phi) While I am sure there are some more optimal methods, the straight-forward way is to do something like the following: import numpy as np from scipy.interpolate import griddata orig_x = R*np.cos(Theta) orig_y = R*np.sin(Theta) orig_z = Z grid_x, grid_y, grid_z = np.mgrid[orig_x.min():orig_x.max():10j, orig_y.min():orig_y.max():10j, orig_z.min():orig_z.max():10j] new_vals = griddata((orig_x, orig_y, orig_z), orig_vals, (grid_x, grid_y, grid_z) After running this, you should have new_vals which should have the same shape as grid_x. You can also specify the interpolation method used by griddata through the 'method' keyword argument. The '10j' in the np.mgrid[] call merely specifies the number of points you want in that axis and can be changed to any other integer you want (just keep the 'j' there to make it work the way we want). I hope that helps! Ben Root
------------------------------------------------------------------------------ Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users