0001 function Iflagged = flagAlphaGraphically_multiple(t,data,varData,Ipreflagged,dataIdent,Ndays)
0002
0003
0004
0005
0006
0007
0008 disp('-------------------------------------------------------------------')
0009 disp('Welcome to the flagAlphaGraphically_multiple 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 if ~iscell(data) || ~iscell(varData) || ~iscell(dataIdent)
0019 disp('Error! Must pass cells of data, varData, and dataIdent to flagAlphaGraphically_multiple.')
0020 return
0021 end
0022
0023 Nplots = length(data);
0024
0025 figure
0026 if t(end)-t(1) < 1.2
0027 xlims = [t(1) t(end)];
0028 else
0029 xlims = [t(1) t(1)+Ndays];
0030 end
0031 Iplt = t>=xlims(1) & t<=xlims(2);
0032 H = [];
0033 for k=1:Nplots
0034 H(k) = subplot(Nplots,1,k);
0035 errorbar(t(~Ipreflagged & Iplt),data{k}(~Ipreflagged & Iplt),sqrt(varData{k}(~Ipreflagged & Iplt))/2,'k.')
0036 if length(t)>1
0037 xlim(xlims)
0038 end
0039 if k==1
0040 title('Use left-clicks to define rectangle around bad data points')
0041 end
0042 ylabel(dataIdent{k})
0043 end
0044 xlabel('Right click or press escape when done flagging')
0045
0046
0047 but = 1;
0048 first = 1;
0049 Iflagged = zeros(size(t));
0050 while but == 1
0051
0052 [xi,yi,but] = ginput(1);
0053 axi = gca();
0054
0055 if but == 1
0056 if first == 1
0057 x1 = xi;
0058 y1 = yi;
0059 first = 0;
0060 ax1 = axi;
0061 else
0062 x2 = xi;
0063 y2 = yi;
0064 ax2 = axi;
0065
0066 if ax2 == ax1
0067
0068 Ik = H==ax2;
0069
0070 x = sort([x1;x2]);
0071 y = sort([y1;y2]);
0072 Iflag = t >= x(1) & t <= x(2) & data{Ik} >= y(1) & data{Ik} <= y(2);
0073 Iflagged = Iflagged | Iflag;
0074 Iplt = t>=xlims(1) & t<=xlims(2);
0075 for k=1:Nplots
0076 errorbar(H(k),t(~(Iflagged|Ipreflagged)&Iplt),data{k}(~(Iflagged|Ipreflagged)&Iplt),...
0077 sqrt(varData{k}(~(Iflagged|Ipreflagged)&Iplt))/2,'k.')
0078 yl = ylim(H(k));
0079 hold(H(k));
0080 errorbar(H(k),t((Iflagged|Ipreflagged)&Iplt),data{k}((Iflagged|Ipreflagged)&Iplt),...
0081 sqrt(varData{k}((Iflagged|Ipreflagged)&Iplt))/2,'r.')
0082 hold(H(k));
0083 xlim(H(k),xlims)
0084 ylim(H(k),yl)
0085 ylabel(dataIdent{k})
0086 end
0087 end
0088
0089 x1 = 0; x2 = 0; y1 = 0; y2 = 0;
0090 ax1 = 0; ax2 = 0;
0091 first = 1;
0092 end
0093 else
0094 if xlims(2) < t(end)
0095 if t(end)-(xlims(1)+Ndays) > 0.2
0096 xlims(1) = xlims(2);
0097 xlims(2) = xlims(1)+Ndays;
0098 else
0099 xlims(1) = xlims(2);
0100 xlims(2) = t(end);
0101 end
0102 but = 1;
0103 Iplt = t>=xlims(1) & t<=xlims(2);
0104 for k=1:Nplots
0105 errorbar(H(k),t(~(Iflagged|Ipreflagged) & Iplt),data{k}(~(Iflagged|Ipreflagged) & Iplt),...
0106 sqrt(varData{k}(~(Iflagged|Ipreflagged) & Iplt))/2,'k.')
0107 yl = ylim(H(k));
0108 hold(H(k));
0109 errorbar(H(k),t((Iflagged|Ipreflagged)&Iplt),data{k}((Iflagged|Ipreflagged)&Iplt),...
0110 sqrt(varData{k}((Iflagged|Ipreflagged)&Iplt))/2,'r.')
0111 hold(H(k));
0112 xlim(H(k),xlims)
0113 ylim(H(k),yl)
0114 ylabel(dataIdent{k})
0115 end
0116
0117 end
0118 end
0119
0120 end
0121 close(gcf)
0122 figure
0123 for k=1:Nplots
0124 subplot(Nplots,1,k)
0125 hold on
0126 errorbar(t(~(Iflagged|Ipreflagged)),data{k}(~(Iflagged|Ipreflagged)),sqrt(varData{k}(~(Iflagged|Ipreflagged)))/2,'k.')
0127 errorbar(t(Iflagged|Ipreflagged),data{k}(Iflagged|Ipreflagged),sqrt(varData{k}(Iflagged|Ipreflagged))/2,'r.')
0128 ylabel(dataIdent{k})
0129 end
0130 xlabel('Time')
0131 legend('Unflagged','Flagged')
0132
0133 end