function [time,st,titlerun]=hopsgui_extimeseries(filein,var,x0,y0,z0)

%       [time,st,titlerun]=hopsgui_extimeseries(filein,var,x0,y0,z0)
%
%   Returns a time series at a specific position
%
%   
% inputs:
%               filein -- the .nc file
%               var    -- the variable
%               x0,y0,z0 the position
% Outputs:      
%		 
%		 time	- time of the time-series
%		 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';
end



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.;
titlerun=deblank(getnc(filein,'titlrun')');
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);
z=getnc(filein,vargrid,[iy ix -1 3],[iy ix -1 3],1,1,2);
iz=locate(z,z0);


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


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

