function [ymax,xmax,zmax,dmax]=quad_peak_2d0(yax,xax,z,data1)
%
ny=length(yax(:)); nx=length(xax(:)); 
if all(size(z) ~= [ny,nx]), 
	disp(['User error: bad sizes for yax,xax,z ',int2str([ny,nx,size(z)])]);
	return
end
%
[zmax0,ii]=max(z(:));
iiy=mod(ii-1,ny) + 1;
iix=floor((ii-1)/ny) + 1;
iiym=[iiy-1:iiy+1]; 
if iiym(1)<1, iiym(1)=ny; end
if iiym(3)>ny, iiym(3)=1; end
iixm=[iix-1:iix+1]; 
if iixm(1)<1, iixm(1)=nx; end
if iixm(3)>nx, iixm(3)=1; end
%
xmat=repmat(xax(iixm),[3,1]);
zmat=z(iiym,iixm);
if nargin>3,
	d1mat=data1(iiym,iixm);
	[jxmax1,xmax1,zmax1,dmax1]=quad_peak2(xmat,zmat,d1mat);
	y2=yax(iiym); z2=zmax1'; x2=xmax1'; d2=dmax1';
	[jymax,ymax,zmax,xmax,dmax]=quad_peak2(y2,z2,x2,d2);
	jymax=jymax + iiym(1);
else
end

jxmax=

iifig=1;
if iifig,
	figure(400);
	plot(xmat.',zmat.');
end
%keyboard
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
