function plotonsphere(data,rang) % PLOTONSPHERE(data,rang) % % Plots data as topography and colors onto a sphere. % The data are standard geographic data; i.e. the first column is the % Greenwich meridian in the x-z plane. % % See PLOTONEARTH, PLOTPLM % % 'rang' is the exaggeration of topography compared to 1 [default: 0] % % Just give it some data, in whatever 2D form. % % EXAMPLE: % % plotonsphere('demo1') % plotonsphere('demo2') % % Last modified by fjsimons-at-alum.mit.edu, 27.09.2005 if ~isstr(data) defval('rang',0); % Test periodicity over the longitudes data=reduntest(data); polestest(data) [ny,nx]=size(data); [x,y,z]=sphere(min([nx ny])-1); % Circumvent weird hold behavior p=plot(1,1); delete(p) % This to make it right - compare standard definitions DT. p 832. data=flipud(data); s=surface(-x,-y,z,'FaceColor','texture','Cdata',data); axis equal % Interpolate the data on an the sphere's grid if nx>ny data=interp2([1:nx],[1:ny]',data,linspace(1,nx,ny),[1:ny]'); elseif nx= size(grd,2)*eps*10 disp(sprintf('Data violate wrap-around by %8.4e',... sum(abs(grd(:,1)-grd(:,end))))) end grd=grd(:,1:(end-1)); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function polestest(grd) % Tests if poles (-90,90) are identical over longitudes var1=var(grd(1,:)); var2=var(grd(end,:)); if var1>eps*10 | var2>eps*10 disp(sprintf('Poles violated by %8.4e and %8.4e',var1,var2)) end