griddata for closed surface

10 次查看(过去 30 天)
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);

采纳的回答

Mohammad Abouali
Mohammad Abouali 2014-10-23
编辑:Mohammad Abouali 2014-10-23
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 个评论
Evgheny
Evgheny 2014-10-28
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 2014-10-29
I got your message. Let me make an example and I get back to you.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by