% flagbadadv - interactively flag bad ADV data % % flagbadadv('QualityFile', cdfqFile,'settings', settings) % % cdfqFile = neCDF quality file generated by adr2cdf % Results and settings are returned to the qFile % settings.currentBeam: 1 the beam operated on % settings.new_bad: {[]; []; []; [1 2 3]; []} % 5 cell matrix of arrays of burst numbers of known % bad data to add to mask override % settings.new_good: {[]; [101]; []; [1 2 3]; [35]} % 5 cell matrix of arrays of burst numbers of % known good data to pass to mask override % settings.new_scutoff: 5 element array with a new velocity standard % deviation threshold % settings.new_ccutoff: 5 element array with a new correlation threshold % % Note: this gui is constrained to 5 subbursts because that's all there is % room to plot. The file flagbadadv.fig is required by flagbadadv.m % Note: using the mouse pointer or the edit field to add bursts to the % override lists is very sticky, it will not be undone by changing the % cutoff thresholds % % Written by Marinna Martini for the U.S. Geological Survey % Coastal & Marine Program Woods Hole Field Center, Woods Hole, MA % http://woodshole.er.usgs.gov/ Please report bugs to mmartini@usgs.gov % % 11/17/05 % allow user to work on partial burst ranges. Leave as a hidden feature % for now. If a range is specified and the user changes a threshold, the % threshold will be recorded in the qfile, and loaded the next time % flagbadadv is run... which might wipe out previous mask settings % useage is: % BurstNumRange = [m:n]; % have flagbadadv work on a subset of bursts % 11/16/05 % -- fix a few little issues, including making the color scheme simpler. % Version 2.0 10/19/05 % use the netCDF qaulity file and improve logic % Version 1.2 3/9/05 go back to the version needing flagbadadv.fig. Handle % systems without pressure sensors % Version 1.1 1/11/05 make flagbadadv.fig unnecessary in distribution % Version 1.0 11/19/04 change toggles to overrides for good and bad points % allow user to preload these overrides % change bottom plot to psdev % change all flags points to red % Version 0.5 9/15/04 added correlation cutoff % Version 0.0 10/11/04 function varargout = flagbadadv(varargin) % FLAGBADADV M-file for flagbadadv.fig % FLAGBADADV, by itself, creates a new FLAGBADADV or raises the existing % singleton*. % % H = FLAGBADADV returns the handle to a new FLAGBADADV or the handle to % the existing singleton*. % % FLAGBADADV('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in FLAGBADADV.M with the given input % arguments. % % FLAGBADADV('Property','Value',...) creates a new FLAGBADADV or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before flagbadadv_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to flagbadadv_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Copyright 2002-2003 The MathWorks, Inc. % TODO freeze zoom until user unzooms by tracking the axis limits and % resetting them % Last Modified by GUIDE v2.5 22-Nov-2005 10:31:35 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @flagbadadv_OpeningFcn, ... 'gui_OutputFcn', @flagbadadv_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before flagbadadv is made visible. function flagbadadv_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to flagbadadv (see VARARGIN) handles.mydata = []; for i = 1:2:length(varargin), if strcmp(varargin{i},'QualityFile'), handles.mydata.cdfqFile = varargin{i+1}; end if strcmp(varargin{i},'settings'), handles.mydata.settings = varargin{i+1}; end if strcmp(varargin{i},'BurstNumRange'), handles.mydata.BurstNumRange = varargin{i+1}; end end if ~isfield(handles.mydata,'cdfqFile'), [filename, pathname] = uigetfile('*.*','Open a netCDF file containing burst Hydra data'); if ~filename, return; end handles.mydata.cdfqFile = fullfile(pathname, filename); end if ~isfield(handles.mydata,'settings'), handles.mydata.settings = []; end if ~isfield(handles.mydata.settings,'new_bad'), handles.mydata.settings.new_bad = {[],[],[],[],[]}; end if ~isfield(handles.mydata.settings,'new_good'), handles.mydata.settings.new_good = {[],[],[],[],[]}; end if ~isfield(handles.mydata.settings,'currentBeam'), handles.mydata.settings.currentBeam = 1; end if ~isfield(handles.mydata,'BurstNumRange'), handles.mydata.BurstNumRange = []; end % get data from qfile if exist(handles.mydata.cdfqFile,'file'), handles.mydata.cdfq = netcdf(handles.mydata.cdfqFile,'write'); if isempty(handles.mydata.cdfq), disp(sprintf('Failure to open netCDF burst file %s',handles.mydata.cdfqFile)) return end else disp(sprintf('Failure to find netCDF burst file %s',handles.mydata.cdfqFile)) return end handles.mydata.currentBeam = handles.mydata.settings.currentBeam; if isfield(handles.mydata, 'currentBeam'), if handles.mydata.currentBeam > length(handles.mydata.cdfq('axis')), handles.mydata.currentBeam = length(handles.mydata.cdfq('axis')); elseif handles.mydata.currentBeam < 1, handles.mydata.currentBeam = 1; end else handles.mydata.currentBeam = 1; end idx = []; % get the quality data handles.mydata.burstNum = handles.mydata.cdfq{'burst'}(:); % check the burst range requested if isempty(handles.mydata.BurstNumRange), % user wants all the bursts handles.mydata.iBurstNumRange(1) = 1; handles.mydata.iBurstNumRange(2) = length(handles.mydata.burstNum); else % user has specified a range, so make sure it's valid and look up the indeces idx = find(handles.mydata.burstNum == handles.mydata.BurstNumRange(1),1,'first'); if isempty(idx), disp('Can''t find requested starting burst number, ') disp(sprintf('using first burst in qulity file = %d',handles.mydata.burstNum(1))); handles.mydata.iBurstNumRange(1) = 1; else handles.mydata.iBurstNumRange(1) = idx; end idx = find(handles.mydata.burstNum == handles.mydata.BurstNumRange(2),1,'first'); if isempty(idx), disp('Can''t find requested ending burst number, ') disp(sprintf('using last burst in qulity file = %d',handles.mydata.burstNum(end))); handles.mydata.iBurstNumRange(2) = length(handles.mydata.burstNum); else handles.mydata.iBurstNumRange(2) = idx; end end % iBurstNumRange is now an accurate index range to the file % the indeces now used by flagbadadv will refer to the subset of data % loaded as follows: disp(sprintf('Reading burst %d to %d from the quality file....',... handles.mydata.cdfq{'burst'}(handles.mydata.iBurstNumRange(1)),... handles.mydata.cdfq{'burst'}(handles.mydata.iBurstNumRange(2)))) b1 = handles.mydata.iBurstNumRange(1); b2 = handles.mydata.iBurstNumRange(2); handles.mydata.burstNum = handles.mydata.cdfq{'burst'}(b1:b2); % reread the burt numbers for the subset we're working on handles.mydata.tm = datenum(gregorian(handles.mydata.cdfq{'time'}(b1:b2)+handles.mydata.cdfq{'time2'}(b1:b2)./(1000*3600*24))); handles.mydata.stdv(:,:) = handles.mydata.cdfq{'flagbadadv_stdv'}(b1:b2,handles.mydata.currentBeam,:); % should be [nbursts x 5 subbursts] handles.mydata.mcor(:,:) = handles.mydata.cdfq{'flagbadadv_mcor'}(b1:b2,handles.mydata.currentBeam,:); % should be [nbursts x 5 subbursts] handles.mydata.stdp = handles.mydata.cdfq{'flagbadadv_stdp'}(b1:b2); handles.mydata.cdfqFile = handles.mydata.cdfqFile; handles.mydata.nSubbursts = length(handles.mydata.cdfq('subburst')); handles.mydata.ivthsubbads(:,:) = handles.mydata.cdfq{'flagbadadv_ivthsubbads'}(b1:b2,handles.mydata.currentBeam,:); handles.mydata.icthsubbads(:,:) = handles.mydata.cdfq{'flagbadadv_icthsubbads'}(b1:b2,handles.mydata.currentBeam,:); handles.mydata.nBursts = length(handles.mydata.tm); handles.mydata.scutoff = handles.mydata.cdfq{'flagbadadv_scutoff'}(handles.mydata.settings.currentBeam,:); handles.mydata.ccutoff = handles.mydata.cdfq{'flagbadadv_ccutoff'}(handles.mydata.settings.currentBeam,:); handles.mydata.mask(:,:) = handles.mydata.cdfq{'flagbadadv_mask'}(b1:b2,handles.mydata.settings.currentBeam,:); handles.mydata.override_as_bad(:,:) = handles.mydata.cdfq{'flagbadadv_override_as_bad'}(b1:b2,handles.mydata.settings.currentBeam,:); handles.mydata.override_as_good(:,:) = handles.mydata.cdfq{'flagbadadv_override_as_good'}(b1:b2,handles.mydata.settings.currentBeam,:); idx = []; % then, add any new overrides the user has provided for iSubburst = 1:handles.mydata.nSubbursts, % translate burst numbers to file indexes for n = 1:length(handles.mydata.settings.new_bad{iSubburst}), idx(n) = find(handles.mydata.settings.new_bad{iSubburst}(n) == handles.mydata.burstNum,1,'first'); end % then into a mask if ~isempty(idx), handles.mydata.override_as_bad(idx,iSubburst) = ones(size(idx)); end end idx = []; % repeat for the good overrides for iSubburst = 1:handles.mydata.nSubbursts, % translate burst numbers to file indexes for n = 1:length(handles.mydata.settings.new_good{iSubburst}), idx(n) = find(handles.mydata.settings.new_good{iSubburst}(n) == handles.mydata.burstNum,1,'first'); end % then into a mask if ~isempty(idx), handles.mydata.override_as_good(idx,iSubburst) = ones(size(idx)); end end if isfield(handles.mydata.settings,'new_scutoff'), for iSubburst = 1:handles.mydata.nSubbursts, handles.mydata.scutoff(iSubburst) = handles.mydata.settings.new_scutoff(iSubburst); end end if isfield(handles.mydata.settings,'new_ccutoff'), for iSubburst = 1:handles.mydata.nSubbursts, handles.mydata.ccutoff(iSubburst) = handles.mydata.settings.new_ccutoff(iSubburst); end end % apply these handles.mydata = flagbads(hObject, handles); % calculated the stats for pressure for plotting later if isempty(handles.mydata.stdp), % we're only making one plot of pressure std, so plot the mean of the subburst values handles.mydata.stdpm = ones(size(handles.mydata.burstNum)).*NaN; else handles.mydata.stdpm = mean(handles.mydata.stdp,2); end % set the cutoff boxes to the cutoff used based on the seed for iSubburst = 1:handles.mydata.nSubbursts, buffer = sprintf('%6.2f',handles.mydata.scutoff(iSubburst)); eval(sprintf('set(handles.editscutoff%d,''String'',buffer);',iSubburst)) buffer = sprintf('%6.2f',handles.mydata.ccutoff(iSubburst)); eval(sprintf('set(handles.editccutoff%d,''String'',buffer);',iSubburst)) end set(handles.editTogBurst,'String','?,?') % update the objects guidata(hObject, handles); % This sets up the initial plot - only do when we are invisible % so window can get raised using example. if strcmp(get(hObject,'Visible'),'off') updateplots(hObject, handles, 'init') % save the initial axes limits for fiddling with zoom later. kids = get(handles.figure1,'children'); for i = 1:length(kids), iAx = []; buf = get(kids(i),'tag'); if findstr(buf, 'cor'), iAx = 1; iPlot = str2num(buf(end)); elseif findstr(buf, 'std'), iAx = 2; iPlot = str2num(buf(end)); end if ~isempty(iAx), handles.oxLims{iPlot,iAx} = get(kids(i),'xlim'); handles.oyLims{iPlot,iAx} = get(kids(i),'ylim'); handles.cxLims{iPlot,iAx} = handles.oxLims{iPlot,iAx}; handles.cyLims{iPlot,iAx} = handles.oyLims{iPlot,iAx}; end end end handles.mydata.initialize = 1; % make sure the delete function is called when the figure is closed set(handles.figure1,'DeleteFcn',... ['disp(''Saving marks to quality file''); ',... 'handles = guidata(gcbo); ',... 'b1 = handles.mydata.iBurstNumRange(1); b2 = handles.mydata.iBurstNumRange(2); ',... 'handles.mydata.cdfq{''flagbadadv_scutoff''}(handles.mydata.settings.currentBeam,:) = handles.mydata.scutoff; ',... 'handles.mydata.cdfq{''flagbadadv_ccutoff''}(handles.mydata.settings.currentBeam,:) = handles.mydata.ccutoff; ',... 'handles.mydata.cdfq{''flagbadadv_mask''}(b1:b2,handles.mydata.settings.currentBeam,:) = handles.mydata.mask; ',... 'handles.mydata.cdfq{''flagbadadv_override_as_bad''}(b1:b2,handles.mydata.settings.currentBeam,:) = handles.mydata.override_as_bad; ',... 'handles.mydata.cdfq{''flagbadadv_override_as_good''}(b1:b2,handles.mydata.settings.currentBeam,:) = handles.mydata.override_as_good; ',... 'close (handles.mydata.cdfq);']); % update the objects guidata(hObject, handles); return % UIWAIT makes flagbadadv wait for user response (see UIRESUME) % this is not good, as one can't concurrently do anything else (like run % ncbrowse or browsehydraburst concurrently. % However, not using uwait means that I can't return results via varargout % hence dumping the results to the workspace during the delete_fcn call % uiwait(handles.figure1); % ------------------ updates the plot - this is a user function function updateplots(hObject, handles, zoomcontrol) if strcmp(get(gcf,'visible'),'off'), init = 1; else init = 0; end % must check here theBlockStdAxes = {handles.axes1, handles.axes2, handles.axes3, handles.axes4, handles.axes5}; theStdStdAxes = handles.axes6; axes(theStdStdAxes); cla; if isfield(handles.mydata,'tm'), plot(handles.mydata.tm,handles.mydata.stdpm) set(gca,'xlim',[handles.mydata.tm(1) handles.mydata.tm(end)]) datetick('x','keeplimits','keepticks') else plot(handles.mydata.burstNum,handles.mydata.stdpm) set(gca,'xlim',[handles.mydata.burstNum(1) handles.mydata.burstNum(end)]) xlabel('Burst Number') end %set(gca,'ylim',[0 20]) ylabel('mean PSDEV for all') for iPlot = 1:length(theBlockStdAxes), allbads = find(handles.mydata.mask(:,iPlot)); overbads = find(handles.mydata.override_as_bad(:,iPlot)); overgoods = find(handles.mydata.override_as_good(:,iPlot)); axes(theBlockStdAxes{iPlot}); xl = get(gca,'xlim'); cla; % the way plotyy works, the std vel plots ends u on top and active [theAx, theLine1, theLine2] = plotyy(handles.mydata.burstNum,handles.mydata.mcor(:,iPlot),... handles.mydata.burstNum,handles.mydata.stdv(:,iPlot)); % activate only set(theLine2,'ButtonDownFcn','flagbadadv(''stdvline_ButtonDownFcn'',gcbo,[],guidata(gcbo))',... 'UserData',iPlot); % label the subbursts so we know which one we get later when the user clicks set(get(theAx(1),'ylabel'),'string',sprintf('Cor %d',iPlot)); set(theAx(1),'tag',sprintf('cor%d',iPlot)); set(theAx(2),'tag',sprintf('std%d',iPlot)); % use 'line' here instead to add lines, plot is destroying the axis object theLine6 = line(handles.mydata.burstNum,ones(handles.mydata.nBursts,1).*handles.mydata.ccutoff(iPlot),... 'linestyle','--','color',get(theLine1,'color')); axes(theAx(2)) theLine3 = line(handles.mydata.burstNum,ones(handles.mydata.nBursts,1).*handles.mydata.scutoff(iPlot),... 'linestyle','--','color',get(theLine2,'color')); theMaskMarkers = line(handles.mydata.burstNum(allbads),handles.mydata.stdv(allbads,iPlot),'linestyle','none','marker','.','color','r'); theOverBadMarkers = line(handles.mydata.burstNum(overbads),handles.mydata.stdv(overbads,iPlot),'linestyle','none','marker','*','color','r'); theOverGoodMarkers = line(handles.mydata.burstNum(overgoods),handles.mydata.stdv(overgoods,iPlot),'linestyle','none','marker','o','color','r'); set(theMaskMarkers,'ButtonDownFcn','flagbadadv(''stdvline_ButtonDownFcn'',gcbo,[],guidata(gcbo))',... 'UserData',iPlot); % label the subbursts so we know which one we get later when the user clicks set(get(theAx(2),'ylabel'),'string',sprintf('STD Vel %d',iPlot)) %if strcmp(zoomcontrol,'init'), set(theAx,'xlim',[handles.mydata.burstNum(1) handles.mydata.burstNum(end)]) % really only need this the first time %elseif strcmp(zoomcontrol,'hold'), % restore the axes to what the user had zoomed to when something was pushed % set(theAx(1),'ylim',handles.cyLims{iPlot,1}); %cor % set(theAx(2),'ylim',handles.cyLims{iPlot,2}); % set(theAx(1),'xlim',handles.cxLims{iPlot,1}); % std % set(theAx(2),'xlim',handles.cxLims{iPlot,2}); %end linkaxes(theAx,'x') % now both plotyy axes will zoom together if iPlot == 1, title(['Beam ',int2str(handles.mydata.settings.currentBeam),... ' quality data by subburst from ',handles.mydata.cdfqFile],'interpreter','none') elseif iPlot == 5, set(get(theAx(2),'xlabel'),'string','Burst Number') end end % ------------------ finds the baddata based on Vel STD cutoffs set by user function mydata = flagbads(hObject, handles) % first, clear the mask handles.mydata.mask = zeros(size(handles.mydata.mask)); for iSubburst = 1:handles.mydata.nSubbursts, % assume user changed the cutoff value, find the new indeces that are bad ivthsubbads = find(handles.mydata.stdv(:,iSubburst) >= handles.mydata.scutoff(iSubburst)); if ~isempty(ivthsubbads), handles.mydata.ivthsubbads(ivthsubbads,iSubburst) = ones(size(ivthsubbads)); end icthsubbads = find(handles.mydata.mcor(:,iSubburst) < handles.mydata.ccutoff(iSubburst)); if ~isempty(icthsubbads), handles.mydata.icthsubbads(icthsubbads,iSubburst) = ones(size(icthsubbads)); end % first shot at a mask is the union of subbursts failing the thresholds idx = union(ivthsubbads, icthsubbads); % these are the new bad points based on the current threshold settings handles.mydata.mask(idx,iSubburst) = ones(size(idx)); % now apply the user overides, forcing good and bad idx = find(handles.mydata.override_as_bad(:,iSubburst)); % indeces to bad data if ~isempty(idx), handles.mydata.mask(idx,iSubburst) = ones(size(idx)); end % force these as marked bad idx = find(handles.mydata.override_as_good(:,iSubburst)); % indeces to good data if ~isempty(idx), handles.mydata.mask(idx,iSubburst) = zeros(size(idx)); end % force these as marked good end % Update handles structure guidata(hObject, handles); % return the flags to the calling function mydata = handles.mydata; return % --- Outputs from this function are returned to the command line. function varargout = flagbadadv_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % this function gets called during initialization! return function editscutoff5_Callback(hObject, eventdata, handles) % hObject handle to editscutoff5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of editscutoff5 as text % str2double(get(hObject,'String')) returns contents of editscutoff5 as a double handles.mydata.scutoff(5) = str2num(get(hObject,'String')); handles.mydata = flagbads(hObject, handles); % the user may have zoomed, so save the limits buf = get(handles.axes5,'tag'); if findstr(buf, 'cor'), iAx = 1; elseif findstr(buf, 'std'), iAx = 2; end iPlot = 5; handles.cxLims{iPlot,iAx} = get(gca,'xlim'); handles.cyLims{iPlot,iAx} = get(gca,'ylim'); % Update handles structure guidata(hObject, handles); updateplots(hObject, handles, 'hold'); % --- Executes during object creation, after setting all properties. function editscutoff5_CreateFcn(hObject, eventdata, handles) % hObject handle to editscutoff5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function editscutoff4_Callback(hObject, eventdata, handles) % hObject handle to editscutoff4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of editscutoff4 as text % str2double(get(hObject,'String')) returns contents of editscutoff4 as a double handles.mydata.scutoff(4) = str2num(get(hObject,'String')); handles.mydata = flagbads(hObject, handles); % the user may have zoomed, so save the limits buf = get(handles.axes4,'tag'); if findstr(buf, 'cor'), iAx = 1; elseif findstr(buf, 'std'), iAx = 2; end iPlot = 4; handles.cxLims{iPlot,iAx} = get(gca,'xlim'); handles.cyLims{iPlot,iAx} = get(gca,'ylim'); % Update handles structure guidata(hObject, handles); updateplots(hObject, handles, 'hold'); % --- Executes during object creation, after setting all properties. function editscutoff4_CreateFcn(hObject, eventdata, handles) % hObject handle to editscutoff4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function editscutoff3_Callback(hObject, eventdata, handles) % hObject handle to editscutoff3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of editscutoff3 as text % str2double(get(hObject,'String')) returns contents of editscutoff3 as a double handles.mydata.scutoff(3) = str2num(get(hObject,'String')); handles.mydata = flagbads(hObject, handles); % the user may have zoomed, so save the limits buf = get(handles.axes3,'tag'); if findstr(buf, 'cor'), iAx = 1; elseif findstr(buf, 'std'), iAx = 2; end iPlot = 3; handles.cxLims{iPlot,iAx} = get(gca,'xlim'); handles.cyLims{iPlot,iAx} = get(gca,'ylim'); % Update handles structure guidata(hObject, handles); updateplots(hObject, handles, 'hold'); return % --- Executes during object creation, after setting all properties. function editscutoff3_CreateFcn(hObject, eventdata, handles) % hObject handle to editscutoff3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function editscutoff2_Callback(hObject, eventdata, handles) % hObject handle to editscutoff2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of editscutoff2 as text % str2double(get(hObject,'String')) returns contents of editscutoff2 as a double handles.mydata.scutoff(2) = str2num(get(hObject,'String')); handles.mydata = flagbads(hObject, handles); % the user may have zoomed, so save the limits buf = get(handles.axes2,'tag'); if findstr(buf, 'cor'), iAx = 1; elseif findstr(buf, 'std'), iAx = 2; end iPlot = 2; handles.cxLims{iPlot,iAx} = get(gca,'xlim'); handles.cyLims{iPlot,iAx} = get(gca,'ylim'); % Update handles structure guidata(hObject, handles); updateplots(hObject, handles, 'hold'); % --- Executes during object creation, after setting all properties. function editscutoff2_CreateFcn(hObject, eventdata, handles) % hObject handle to editscutoff2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function editscutoff1_Callback(hObject, eventdata, handles) % hObject handle to editscutoff1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of editscutoff1 as text % str2double(get(hObject,'String')) returns contents of editscutoff1 as a double handles.mydata.scutoff(1) = str2num(get(hObject,'String')); handles.mydata = flagbads(hObject, handles); % the user may have zoomed, so save the limits buf = get(handles.axes1,'tag'); if findstr(buf, 'cor'), iAx = 1; elseif findstr(buf, 'std'), iAx = 2; end iPlot = 1; handles.cxLims{iPlot,iAx} = get(gca,'xlim'); handles.cyLims{iPlot,iAx} = get(gca,'ylim'); % Update handles structure guidata(hObject, handles); updateplots(hObject, handles, 'hold'); % --- Executes during object creation, after setting all properties. function editscutoff1_CreateFcn(hObject, eventdata, handles) % hObject handle to editscutoff1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end %flagbadadv('axes1_ButtonDownFcn',gcbo,[],guidata(gcbo)) % --- Executes on mouse press over axes background. function axes1_ButtonDownFcn(hObject, eventdata, handles) % hObject handle to axes1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) disp('click') % --- Executes on mouse press over axes background. function stdvline_ButtonDownFcn(hObject, eventdata, handles) % hObject handle to axes1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % I set this in the line object to the subburst # and beam earlier data = get(hObject,'UserData'); iPlot = data(1); cb = get(gca,'CurrentPoint'); cb = round(cb(1,1)); % note that cp is the burst number, not an index into the array of burst numbers % now must find which index has that burst number icb = near(handles.mydata.burstNum, cb); % index that was toggled % the user wants to invert the current state by mouse click handles.mydata.mask(icb,iPlot) = ~handles.mydata.mask(icb,iPlot); % now we must save this as an override if handles.mydata.mask(icb,iPlot), % true means this is known bad handles.mydata.override_as_bad(icb, iPlot) = 1; handles.mydata.override_as_good(icb, iPlot) = 0; disp(sprintf('Selected Burst #%d in Subburst %d in beam %d added to Bad Override list',cb,iPlot,handles.mydata.currentBeam)) else handles.mydata.override_as_good(icb, iPlot) = 1; handles.mydata.override_as_bad(icb, iPlot) = 0; disp(sprintf('Selected Burst #%d in Subburst %d in beam %d added to Good Override list',cb,iPlot,handles.mydata.currentBeam)) end % update the mask handles.mydata = flagbads(hObject, handles); buf = get(gca,'tag'); if findstr(buf, 'cor'), iAx = 1; iPlot = str2num(buf(end)); elseif findstr(buf, 'std'), iAx = 2; iPlot = str2num(buf(end)); end handles.cxLims{iPlot,iAx} = get(gca,'xlim'); handles.cyLims{iPlot,iAx} = get(gca,'ylim'); % Update handles structure guidata(hObject, handles); updateplots(hObject, handles, 'hold'); function editccutoff1_Callback(hObject, eventdata, handles) % hObject handle to editccutoff1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of editccutoff1 as text % str2double(get(hObject,'String')) returns contents of editccutoff1 as a double handles.mydata.ccutoff(1) = str2num(get(hObject,'String')); handles.mydata = flagbads(hObject, handles); % the user may have zoomed, so save the limits buf = get(handles.axes1,'tag'); if findstr(buf, 'cor'), iAx = 1; elseif findstr(buf, 'std'), iAx = 2; end iPlot = 1; handles.cxLims{iPlot,iAx} = get(gca,'xlim'); handles.cyLims{iPlot,iAx} = get(gca,'ylim'); % Update handles structure guidata(hObject, handles); updateplots(hObject, handles, 'hold'); % --- Executes during object creation, after setting all properties. function editccutoff1_CreateFcn(hObject, eventdata, handles) % hObject handle to editccutoff1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function editccutoff2_Callback(hObject, eventdata, handles) % hObject handle to editccutoff2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of editccutoff2 as text % str2double(get(hObject,'String')) returns contents of editccutoff2 as a double handles.mydata.ccutoff(2) = str2num(get(hObject,'String')); handles.mydata = flagbads(hObject, handles); % the user may have zoomed, so save the limits buf = get(handles.axes2,'tag'); if findstr(buf, 'cor'), iAx = 1; elseif findstr(buf, 'std'), iAx = 2; end iPlot = 2; handles.cxLims{iPlot,iAx} = get(gca,'xlim'); handles.cyLims{iPlot,iAx} = get(gca,'ylim'); % Update handles structure guidata(hObject, handles); updateplots(hObject, handles, 'hold'); % --- Executes during object creation, after setting all properties. function editccutoff2_CreateFcn(hObject, eventdata, handles) % hObject handle to editccutoff2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function editccutoff3_Callback(hObject, eventdata, handles) % hObject handle to editccutoff3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of editccutoff3 as text % str2double(get(hObject,'String')) returns contents of editccutoff3 as a double handles.mydata.ccutoff(3) = str2num(get(hObject,'String')); handles.mydata = flagbads(hObject, handles); % the user may have zoomed, so save the limits buf = get(handles.axes3,'tag'); if findstr(buf, 'cor'), iAx = 1; elseif findstr(buf, 'std'), iAx = 2; end iPlot = 3; handles.cxLims{iPlot,iAx} = get(gca,'xlim'); handles.cyLims{iPlot,iAx} = get(gca,'ylim'); % Update handles structure guidata(hObject, handles); updateplots(hObject, handles, 'hold'); % --- Executes during object creation, after setting all properties. function editccutoff3_CreateFcn(hObject, eventdata, handles) % hObject handle to editccutoff3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function editccutoff4_Callback(hObject, eventdata, handles) % hObject handle to editccutoff4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of editccutoff4 as text % str2double(get(hObject,'String')) returns contents of editccutoff4 as a double handles.mydata.ccutoff(4) = str2num(get(hObject,'String')); handles.mydata = flagbads(hObject, handles); % the user may have zoomed, so save the limits buf = get(handles.axes4,'tag'); if findstr(buf, 'cor'), iAx = 1; elseif findstr(buf, 'std'), iAx = 2; end iPlot = 4; handles.cxLims{iPlot,iAx} = get(gca,'xlim'); handles.cyLims{iPlot,iAx} = get(gca,'ylim'); % Update handles structure guidata(hObject, handles); updateplots(hObject, handles, 'hold'); % --- Executes during object creation, after setting all properties. function editccutoff4_CreateFcn(hObject, eventdata, handles) % hObject handle to editccutoff4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function editccutoff5_Callback(hObject, eventdata, handles) % hObject handle to editccutoff5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of editccutoff5 as text % str2double(get(hObject,'String')) returns contents of editccutoff5 as a double handles.mydata.ccutoff(5) = str2num(get(hObject,'String')); handles.mydata = flagbads(hObject, handles); % the user may have zoomed, so save the limits buf = get(handles.axes5,'tag'); if findstr(buf, 'cor'), iAx = 1; elseif findstr(buf, 'std'), iAx = 2; end iPlot = 5; handles.cxLims{iPlot,iAx} = get(gca,'xlim'); handles.cyLims{iPlot,iAx} = get(gca,'ylim'); % Update handles structure guidata(hObject, handles); updateplots(hObject, handles, 'hold'); % --- Executes during object creation, after setting all properties. function editccutoff5_CreateFcn(hObject, eventdata, handles) % hObject handle to editccutoff5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function editTogBurst_Callback(hObject, eventdata, handles) % hObject handle to editTogBurst (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of editTogBurst as text % str2double(get(hObject,'String')) returns contents of editTogBurst as a double % the burst is asked for as #, # [cb, buffer] = strtok(get(hObject,'String'),','); [iPlot, buffer] = strtok(buffer,','); cb = round(str2num(char(cb))); % chosen burst iPlot = round(str2num(char(iPlot))); % chosen subburst plot if isempty(cb) | isempty(iPlot), set(hObject,'String','?,?') guidata(hObject, handles); disp('User entered burst or subburst missing') return end if iPlot < 1 | iPlot > 5, set(hObject,'String','?,?') guidata(hObject, handles); disp('User entered subburst out of bounds') return end % note that cp is the burst number, not an index into the array of burst numbers % now must find which index has that burst number icb = near(handles.mydata.burstNum, cb); % the user wants to invert the current state by entering the burst number handles.mydata.mask(icb,iPlot) = ~handles.mydata.mask(icb,iPlot); % now we must save this as an override if handles.mydata.mask(icb,iPlot), % true means this is known bad handles.mydata.override_as_bad(icb, iPlot) = 1; handles.mydata.override_as_good(icb, iPlot) = 0; disp(sprintf('Selected Burst #%d in Subburst %d in beam %d added to Bad Override list',cb,iPlot,handles.mydata.currentBeam)) else handles.mydata.override_as_good(icb, iPlot) = 1; handles.mydata.override_as_bad(icb, iPlot) = 0; disp(sprintf('Selected Burst #%d in Subburst %d in beam %d added to Good Override list',cb,iPlot,handles.mydata.currentBeam)) end % update the mask handles.mydata = flagbads(hObject, handles); buf = get(gca,'tag'); if findstr(buf, 'cor'), iAx = 1; iPlot = str2num(buf(end)); elseif findstr(buf, 'std'), iAx = 2; iPlot = str2num(buf(end)); end handles.cxLims{iPlot,iAx} = get(gca,'xlim'); handles.cyLims{iPlot,iAx} = get(gca,'ylim'); % Update handles structure guidata(hObject, handles); updateplots(hObject, handles, 'hold'); % --- Executes during object creation, after setting all properties. function editTogBurst_CreateFcn(hObject, eventdata, handles) % hObject handle to editTogBurst (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % ********************** this button currently removed from the figure % --- Executes on button press in reset_zoom. function reset_zoom_Callback(hObject, eventdata, handles) % hObject handle to reset_zoom (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) for iPlot = 1:handles.mydata.nSubbursts, for iAx = 1:2 eval(sprintf('theAx = handles.axes%d;',iPlot)) handles.cxLims{iPlot,iAx} = handles.oxLims{iPlot,iAx}; handles.cyLims{iPlot,iAx} = handles.oyLims{iPlot,iAx}; end end % Update handles structure guidata(hObject, handles); updateplots(hObject, handles, 'init'); % --- Executes on button press in cleargood. function cleargood_Callback(hObject, eventdata, handles) % hObject handle to cleargood (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.mydata.override_as_good = zeros(size(handles.mydata.override_as_good)); % update the mask handles.mydata = flagbads(hObject, handles); guidata(hObject, handles); updateplots(hObject, handles, 'hold'); % --- Executes on button press in clearbad. function clearbad_Callback(hObject, eventdata, handles) % hObject handle to clearbad (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.mydata.override_as_bad = zeros(size(handles.mydata.override_as_bad)); % update the mask handles.mydata = flagbads(hObject, handles); guidata(hObject, handles); updateplots(hObject, handles, 'hold');