griddata for closed surface

11 views (last 30 days)
Evgheny
Evgheny on 23 Oct 2014
Commented: Mohammad Abouali on 29 Oct 2014
I have spherical data [theta, phi, R]: R = f(theta, phi)
I need to interpolate this data. I've used griddata function and got a nice result, but with an issue: it's not interpolated as a closed surface:
it looks like a rumpled orange (as I wanted), but there is no smooth seam line. So the data near edges are not interpolated as needed.
Is there any variants of griddata function for closed manifolds? Or maybe some variants to solve this problem?
UPDATE:
I was advised to use scatteredInterpolant:
% Given data [theta phi rho] - Nx1 vectors
% making XYZ scattered data (Nx1 vectors)
[x,y,z] = sph2cart(theta,phi,1);
F = scatteredInterpolant(x,y,z,rho);
% prepare grid for meshing (we'll mesh xyz data, not theta,phi)
nTheta0 = 100; nPhi0 = 100;
theta0 = linspace(-pi, pi, nTheta0);
phi0 = linspace(-pi/2, pi/2, nPhi0);
[theta0, phi0] = meshgrid(theta0, phi0);
% don't know if there is easier way to make rho0 grid
% but this way works too:
rho0 = zeros(nTheta0, nPhi0);
for i=1:nTheta0
for j=1:nPhi0
% current point x y z taken from theta0, phi0 grids
[x_,y_,z_] = sph2cart(theta0(i,j), phi0(i,j), 1);
% interpolated value of this [x y z] point is new rho value
rho0(i,j) = F(x_,y_,z_);
end
end
% xyz grids for meshing
[vx,vy,vz] = sph2cart(theta0, phi0, rho0);
figure; mesh(vx,vy,vz);

Accepted Answer

Mohammad Abouali
Mohammad Abouali on 23 Oct 2014
Edited: Mohammad Abouali on 23 Oct 2014
The problem is that it doesn't recognize that phi=360 and phi=0 are actually the same point.
use scatteredInterpolant. You need to convert it to regular cartesian coordinate too.
If you want to use another application ESMF Regridding Utilities in NCL supports this sort of grid (I mean directly interpolating in spherical coordinate with periodic boundary). Another package for spherical interpolation is SCRIP.
  4 Comments
Evgheny
Evgheny on 28 Oct 2014
Can you help me with your interpolant-extrapolant lib? I have 2 vectors Theta, Phi representing points on a sphere. I can translate them in X,Y,Z vectors, size of 1xN. These points lay on a sphere ( norm of every triple (x,y,z) = 1 ) Also I have vector V the same size r = f(x,y,z). r is the value of "radius" (as data came from theta,phi representation)
I need to interpolate it to more frequent scattered data [X2 Y2 Z2], each size of 1xM , where M >> N.
How to prepare data and what function to use from your lib? Thank you in advance
Mohammad Abouali
Mohammad Abouali on 29 Oct 2014
I got your message. Let me make an example and I get back to you.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!