% mksecplt2
% assume you've got a sect_info.mat which has
%    sect_info(sect_matchi).dates=[min(dday(ii)) max(dday(ii))];
%    sect_info(sect_matchi).xytext=[xtext_loc,ytext_loc];
%    sect_info(sect_matchi).name=sec_name;
%    sect_info(sect_matchi).plot_against=plot_against;
%    sect_info(sect_matchi).ii=[min(ii) max(ii)];

global XYDATA
global UVDATA
global CONTFIG
global VECFIG

title_str = sprintf(' %s, Section %s', cruise_name, sec_name);

if which_plots == 1 | which_plots == 3,  % CONTOUR
   
   UVDATA = load(uvfile);   %    uvfile = 'c_sect_uv.mat'; normally
   XYDATA = load(xyfile);   %    xyfile = 'c_sect_xy.mat';
   preparedata
   
   dday=XYDATA.dday;
   sect_dday=sect_info(sect_matchi).dates;
   ii = find((dday >= sect_dday(1)) & (dday <= sect_dday(2)));
   
   CONTFIG.ii = ii;
   XYDATA.X = XYDATA.x(ii);
   XYDATA.Y = XYDATA.y(ii);
   XYDATA.DDAY = XYDATA.dday(ii);
   UVDATA.U = UVDATA.u(:,ii);
   UVDATA.V = UVDATA.v(:,ii);
   
   u = UVDATA.u'; v = UVDATA.v';  %extract the section to send to contour 
   xyt = [x(ii)'; y(ii)'; dday(ii)'];
   uv = [u(ii,:)' u(ii,:)'];             % for space
   uv(:,1:2:2*length(ii)) = u(ii,:)';
   uv(:,2:2:2*length(ii)) = v(ii,:)';
   
   CONTFIG.depthstr = ' 100  150'; 
   CONTFIG.bold = 1;
   CONTFIG.custlevstr = [];
   CONTFIG.boldlevs = '[0 0]';
   CONTFIG.showtitle = 0;
   CONTFIG.outline = 1;
   CONTFIG.disable = 0;
   CONTFIG.title = title_str;
   
   contourmaster('websetup')
   
   cch = findobj(gcf,'tag','btnCancel');
   msg = sprintf('\nUse the [Cancel/Close] button \nwhen finished editing ');
   msg = sprintf('%s\n\nBe sure to [Save / Print figure] \nfor the *.eps file \nwith the final [OK / Preview]',msg);
   noticeOK(msg);
   
   waitfor(cch,'selected')
   close  % cancel also calls gplot figure, not needed here
end

if which_plots == 2 | which_plots == 3,  % VECTOR

   UVDATA = load(uvfilev);  %    uvfilev = 'v_sect_uv.mat'; normally, notice end 'v'
   XYDATA = load(xyfilev);  %    xyfilev = 'v_sect_xy.mat'; 
   preparedata
   
   dday=XYDATA.dday;
   sect_dday=sect_info(sect_matchi).dates;
   ii = find((dday >= sect_dday(1)) & (dday <= sect_dday(2)));
   VECFIG.ii = ii;
   XYDATA.X = XYDATA.x(ii);
   XYDATA.Y = XYDATA.y(ii);
   XYDATA.DDAY = XYDATA.dday(ii);
   UVDATA.U = UVDATA.u(:,ii);
   UVDATA.V = UVDATA.v(:,ii);
   
   u = UVDATA.u'; v = UVDATA.v';  %extract the section to send to vector plot
   xyt = [x(ii)'; y(ii)'; dday(ii)'];
   uv = [u(ii,:)' u(ii,:)'];             % for space
   uv(:,1:2:2*length(ii)) = u(ii,:)';
   uv(:,2:2:2*length(ii)) = v(ii,:)';
   
   VECFIG.title = title_str;
   
   vectormaster('websetup')
   
   cch = findobj(gcf,'tag','btnCancel');
   msg = sprintf('\nUse the [Cancel/Close] button \nwhen finished editing ');
   msg = sprintf('%s\n\nBe sure to [Save / Print figure] \nfor the *.eps file \nwith the final [OK / Preview]',msg);
   noticeOK(msg);
   
   waitfor(cch,'selected')
   close  % cancel also calls gplot figure, not needed here  
end 

%%%% re-establish data one more time as contour = reference set
UVDATA = load(uvfile);  % uvfile = 'c_sect_uv.mat';  using contour reference
XYDATA = load(xyfile);
preparedata

dday=XYDATA.dday;
sect_dday=sect_info(sect_matchi).dates;
ii = find((dday >= sect_dday(1)) & (dday <= sect_dday(2)));

CONTFIG.ii = ii; % nornally unnec. -- already ready;
XYDATA.X = XYDATA.x(ii);
XYDATA.Y = XYDATA.y(ii);
XYDATA.DDAY = XYDATA.dday(ii);
UVDATA.U = UVDATA.u(:,ii);
UVDATA.V = UVDATA.v(:,ii);

u = UVDATA.u'; v = UVDATA.v';  %extract the section for web plotting reference
xyt = [x(ii)'; y(ii)'; dday(ii)'];
uv = [u(ii,:)' u(ii,:)'];             % for space
uv(:,1:2:2*length(ii)) = u(ii,:)';
uv(:,2:2:2*length(ii)) = v(ii,:)';
%%%%%%%%%  end of file

