function hopsgui_timeseries
% This plot draw the time-profile series


global hopsgui_obj
hopsgui_obj{1}.answer=1;

if ~strcmp('depth_contour',strrep(hopsgui_obj{1}.action,' ','')) & ~strcmp('kindex_contour',strrep(hopsgui_obj{1}.action,' ','')) 
disp('>>>>This option only works with kslices or depth contours')
return;
end



disp('>>>Click twice at the same place to disable the time series')
nfig=figure;
set(nfig,'Name','Time series','MenuBar','none','Position',[0 0.6 0.4 0.4]);

	
while hopsgui_obj{1}.answer==1
var=hopsgui_obj{1}.variable;



figure(hopsgui_obj{1}.hfigure)
[x,y]=ginput(2);
z=hopsgui_obj{1}.depth;

switch(var)
  case 'temp' 
	ytitle=strcat(var);	
	fac=1;
	[depth1,time1,st1,titlerun]=hopsgui_extimeprofiles(hopsgui_obj{1}.filein,var,x(1),y(1));
	[depth2,time2,st2,titlerun]=hopsgui_extimeprofiles(hopsgui_obj{1}.filein,var,x(2),y(2));
	
  case 'salt' 
	ytitle=strcat(var);	
	fac=1;
	[depth1,time1,st1,titlerun]=hopsgui_extimeprofiles(hopsgui_obj{1}.filein,var,x(1),y(1));
	[depth2,time2,st2,titlerun]=hopsgui_extimeprofiles(hopsgui_obj{1}.filein,var,x(2),y(2));

	
  case 'wvzt'
	fac=24.*36.;
	ytitle=strcat(var,' (m/day)');
	[depth1,time1,st1,titlerun]=hopsgui_extimeprofiles(hopsgui_obj{1}.filein,var,x(1),y(1));
	[depth2,time2,st2,titlerun]=hopsgui_extimeprofiles(hopsgui_obj{1}.filein,var,x(2),y(2));

  case 'wvst'

	fac=24.*36.;
	ytitle=strcat(var,' (m/day)');
	[depth1,time1,st1,titlerun]=hopsgui_extimeprofiles(hopsgui_obj{1}.filein,var,x(1),y(1));
	[depth2,time2,st2,titlerun]=hopsgui_extimeprofiles(hopsgui_obj{1}.filein,var,x(2),y(2));

	
  case '|Ut|'
       ytitle=var;		
	[depth1,time1,st1,titlerun]=hopsgui_extimeprofiles(hopsgui_obj{1}.filein,var,x(1),y(1));
	[depth2,time2,st2,titlerun]=hopsgui_extimeprofiles(hopsgui_obj{1}.filein,var,x(2),y(2));
	fac=1;  
	
	
	
  otherwise
  	disp(sprintf('>>>>This option is not currently installed for -%s-, edit hopsgui_timeprofiles.m \n',var))
	close(nfig)
	return;
  	
end		



figure(nfig)
subplot(211)
minmax=extrem(st1*fac);
vector=nice([minmax],2)';
levels=min(vector):(vector(2)-vector(1)):max(vector);

tit=sprintf('Corrd: x %6.3f, y %6.3f',x(1),y(1));
caxis([minmax]);
extcontour(time1,depth1,st1'*fac,levels,'k','fill');grid on;title(tit);xlabel('Time (days)');ylabel(ytitle)
caxis([minmax]);colorbar

subplot(212)
minmax=extrem(st2*fac);
vector=nice([minmax],2)';
levels=min(vector):(vector(2)-vector(1)):max(vector);
tit=sprintf('Corrd: x %6.3f, y %6.3f',x(2),y(2));
caxis([minmax]);
extcontour(time2,depth2,st2'*fac,levels,'k','fill');grid on;title(tit);xlabel('Time (days)');ylabel(ytitle)
caxis([minmax]);colorbar

if x(1)==x(2) & y(1)==y(2) 
hopsgui_obj{1}.answer=0;
end


if exist('h') == 1
delete(h);
end

figure(hopsgui_obj{1}.hfigure)
hold on;
h=plot(x,y,'ko');
hold off;

end

delete(h);
disp('>>>>>Finished time series display')
return;


