Documentation of map_surface

Global Index (all files) (short | long) | Local Index (files in subdir) (short | long)

Function Synopsis

h = map_surface(varargin);

Help text

  h = map_surface(data, alt, 'PropertyName', ProptertyValue, ...);

  This function uses the surfacem routine in the map
  toolbox to generate a color-shaded surface.

  If alt is specified, then surfacem will produce the
  map at the Z-altitude specified in alt.  Otherwise,
  the routine uses Z=0 for an altitude.

Cross-Reference Information

This function calls This function is called by

Listing of function map_surface

function h = map_surface(varargin);

%  Dan Vimont, 2 September, 1999

if nargin == 1
     data = varargin{1};
     alt = zeros(size(data));
     varargin(1) = [];

     data = varargin{1};
     if ~isstr(varargin{2}); 
         alt = varargin{2};
         varargin(1:2) = [];
         alt = zeros(size(data));
         varargin(1) = [];

data = squeeze(data);
alt = squeeze(alt);

if isscalar(alt); alt = alt*ones(size(data)); end;

%  First, determine if hold is 'on', or 'off'.

next_ax = lower(get(gca, 'NextPlot'));
if strcmp(next_ax, 'replace');  cla;  end;

%  Get the global varaibles XAX YAX and FRAME

if (size(XAX, 1) == 1); XAX = XAX'; end;
if (size(YAX, 1) == 1); YAX = YAX'; end;

[m, n] = size(data);
if or((m~=length(YAX)), (n~=length(XAX)));
  error('[length(YAX) length(XAX)] must equal size(data)');

%  Redefine XAX, YAX and data for global contouring -- allowing 
%  for wrapping around the globe.

%  The shifting of XAX and YAX by diff(XAX)/2 and diff(YAX)/2 is
%  because surfacem puts the data in a box, with the lower left
%  corner defined by the given (lat, lon) pair.  We assume here
%  that the data is centered on the (lat, lon) pair.

XAX2 = XAX - mean(diff(XAX))/2;
YAX2 = YAX - mean(diff(YAX))/2;

[xk, yk] = keep_var(FRAME, XAX2, YAX2);
if (FRAME(2) - FRAME(1) == 360);
  data2 = [data(yk,:) data(yk,1)];
  alt2 = [alt(yk,:) alt(yk,1)];
  XAX2 = [XAX2; XAX2(1)+360];
  data2 = data(yk, xk);
  alt2 = alt(yk, xk);
  XAX2 = XAX2(xk);
YAX2 = YAX2(yk);

[nlat, nlon] = size(data2);
XAX2 = ones(nlat,1)*XAX2';
YAX2 = YAX2*ones(1,nlon);

if isempty(find(~isnan(data2))); return; end;

%  Plot the data

hndl0 = surfacem(YAX2, XAX2, data2, alt2);

if ~isempty(varargin);  set(hndl0,varargin{:});  end

if nargout == 1;
    h = hndl0;

set(gca, 'NextPlot', next_ax);