% need: T,S,ix,iy,iz,field (1D) or fielduv (2D),ind,ts,dt
% need: limT Scontour fcontourI fcontourO
if(exist('ncmap','var')==0);ncmap=20;end;
if(exist('fflag','var')==0);fflag=1;end;
if(exist('iz','var')==0);iz=1:nz1;end;

%figure(2);clf;
flagx=0;
if(fflag==1);
    if(length(iy)==1);ind=ix;flagx=1;elseif(length(ix)==1);ind=iy;flagx=0;end;
%1.jul.2020: add unique to see if can remove repeated indices
    [tmp,iq]=unique(ind);
    if(flagx);ixq=iq;iyq=1;else;iyq=iq;ixq=1;end;
%----
    msk=ones(size(T));msk(find(T(:)==0))=nan;
    %mypcolor(ind,rc(iz),squeeze(T(ix,iy,iz).*msk(ix,iy,iz))');caxis(limT);colormap(jet(ncmap));mythincolorbar;grid;
    %imagescnan(ind,rc(iz),squeeze(T(ix,iy,iz).*msk(ix,iy,iz))');caxis(limT);colormap(jet(ncmap));mythincolorbar;grid;set(gca,'ydir','normal');
    imagescnan(ind(iq),rc(iz),squeeze(T(ix(ixq),iy(iyq),iz).*msk(ix(ixq),iy(iyq),iz))');caxis(limT);colormap(jet(ncmap));mythincolorbar;grid;set(gca,'ydir','normal');
    hold on;[a,b]=contour(ind(iq),rc(iz),squeeze(S(ix(ixq),iy(iyq),iz))',Scontour);hold off;
    set(b,'color',[.2,.2,.2]);clabel(a);%,'manual');
    hold on;[a,b]=contour(ind(iq),rc(iz),squeeze(field(ix(ixq),iy(iyq),iz))',fcontourI);hold off;
    set(b,'color',[.8,.8,.8],'linewidth',2);clabel(a);%,'manual');
    hold on;[a,b]=contour(ind(iq),rc(iz),squeeze(field(ix(ixq),iy(iyq),iz))',fcontourO,'--');hold off;
    set(b,'color',[.8,.8,.8]);clabel(a);%,'manual');
    title([ts2dte(ts,dt,yrStart,1,1) '--' ts2dte(ts2,dt,yrStart,1,1) ', ' titlestr]);
    set(gca,'Ylim',[rc(iz(end)),100]);
    %pause
elseif(fflag==2);
    msk=ones(size(tempT));msk(find(tempT(:)==0))=nan;
    ind=ix;flagx=1;if(length(find(diff(ind)==0))>0);ind=iy;flagx=0;end;
%1.jul.2020: add unique to see if can remove repeated indices
    [tmp,iq]=unique(ind);
    if(flagx);ixq=iq;iyq=1;else;iyq=iq;ixq=1;end;
%----
    %mypcolor(ind,rc(iz),tempT'.*msk');caxis(limT);colormap(jet(ncmap));mythincolorbar;grid;
    imagescnan(ind(iq),rc(iz),tempT(iq,:)'.*msk(iq,:)');caxis(limT);colormap(jet(ncmap));mythincolorbar;grid;set(gca,'ydir','normal');
    hold on;[a,b]=contour(ind(iq),rc(iz),tempS(iq,:)',Scontour);hold off;
    set(b,'color',[.2,.2,.2]);clabel(a);%,'manual');
    hold on;[a,b]=contour(ind(iq),rc(iz),fielduv(iq,:)',fcontourI);hold off;
    set(b,'color',[.8,.8,.8],'linewidth',2);clabel(a);%,'manual');
    hold on;[a,b]=contour(ind(iq),rc(iz),fielduv(iq,:)',fcontourO,'--');hold off;
    set(b,'color',[.8,.8,.8]);clabel(a);%,'manual');
    title([ts2dte(ts,dt,yrStart,1,1) '--' ts2dte(ts2,dt,yrStart,1,1) ', ' titlestr]);
    set(gca,'Ylim',[rc(iz(end)),100]);
end;
