function [depth,time,st,titlerun]=hopsgui_extimeprofiles(filein,var,x0,y0)

%       [depth,time,st,titlerun]=hopsgui_extimeprofiles(filein,var,x0,y0)
%
%   Returns a time series profile (biddimensional matriz) at a specific position
%
%   
% inputs:
%               filein -- the .nc file
%               var    -- the variable
%               x0,y0,z0 the position
% Outputs:      
%		 
%		 time	 - time of the time-series
%            depth - depth levels
%		 st 	 - Time series of the var
%
%  Pedro Velez (UIB), July 1999

vargrid='tgrid3';
if strcmp('wvsv',strrep(var,' ',''))
	vargrid='wvgrid3';
elseif strcmp('wvst',strrep(var,' ',''))
	vargrid='wtgrid3';
elseif strcmp('wvzv',strrep(var,' ',''))	
	vargrid='vgrid3';
elseif strcmp('|Ut|',strrep(var,' ',''))
	vargrid='vgrid3';	
end


titlerun=deblank(getnc(filein,'titlrun')');

ntlast=getnc(filein,'nlast');
ntsout=getnc(filein,'ntsout');
dtuv=getnc(filein,'dtuv');
timemax=ntlast/ntsout+1;
timeinterval=(dtuv*ntsout)/3600. ;
time=((1:1:timemax)*timeinterval)/24.;

x=getnc(filein,vargrid,[1 -1 1 1],[1 -1 1 1],1,1,2);
y=getnc(filein,vargrid,[-1 1 1 2],[-1 1 1 2],1,1,2);
ix=locate(x,x0);
iy=locate(y,y0);
depth=getnc(filein,vargrid,[iy ix -1 3],[iy ix -1 3],1,1,2);



if strcmp('|Ut|',strrep(var,' ',''))
u=getnc(filein,'vtot',[-1 iy ix -1 1],[-1 iy ix -1 1],1,1,2);
v=getnc(filein,'vtot',[-1 iy ix -1 2],[-1 iy ix -1 2],1,1,2);
st=sqrt(u.^2+v.^2);
return;
end


st=getnc(filein,var,[-1 iy ix -1],[-1 iy ix -1],1,1,2);

