function []=vpraqparsedplottriplet(plotinit)

global HydroXYZval HydroTimeval Flightval Courseplotval Planktonval Processed VPRlog CTDdat CreateDotPlotval SaveSensorDataval LoadBugDataval SaveBugDataval
global az el plotnames limn
global taxa htaxa htaxa1 basepathcruise name b b_column_headings b_full classid nxgrd nygrd imdir cruise buginit replotval repeat fn fhc lims
cr=setstr(13);
lf=setstr(10);
vprdata=0;
buginit=1;
SOGlobec=0;

plotnames=['Temperature        ';...
           'Salinity           ';...
           'Density            ';...
           'Fluorescence       ';...
           'Optical Backscatter';...
           'Oxygen             ';...
           'Light              '];
if strcmp(fn(end-5:end),'.combo')%ECO Triplet Data
plotnames=[plotnames;...
           'ECO Triplet Bb     ';...
           'ECO Triplet Chl    ';...
           'ECO Triplet CDOM   '];
end



load plotflag
% basepathcruise=imdir(1:length(imdir)-8);
basepathcruise=imdir(1:length(imdir)-13);%if vprlog folder is written inside rois folder

while (plotflag)
    
    if Processed,%load processed physical data
%         eval(['load ' basepathcruise '\processed\sensordata\' fn]);
        eval(['load ' basepathcruise '\processed\sensordata\' fn]);
    elseif VPRlog,%load vprlog data
        eval(['fid=fopen(''' imdir fn ''');']);
        lineone=fgets(fid);fclose(fid);
        if lineone(5)==':',
            getprepdata_bobparse(imdir,cruise,fn);
        else
            if strcmp(fn(end-5:end),'.combo')%Check if it is a ECO Triplet Combined File
                getprepdata_newfish_triplet(imdir,cruise,fn);
                b_full=b;
            else
                getprepdata_newfish(imdir,cruise,fn);
                b_full=b;
            end
        end
        if plotinit,
            PLplotsetup
            waitfor(fhc);% wait until the data limits figure is closed
            limn=str2num(lims(:,4:end));
            for j=4:9, b=b((b(:,j+1)>=limn(j,1)&b(:,j+1)<=limn(j,2)),:); end%crops rows in b that are outside limits
            limn=[limn(4:8,:);mean(b(:,12))-4*std(b(:,12)),mean(b(:,12))+4*std(b(:,12));limn(9,:)];
            limnbcol=[5,6,7,8,9,12,10];
            if strcmp(fn(end-5:end),'.combo')
                limn=[limn;mean(b(:,16))-4*std(b(:,16)),mean(b(:,16))+4*std(b(:,16));...
                      mean(b(:,17))-4*std(b(:,17)),mean(b(:,17))+4*std(b(:,17));...
                      mean(b(:,18))-4*std(b(:,18)),mean(b(:,18))+4*std(b(:,18))];
                limnbcol=[limnbcol,16,17,18];
            end
        end
        for j=1:size(limn,1),b=b((b(:,limnbcol(j))>=limn(j,1)&b(:,limnbcol(j))<=limn(j,2)),:); end%crops rows in b that are outside limits
        [totkm,af,ar]=dist(b(:,2),b(:,3)); totkm=[0 totkm/1000];totkm=cumsum(totkm)';
        b=[b totkm];
        b_column_headings=str2mat(b_column_headings,'16 distance       cumulative distance traveled by ship during tow, in km');
        if SaveSensorDataval,%save processed data
            if exist([basepathcruise '\processed\sensordata'],'dir')~=7,
                dos(['mkdir ' basepathcruise '\processed\sensordata']);
            end
            fn=strrep(fn,'.','_');%replaces all '.' with '_' so fn will save as .mat file    
            eval(['save ' basepathcruise '\processed\sensordata\' fn ' b b_column_headings lims']);
        end
    elseif CTDdat,
        b=ReadparseCTDdatFiles(basepathcruise,fn);
    end
    
    if plotinit==1,%set initial az, el
        plotinit=0;
        az=10;
        el=30;
        save azel az el;
    end
    colordef none
    latitude=num2str(b(end,2));if(b(end,2)>0),latitude=['  ',latitude];end %Last position for readout
    longitude=num2str(b(end,3));if(b(end,3)>0),longitude=['  ',longitude];end %Last position for readout
    [~,mindepth]=min(abs(b(end-min([500,size(b,1)-1]):end,4)));
    temperature=num2str(b(end-min([501,size(b,1)])+mindepth,5));
    salinity=num2str(b(end-min([501,size(b,1)])+mindepth,6));
    redgreenblue=[0.2157 .6353 .6353]*1.2;
    lattext=['h1=uicontrol(''Parent'',h,''Units'',''normalized'',''ForegroundColor'',[redgreenblue]*1.1,''BackgroundColor'',[0,0,0],''fontunits'',''normalized'',''fontsize'',.7,''FontWeight'',''normal'',''ListboxTop'',0,''Position'',[0.05 0.9 0.15 0.0401],''String'',''Latitude:   ' latitude ''',''Style'',''text'',''Tag'',''StaticText Latitude'');'];
    lontext=['h1=uicontrol(''Parent'',h,''Units'',''normalized'',''ForegroundColor'',[redgreenblue]*1.1,''BackgroundColor'',[0,0,0],''fontunits'',''normalized'',''fontsize'',.7,''FontWeight'',''normal'',''ListboxTop'',0,''Position'',[0.05 0.8 0.15 0.0401],''String'',''Longitude: ' longitude ''',''Style'',''text'',''Tag'',''StaticText Longitude'');'];
    temptext=['h1=uicontrol(''Parent'',h,''Units'',''normalized'',''ForegroundColor'',[redgreenblue]*1.1,''BackgroundColor'',[0,0,0],''fontunits'',''normalized'',''fontsize'',.7,''FontWeight'',''normal'',''ListboxTop'',0,''Position'',[0.04 0.7 0.25 0.0401],''String'',''Min Depth Temperature: ' temperature ''',''Style'',''text'',''Tag'',''StaticText Temperature'');'];
    saltext=['h1=uicontrol(''Parent'',h,''Units'',''normalized'',''ForegroundColor'',[redgreenblue]*1.1,''BackgroundColor'',[0,0,0],''fontunits'',''normalized'',''fontsize'',.7,''FontWeight'',''normal'',''ListboxTop'',0,''Position'',[0.04 0.6 0.21 0.0401],''String'',''Min Depth Salinity: ' salinity ''',''Style'',''text'',''Tag'',''StaticText Salinity'');'];
    %Overwrite lims to custom range
    titletext='h1=uicontrol(''Parent'',h,''Units'',''normalized'',''ForegroundColor'',[redgreenblue]*1.1,''BackgroundColor'',[0,0,0],''fontunits'',''normalized'',''fontsize'',.7,''FontWeight'',''normal'',''ListboxTop'',0,''Position'',[0.04 0.4 0.20 0.0401],''String'',''Set new colorbar limits:'',''Style'',''text'',''Tag'',''StaticText limntitle'',''TooltipString'',[''Enter new colorbar minimum'' char(10) ''and maximum values,'' char(10) ''then press update'']);';
    maxtext='h1=uicontrol(''Parent'',h,''Units'',''normalized'',''ForegroundColor'',[redgreenblue]*1.1,''BackgroundColor'',[0,0,0],''fontunits'',''normalized'',''fontsize'',.7,''FontWeight'',''normal'',''ListboxTop'',0,''Position'',[0.04 0.35 0.15 0.0401],''String'',''Maximum Value:'',''Style'',''text'',''Tag'',''StaticText limnmax'',''TooltipString'',[''Enter new colorbar minimum'' char(10) ''and maximum values,'' char(10) ''then press update'']);';
    mintext='h1=uicontrol(''Parent'',h,''Units'',''normalized'',''ForegroundColor'',[redgreenblue]*1.1,''BackgroundColor'',[0,0,0],''fontunits'',''normalized'',''fontsize'',.7,''FontWeight'',''normal'',''ListboxTop'',0,''Position'',[0.04 0.25 0.15 0.0401],''String'',''Minimum Value:'',''Style'',''text'',''Tag'',''StaticText limnmin'',''TooltipString'',[''Enter new colorbar minimum'' char(10) ''and maximum values,'' char(10) ''then press update'']);';
    maxbox='h1=uicontrol(''Parent'',h,''Units'',''normalized'',''BackgroundColor'',[1 1 1],''fontunits'',''normalized'',''fontsize'',.7,''FontWeight'',''normal'',''Position'',[0.055 0.3 0.15 0.0401],''Style'',''edit'',''TooltipString'',[''Enter new colorbar minimum'' char(10) ''and maximum values,'' char(10) ''then press update''],''Tag'',''Edittext maxlimn';
    minbox='h1=uicontrol(''Parent'',h,''Units'',''normalized'',''BackgroundColor'',[1 1 1],''fontunits'',''normalized'',''fontsize'',.7,''FontWeight'',''normal'',''Position'',[0.055 0.2 0.15 0.0401],''Style'',''edit'',''TooltipString'',[''Enter new colorbar minimum'' char(10) ''and maximum values,'' char(10) ''then press update''],''Tag'',''Edittext minlimn';
    maxminbutton='h1=uicontrol(''Parent'',h,''Units'',''normalized'',''BackgroundColor'',[redgreenblue]*1.1,''fontunits'',''normalized'',''fontsize'',.42,''FontWeight'',''normal'',''ListboxTop'',0,''Position'',[0.055 0.12 0.15 0.055],''Style'',''pushbutton'',''String'',''Data Min/Max Values'',''TooltipString'',[''Change listed minimum and maximum values'' char(10) ''to the minimum and maximum values in the data.'' char(10) '' '' char(10) ''This button does not update any plots, it just'' char(10) ''adjusts the typed values.''],''Tag'',''Pushbutton UpdateValues';
    updatebutton='h1=uicontrol(''Parent'',h,''Units'',''normalized'',''BackgroundColor'',[redgreenblue]*1.1,''fontunits'',''normalized'',''fontsize'',.41,''FontWeight'',''normal'',''ListboxTop'',0,''Position'',[0.055 0.05 0.15 0.055],''Style'',''pushbutton'',''String'',''Change and Replot'',''TooltipString'',[''Click to change colorbar minimum and maximum '' char(10) ''values to the listed minimum and maximum values'' char(10) ''and replot.'' char(10) '' '' char(10) ''NOTE: Adjustment will occur immediately only '' char(10) ''if there is no replotting. Otherwise, the change'' char(10) ''will take effect on the next reset.''],''Tag'',''Pushbutton UpdatePlots';
    exitbutton='h1=uicontrol(''Parent'',h,''Units'',''normalized'',''BackgroundColor'',[redgreenblue]*1.1,''fontunits'',''normalized'',''fontsize'',.42,''FontWeight'',''normal'',''ListboxTop'',0,''Position'',[0.84 0.05 0.15 0.055],''Style'',''pushbutton'',''String'',''Close and Exit'',''TooltipString'',[''Use to close graphs and stop replotting.''],''Tag'',''Pushbutton Exit';
    [nxgrd,nygrd]=gridsize(b(:,4));
    if HydroXYZval,
        pause(1);
        h=findobj('tag',deblank(plotnames(1,:)));if isempty(h),figure('tag',deblank(plotnames(1,:))),h=findobj('tag',deblank(plotnames(1,:)));else,figure(h),load azel;end;clf;
        set(h,'units','normalized','position',[0.1 0.075 0.8 0.8]);
        ah=subplot(335);set(ah,'position',[.2 .15 .7 .7]);
        if CreateDotPlotval,cbaroutput=xyz_colordotplot_cbaroutput([b(:,3),b(:,2),b(:,4),b(:,5)],16,'jet',limn(1,:));else,curtain3(b,nxgrd,nygrd,1,az,el,h);end;title('\bf Temperature \rm(^oC)','fontsize',14);set(h,'numbertitle','off','name',plotnames(1,:));
        cbar=colorbar;ylabel(cbar,plotnames(1,:));set(cbar,'Color',[1 1 1]);caxis(cbaroutput);
        set(gca,'dataaspectratio',[1 1 500]);axissnug;
        cameratoolbar(gcf,'show');cameratoolbar(gcf,'setmode','orbit');axis vis3d;hold off;
        eval([lattext,lontext,temptext,saltext,titletext,maxtext,mintext]);
        eval([[maxbox,'1'',''String'',''' num2str(limn(1,2)) ''');'],[minbox,'1'',''String'',''' num2str(limn(1,1)) ''');']])
        eval([maxminbutton,'1'',''Callback'',''updateminmax(1,5);'');'])
        eval([updatebutton,'1'',''Callback'',''updateresultplots(1);'');'])
        eval([exitbutton,'1'',''Callback'',[''global replotval plotnames;replotval=-1;for i=1:size(plotnames,1),close(findobj(''''Tag'''',deblank(plotnames(i,:))));end;close(findobj(''''Tag'''',''''plot composite''''));'']);'])
        pause(1);
        h=findobj('tag',deblank(plotnames(2,:)));if isempty(h),figure('tag',deblank(plotnames(2,:))),h=findobj('tag',deblank(plotnames(2,:)));else,figure(h),load azel;end;clf;
        set(h,'units','normalized','position',[0.1 0.075 0.8 0.8]);
        ah=subplot(335);set(ah,'position',[.2 .15 .7 .7]);
        if CreateDotPlotval,cbaroutput=xyz_colordotplot_cbaroutput([b(:,3),b(:,2),b(:,4),b(:,6)],16,'jet',limn(2,:));else,curtain3(b,nxgrd,nygrd,2,az,el,h);end;title('\bf Salinity','fontsize',14);set(h,'numbertitle','off','name',plotnames(2,:));
        cbar=colorbar;ylabel(cbar,plotnames(2,:));set(cbar,'Color',[1 1 1]);caxis(cbaroutput);
        set(gca,'dataaspectratio',[1 1 500]);axissnug;
        cameratoolbar(gcf,'show');cameratoolbar(gcf,'setmode','orbit');axis vis3d;hold off;
        eval([lattext,lontext,temptext,saltext,titletext,maxtext,mintext]);
        eval([[maxbox,'2'',''String'',''' num2str(limn(2,2)) ''');'],[minbox,'2'',''String'',''' num2str(limn(2,1)) ''');']])
        eval([maxminbutton,'2'',''Callback'',''updateminmax(2,6);'');'])
        eval([updatebutton,'2'',''Callback'',''updateresultplots(2);'');'])
        eval([exitbutton,'2'',''Callback'',[''global replotval plotnames;replotval=-1;for i=1:size(plotnames,1),close(findobj(''''Tag'''',deblank(plotnames(i,:))));end;close(findobj(''''Tag'''',''''plot composite''''));'']);'])
        pause(1);
        h=findobj('tag',deblank(plotnames(3,:)));if isempty(h),figure('tag',deblank(plotnames(3,:))),h=findobj('tag',deblank(plotnames(3,:)));else,figure(h),load azel;end;clf;
        set(h,'units','normalized','position',[0.1 0.075 0.8 0.8]);
        ah=subplot(335);set(ah,'position',[.2 .15 .7 .7]);
        if CreateDotPlotval,cbaroutput=xyz_colordotplot_cbaroutput([b(:,3),b(:,2),b(:,4),b(:,7)],16,'jet',limn(3,:));else,curtain3(b,nxgrd,nygrd,3,az,el,h);end;title('\bf Density \rm(\sigma_t)','fontsize',14);set(h,'numbertitle','off','name',plotnames(3,:));
        cbar=colorbar;ylabel(cbar,plotnames(3,:));set(cbar,'Color',[1 1 1]);caxis(cbaroutput);
        set(gca,'dataaspectratio',[1 1 500]);axissnug;
        cameratoolbar(gcf,'show');cameratoolbar(gcf,'setmode','orbit');axis vis3d;hold off;
        eval([lattext,lontext,temptext,saltext,titletext,maxtext,mintext]);
        eval([[maxbox,'3'',''String'',''' num2str(limn(3,2)) ''');'],[minbox,'3'',''String'',''' num2str(limn(3,1)) ''');']])
        eval([maxminbutton,'3'',''Callback'',''updateminmax(3,7);'');'])
        eval([updatebutton,'3'',''Callback'',''updateresultplots(3);'');'])
        eval([exitbutton,'3'',''Callback'',[''global replotval plotnames;replotval=-1;for i=1:size(plotnames,1),close(findobj(''''Tag'''',deblank(plotnames(i,:))));end;close(findobj(''''Tag'''',''''plot composite''''));'']);'])
        pause(1);
        h=findobj('tag',deblank(plotnames(4,:)));if isempty(h),figure('tag',deblank(plotnames(4,:))),h=findobj('tag',deblank(plotnames(4,:)));else,figure(h),load azel;end;clf;
        set(h,'units','normalized','position',[0.1 0.075 0.8 0.8]);
        ah=subplot(335);set(ah,'position',[.2 .15 .7 .7]);
        if CreateDotPlotval,cbaroutput=xyz_colordotplot_cbaroutput([b(:,3),b(:,2),b(:,4),b(:,8)],16,'jet',limn(4,:));else,curtain3(b,nxgrd,nygrd,4,az,el,h);end;title('\bf Fluorescence \rm(\mug chlorophyll a / liter)','fontsize',14);set(h,'numbertitle','off','name',plotnames(4,:));
        cbar=colorbar;ylabel(cbar,plotnames(4,:));set(cbar,'Color',[1 1 1]);caxis(cbaroutput);
        set(gca,'dataaspectratio',[1 1 500]);axissnug;
        cameratoolbar(gcf,'show');cameratoolbar(gcf,'setmode','orbit');axis vis3d;hold off;
        eval([lattext,lontext,temptext,saltext,titletext,maxtext,mintext]);
        eval([[maxbox,'4'',''String'',''' num2str(limn(4,2)) ''');'],[minbox,'4'',''String'',''' num2str(limn(4,1)) ''');']])
        eval([maxminbutton,'4'',''Callback'',''updateminmax(4,8);'');'])
        eval([updatebutton,'4'',''Callback'',''updateresultplots(4);'');'])
        eval([exitbutton,'4'',''Callback'',[''global replotval plotnames;replotval=-1;for i=1:size(plotnames,1),close(findobj(''''Tag'''',deblank(plotnames(i,:))));end;close(findobj(''''Tag'''',''''plot composite''''));'']);'])
        pause(1);
        %2018-04-17 JAE Changed Turbidity units to Nepelometric
        h=findobj('tag',deblank(plotnames(5,:)));if isempty(h),figure('tag',deblank(plotnames(5,:))),h=findobj('tag',deblank(plotnames(5,:)));else,figure(h),load azel;end;clf;
        set(h,'units','normalized','position',[0.1 0.075 0.8 0.8]);
        ah=subplot(335);set(ah,'position',[.2 .15 .7 .7]);
        if CreateDotPlotval,cbaroutput=xyz_colordotplot_cbaroutput([b(:,3),b(:,2),b(:,4),b(:,9)],16,'jet',limn(5,:));else,curtain3(b,nxgrd,nygrd,5,az,el,h);end;title('\bf Optical Backscatter \rm(Nephelometric Units)','fontsize',14);set(h,'numbertitle','off','name',plotnames(5,:)); 
        cbar=colorbar;ylabel(cbar,plotnames(5,:));set(cbar,'Color',[1 1 1]);caxis(cbaroutput);
        set(gca,'dataaspectratio',[1 1 500]);axissnug;
        cameratoolbar(gcf,'show');cameratoolbar(gcf,'setmode','orbit');axis vis3d;hold off;
        eval([lattext,lontext,temptext,saltext,titletext,maxtext,mintext]);
        eval([[maxbox,'5'',''String'',''' num2str(limn(5,2)) ''');'],[minbox,'5'',''String'',''' num2str(limn(5,1)) ''');']])
        eval([maxminbutton,'5'',''Callback'',''updateminmax(5,9);'');'])
        eval([updatebutton,'5'',''Callback'',''updateresultplots(5);'');'])
        eval([exitbutton,'5'',''Callback'',[''global replotval plotnames;replotval=-1;for i=1:size(plotnames,1),close(findobj(''''Tag'''',deblank(plotnames(i,:))));end;close(findobj(''''Tag'''',''''plot composite''''));'']);'])
        pause(1);
        %2018-04-17 JAE Added Oxygen Plot
        h=findobj('tag',deblank(plotnames(6,:)));if isempty(h),figure('tag',deblank(plotnames(6,:))),h=findobj('tag',deblank(plotnames(6,:)));else,figure(h),load azel;end;clf;
        set(h,'units','normalized','position',[0.1 0.075 0.8 0.8]);
        ah=subplot(335);set(ah,'position',[.2 .15 .7 .7]);
        if CreateDotPlotval,cbaroutput=xyz_colordotplot_cbaroutput([b(:,3),b(:,2),b(:,4),b(:,12)],16,'jet',limn(6,:));else,curtain3(b,nxgrd,nygrd,5,az,el,h);end;title('\bf Oxygen \rm(ml/l)','fontsize',14);set(h,'numbertitle','off','name',plotnames(6,:));
        cbar=colorbar;ylabel(cbar,plotnames(6,:));set(cbar,'Color',[1 1 1]);caxis(cbaroutput);
        set(gca,'dataaspectratio',[1 1 500]);axissnug;
        cameratoolbar(gcf,'show');cameratoolbar(gcf,'setmode','orbit');axis vis3d;hold off;
        eval([lattext,lontext,temptext,saltext,titletext,maxtext,mintext]);
        eval([[maxbox,'6'',''String'',''' num2str(limn(6,2)) ''');'],[minbox,'6'',''String'',''' num2str(limn(6,1)) ''');']])
        eval([maxminbutton,'6'',''Callback'',''updateminmax(6,12);'');'])
        eval([updatebutton,'6'',''Callback'',''updateresultplots(6);'');'])
        eval([exitbutton,'6'',''Callback'',[''global replotval plotnames;replotval=-1;for i=1:size(plotnames,1),close(findobj(''''Tag'''',deblank(plotnames(i,:))));end;close(findobj(''''Tag'''',''''plot composite''''));'']);'])
        pause(1);
        h=findobj('tag',deblank(plotnames(7,:)));if isempty(h),figure('tag',deblank(plotnames(7,:))),h=findobj('tag',deblank(plotnames(7,:)));else,figure(h),load azel;end;clf;
        set(h,'units','normalized','position',[0.1 0.075 0.8 0.8]);
        ah=subplot(335);set(ah,'position',[.2 .15 .7 .7]);
        if CreateDotPlotval,cbaroutput=xyz_colordotplot_cbaroutput([b(:,3),b(:,2),b(:,4),b(:,10)],16,'jet',limn(7,:));else,curtain3(b,nxgrd,nygrd,6,az,el,h);end;title('\bf PAR ','fontsize',14);set(h,'numbertitle','off','name',plotnames(7,:));
        cbar=colorbar;ylabel(cbar,plotnames(7,:));set(cbar,'Color',[1 1 1]);caxis(cbaroutput);
        set(gca,'dataaspectratio',[1 1 500]);axissnug;
        cameratoolbar(gcf,'show');cameratoolbar(gcf,'setmode','orbit');axis vis3d;hold off;
        eval([lattext,lontext,temptext,saltext,titletext,maxtext,mintext]);
        eval([[maxbox,'7'',''String'',''' num2str(limn(7,2)) ''');'],[minbox,'7'',''String'',''' num2str(limn(7,1)) ''');']])
        eval([maxminbutton,'7'',''Callback'',''updateminmax(7,10);'');'])
        eval([updatebutton,'7'',''Callback'',''updateresultplots(7);'');'])
        eval([exitbutton,'7'',''Callback'',[''global replotval plotnames;replotval=-1;for i=1:size(plotnames,1),close(findobj(''''Tag'''',deblank(plotnames(i,:))));end;close(findobj(''''Tag'''',''''plot composite''''));'']);'])
        pause(1);
        if strcmp(fn(end-5:end),'.combo')%Check if it is a ECO Triplet Combined File
            %Total Backscattering Coefficient
            h=findobj('tag',deblank(plotnames(8,:)));if isempty(h),figure('tag',deblank(plotnames(8,:))),h=findobj('tag',deblank(plotnames(8,:)));else,figure(h),load azel;end;clf;
            set(h,'units','normalized','position',[0.1 0.075 0.8 0.8]);
            ah=subplot(335);set(ah,'position',[.2 .15 .7 .7]);
            if CreateDotPlotval,cbaroutput=xyz_colordotplot_cbaroutput([b(:,3),b(:,2),b(:,4),b(:,16)],16,'jet',limn(8,:));else,curtain3(b,nxgrd,nygrd,1,az,el,h);end;title('\bf Total Backscattering Coefficient b_b(\lambda) \rm(m^{-1})','fontsize',14);set(h,'numbertitle','off','name',plotnames(8,:));
            cbar=colorbar;ylabel(cbar,plotnames(8,:));set(cbar,'Color',[1 1 1]);caxis(cbaroutput);
            set(gca,'dataaspectratio',[1 1 500]);axissnug;
            cameratoolbar(gcf,'show');cameratoolbar(gcf,'setmode','orbit');axis vis3d;hold off;
            eval([lattext,lontext,temptext,saltext,titletext,maxtext,mintext]);
            eval([[maxbox,'8'',''String'',''' num2str(limn(8,2)) ''');'],[minbox,'8'',''String'',''' num2str(limn(8,1)) ''');']])
            eval([maxminbutton,'8'',''Callback'',''updateminmax(8,16);'');'])
            eval([updatebutton,'8'',''Callback'',''updateresultplots(8);'');'])
            eval([exitbutton,'8'',''Callback'',[''global replotval plotnames;replotval=-1;for i=1:size(plotnames,1),close(findobj(''''Tag'''',deblank(plotnames(i,:))));end;close(findobj(''''Tag'''',''''plot composite''''));'']);'])
            pause(1);
            %ECO Triplet Chlorophyll
            h=findobj('tag',deblank(plotnames(9,:)));if isempty(h),figure('tag',deblank(plotnames(9,:))),h=findobj('tag',deblank(plotnames(9,:)));else,figure(h),load azel;end;clf;
            set(h,'units','normalized','position',[0.1 0.075 0.8 0.8]);
            ah=subplot(335);set(ah,'position',[.2 .15 .7 .7]);
            if CreateDotPlotval,cbaroutput=xyz_colordotplot_cbaroutput([b(:,3),b(:,2),b(:,4),b(:,17)],16,'jet',limn(9,:));else,curtain3(b,nxgrd,nygrd,1,az,el,h);end;title('\bf ECO Triplet Chlorophyll \rm(\mug/L)','fontsize',14);set(h,'numbertitle','off','name',plotnames(9,:));
            cbar=colorbar;ylabel(cbar,plotnames(9,:));set(cbar,'Color',[1 1 1]);caxis(cbaroutput);
            set(gca,'dataaspectratio',[1 1 500]);axissnug;
            cameratoolbar(gcf,'show');cameratoolbar(gcf,'setmode','orbit');axis vis3d;hold off;
            eval([lattext,lontext,temptext,saltext,titletext,maxtext,mintext]);
            eval([[maxbox,'9'',''String'',''' num2str(limn(9,2)) ''');'],[minbox,'9'',''String'',''' num2str(limn(9,1)) ''');']])
            eval([maxminbutton,'9'',''Callback'',''updateminmax(9,17);'');'])
            eval([updatebutton,'9'',''Callback'',''updateresultplots(9);'');'])
            eval([exitbutton,'9'',''Callback'',[''global replotval plotnames;replotval=-1;for i=1:size(plotnames,1),close(findobj(''''Tag'''',deblank(plotnames(i,:))));end;close(findobj(''''Tag'''',''''plot composite''''));'']);'])
            pause(1);
            %CDOM
            h=findobj('tag',deblank(plotnames(10,:)));if isempty(h),figure('tag',deblank(plotnames(10,:))),h=findobj('tag',deblank(plotnames(10,:))');else,figure(h),load azel;end;clf;
            set(h,'units','normalized','position',[0.1 0.075 0.8 0.8]);
            ah=subplot(335);set(ah,'position',[.2 .15 .7 .7]);
            if CreateDotPlotval,cbaroutput=xyz_colordotplot_cbaroutput([b(:,3),b(:,2),b(:,4),b(:,18)],16,'jet',limn(10,:));else,curtain3(b,nxgrd,nygrd,1,az,el,h);end;title('\bf CDOM \rm(ppb)','fontsize',14);set(h,'numbertitle','off','name',plotnames(10,:));
            cbar=colorbar;ylabel(cbar,plotnames(10,:));set(cbar,'Color',[1 1 1]);caxis(cbaroutput);
            set(gca,'dataaspectratio',[1 1 500]);axissnug;
            cameratoolbar(gcf,'show');cameratoolbar(gcf,'setmode','orbit');axis vis3d;hold off;
            eval([lattext,lontext,temptext,saltext,titletext,maxtext,mintext]);
            eval([[maxbox,'10'',''String'',''' num2str(limn(10,2)) ''');'],[minbox,'10'',''String'',''' num2str(limn(10,1)) ''');']])
            eval([maxminbutton,'10'',''Callback'',''updateminmax(10,18);'');'])
            eval([updatebutton,'10'',''Callback'',''updateresultplots(10);'');'])
            eval([exitbutton,'10'',''Callback'',[''global replotval plotnames;replotval=-1;for i=1:size(plotnames,1),close(findobj(''''Tag'''',deblank(plotnames(i,:))));end;close(findobj(''''Tag'''',''''plot composite''''));'']);'])
        end
    end
    if HydroTimeval,
        pause(1);
        h=findobj('tag','plot env');if isempty(h),figure('tag','plot env'),h=findobj('tag','plot env');else,figure(h),end;clf;
        set(h,'numbertitle','off','name','Environmental Data');
        set(h,'units','normalized','position',[0.1 0.075 0.8 0.8])
        clf;
        vpraqplotctdftlt(b(:,1),b(:,5),b(:,6),b(:,7),b(:,8),b(:,9),b(:,10));
    end;
    if Flightval,
        pause(1);
        h=findobj('tag','plot flight');if isempty(h),figure('tag','plot flight'),h=findobj('tag','plot flight');else,figure(h),end;clf;
        set(h,'numbertitle','off','name','Flight Control Data');
        set(h,'units','normalized','position',[0.1 0.075 0.8 0.8])
        clf;
        vpraqplotsrpaz(b(:,1),b(:,4),b(:,11),b(:,12),b(:,13),b(:,14),b(:,15));
    end;
    if Courseplotval, 
        pause(1);
        h=findobj('tag','plot course');if isempty(h),figure('tag','plot course'),h=findobj('tag','plot course');else,figure(h),end;clf;
        set(h,'numbertitle','off','name','Courseplot');
        set(h,'units','normalized','position',[0.1 0.075 0.8 0.8])
        clf;
        courseplot(b(:,1),b(:,2),b(:,3));

    end
    if Planktonval,
        pause(1);
        h=findobj('tag','plot bugs');if isempty(h),figure('tag','plot bugs'),h=findobj('tag','plot bugs');else,figure(h),load azel;end;clf;
        hbugs=h;
        clf;
        set(hbugs,'numbertitle','off','name','Taxon Plot');
        set(hbugs,'units','normalized','position',[0.1 0.075 0.8 0.8]);
        realbugplot;
        if buginit==1,buginit=0;end;
    end
%     hcurrent=findobj('tag','plot fluo');if ~isempty(hcurrent),figure(hcurrent);end
    
    
    %ldt=length(dtime);figure(16);plot(dtime(ldt-600:ldt),-pr(ldt-600:ldt),'.-',dtime(ldt-600:ldt),-bz(ldt-600:ldt),'r.-');grid on;set(gcf,'position',[38 13 1096 116])
    
    % end     %If i
    pause(1);
    h=findobj('tag','plot composite');if isempty(h),figure('tag','plot composite'),h=findobj('tag','plot composite');else,figure(h),load azel;end;clf;
    if CreateDotPlotval,
        set(h,'numbertitle','off','name','Composite: Sal, Temp, Dens, Fluor');
        set(h,'units','normalized','position',[0.1 0.075 0.8 0.8]);     
        subplot(221)
        cbaroutput=xyz_colordotplot_cbaroutput([b(:,3),b(:,2),b(:,4),b(:,5)],16,'jet',limn(1,:));
        cbar=colorbar;ylabel(cbar,'Temperature');set(cbar,'Color',[1 1 1]);caxis(cbaroutput);
        title('\bf Temperature \rm(^oC)','fontsize',14);
        set(gca,'dataaspectratio',[1 1 500]);axissnug;
        cameratoolbar(gcf,'show');cameratoolbar(gcf,'setmode','orbit');axis vis3d;hold off;
        subplot(222)
        cbaroutput=xyz_colordotplot_cbaroutput([b(:,3),b(:,2),b(:,4),b(:,6)],16,'jet',limn(2,:));
        cbar=colorbar;ylabel(cbar,'Salinity');set(cbar,'Color',[1 1 1]);caxis(cbaroutput);
        title('\bf Salinity','fontsize',14);
        set(gca,'dataaspectratio',[1 1 500]);axissnug;
        cameratoolbar(gcf,'show');cameratoolbar(gcf,'setmode','orbit');axis vis3d;hold off;
        subplot(223)
        cbaroutput=xyz_colordotplot_cbaroutput([b(:,3),b(:,2),b(:,4),b(:,7)],16,'jet',limn(3,:));
        cbar=colorbar;ylabel(cbar,'Density');set(cbar,'Color',[1 1 1]);caxis(cbaroutput);
        title('\bf Density \rm(\sigma_t)','fontsize',14);
        set(gca,'dataaspectratio',[1 1 500]);axissnug;
        cameratoolbar(gcf,'show');cameratoolbar(gcf,'setmode','orbit');axis vis3d;hold off;
        subplot(224)
        cbaroutput=xyz_colordotplot_cbaroutput([b(:,3),b(:,2),b(:,4),b(:,8)],16,'jet',limn(4,:));
        cbar=colorbar;ylabel(cbar,'Fluorescence');set(cbar,'Color',[1 1 1]);caxis(cbaroutput);
        title('\bf Fluorescence \rm(\mug chlorophyll a / liter)','fontsize',14);
        set(gca,'dataaspectratio',[1 1 500]);axissnug;
        cameratoolbar(gcf,'show');cameratoolbar(gcf,'setmode','orbit');axis vis3d;hold off;
    end

    if replotval==-1;
        repeat=0;
        for i=1:size(plotnames,1)
            %Wait until all figures are closed.
            waitfor(findobj('Tag',deblank(plotnames(i,:))));
        end
        if ~repeat
            plotflag=0;
            save plotflag plotflag;
        end
    else
        pause(replotval) % pause for replotval seconds before repeating plotting sequence
        if replotval==-1;
            for i=1:size(plotnames,1)
                %Wait until all figures are closed.
                waitfor(findobj('Tag',deblank(plotnames(i,:))));
                plotflag=0;
                save plotflag plotflag;
            end
        end
    end
    load plotflag
    
end; %while
