griddata for closed surface

조회 수: 7 (최근 30일)
Evgheny
Evgheny 2014년 10월 23일
댓글: Mohammad Abouali 2014년 10월 29일
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