0001 function Iflagged = flagAlphaGraphically(t,data,varData,Ipreflagged,dataIdent,Ndays)
0002
0003
0004
0005
0006
0007
0008 disp('-------------------------------------------------------------------')
0009 disp('Welcome to the flagAlphaGraphically routine')
0010 disp('Operation:')
0011 disp('A window will open: use the left mouse button to select the two')
0012 disp('corners of the rectangle around the points to be flagged. The flagged')
0013 disp('data points will disappear. When done flagging points on the current')
0014 disp('plot, right-click or press escape. The plot will update with more')
0015 disp('points, or ask for input when done.')
0016 disp('-------------------------------------------------------------------')
0017
0018 figure
0019 if t(end)-t(1) < 1.2
0020 xlims = [t(1) t(end)];
0021 else
0022 xlims = [t(1) t(1)+Ndays];
0023 end
0024 Iplt = t>=xlims(1) & t<=xlims(2);
0025 errorbar(t(~Ipreflagged & Iplt),data(~Ipreflagged & Iplt),sqrt(varData(~Ipreflagged & Iplt))/2,'k.')
0026 if length(t)>1
0027 xlim(xlims)
0028 end
0029 ylabel(dataIdent)
0030 title('Use left-clicks to define rectangle around bad data points')
0031 xlabel('Right click or press escape when done flagging')
0032
0033
0034 but = 1;
0035 first = 1;
0036 Iflagged = zeros(size(t));
0037 while but == 1
0038
0039 [xi,yi,but] = ginput(1);
0040 if but == 1
0041 if first == 1
0042 x1 = xi;
0043 y1 = yi;
0044 first = 0;
0045 else
0046 x2 = xi;
0047 y2 = yi;
0048
0049
0050 x = sort([x1;x2]);
0051 y = sort([y1;y2]);
0052 Iflag = t >= x(1) & t <= x(2) & data >= y(1) & data <= y(2);
0053 Iflagged = Iflagged | Iflag;
0054 Iplt = t>=xlims(1) & t<=xlims(2);
0055 errorbar(t(~(Iflagged|Ipreflagged)&Iplt),data(~(Iflagged|Ipreflagged)&Iplt),...
0056 sqrt(varData(~(Iflagged|Ipreflagged)&Iplt))/2,'k.')
0057 xlim(xlims)
0058 ylabel(dataIdent)
0059 title('Use left-clicks to define rectangle around bad data points')
0060 xlabel('Right click or press escape when done flagging')
0061
0062 x1 = 0; x2 = 0; y1 = 0; y2 = 0;
0063 first = 1;
0064 end
0065 else
0066 if xlims(2) < t(end)
0067 if t(end)-(xlims(1)+Ndays) > 0.2
0068 xlims(1) = xlims(2);
0069 xlims(2) = xlims(1)+Ndays;
0070 else
0071 xlims(1) = xlims(2);
0072 xlims(2) = t(end);
0073 end
0074 but = 1;
0075 Iplt = t>=xlims(1) & t<=xlims(2);
0076 errorbar(t(~(Iflagged|Ipreflagged) & Iplt),data(~(Iflagged|Ipreflagged) & Iplt),...
0077 sqrt(varData(~(Iflagged|Ipreflagged) & Iplt))/2,'k.')
0078 ylabel(dataIdent)
0079 xlim(xlims)
0080 title('Use left-clicks to define rectangle around bad data points')
0081 xlabel('Right click or press escape when done flagging')
0082 end
0083 end
0084
0085 end
0086 close(gcf)
0087 figure
0088 hold on
0089 errorbar(t(~(Iflagged|Ipreflagged)),data(~(Iflagged|Ipreflagged)),sqrt(varData(~(Iflagged|Ipreflagged)))/2,'k.')
0090 errorbar(t(Iflagged|Ipreflagged),data(Iflagged|Ipreflagged),sqrt(varData(Iflagged|Ipreflagged))/2,'r.')
0091 xlabel('Time')
0092 ylabel(dataIdent)
0093 legend('Unflagged','Flagged')
0094
0095 end