function g=GOMLSSWplot(X,Y,Z,D,Er);
%GOMLSSWPLOT plots layer of LSSW over GOM bathymetry
%
%g=GOMLSSWplot(X,Y,Z,D,Er);
%
%  X, Y, Z define a 2D grid suitable for use with surf
%
%   D is the value to be plotted on the grid (usually %LSSW)
%   Er is the -(errorvariance)+1 
%
% A white-blue colormap will be added to the figure to display
% the values of D.  An alphamap will be added so that Er values
% below 0.5 are transparent and >0.75 are opaque.
%
%V and E should be third cells from V and E data-pair in
%         /CODE/FEM/OAFE/GOMwork/oaxoutOD9799_LSSW.mat
%   or  /CODE/FEM/OAFE/GOMwork/data/DrinkLSW/DrinkLSWinterp.mat
%

GOMplot3D_2; %cool GOM bathymetry figure
set(gcf,'renderer','opengl')
h=findobj(gca,'type','surface');
%set up colormap
map=colormap;
blue=ones(256,3);blue(:,1:2)=linspace(1,0,256)'*[1 1];
bot=map(1:256,:)*0.4; %darken the ocean bottom to improve contrast with LSSW
I=find(bot<0);if(~isempty(I));bot(I)=0;end
map=[bot;map(257:end,:);blue];
colormap(map);caxis([-1 2]);
h=findobj(gca,'type','surface');
%make sure colors on topography are not > 1
C=get(h,'Cdata');
I=find(C>1);
C(I)=1;
I=find(C>=0);
C(I)=.97*C(I)+.02;
set(h,'Cdata',C);

%Normalize D to [0 1} and then shift to [1 2]
	mnd=min(D(:));
   mxd=max(D(:));
  D=(D-mnd)/(mxd-mnd)+1;
	
  
  hold on; 
  g=surf(X,Y,0*D-100,D);%Plot D at -100m & make color proportional to D
  %Set shading to interp and set up for good lighting
  set(g,'edgecolor','none','facecolor','interp','facelighting','phong',...
      'backfacelighting','lit');
  %Set alpha properties so that transparancey is determiend by E
  set(g,'alphadata',Er,'facealpha','interp');
  
  %set the alphalimits
  set(gca,'alim',[0 1]);
  %creat an alphamap and add to figure
  amap=interp1([1,0.5*256,0.75*256,256],[0 0 1 1],1:256);
  set(gcf,'alphamap',amap);
  
  %add another light
  l=camlight(0,90);
  
