0001 function genfigAlpha(d, flags, xc, txt, ax, type, prop, field, saveplot)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 if(nargin<9)
0028 saveplot = 1;
0029 end
0030
0031
0032 if (~exist('ax'))
0033 ax=[];
0034 end
0035
0036 if(saveplot)
0037
0038 maindir=getMainDir(d, field);
0039 end
0040
0041
0042
0043 if(size(xc{2,1},2)~=2)
0044 error('Should not be using plot_alpha');
0045 end
0046
0047
0048
0049
0050
0051 numPlots = length(xc)/2;
0052 matrix = [4 4];
0053 linesPerPlot = 2;
0054 p.swap = 0;
0055 num = 2*ceil(numPlots/16);
0056
0057
0058
0059 nPlots = numPlots;
0060 m=1;
0061 while(nPlots >0)
0062 if(nPlots>=16)
0063 plotsPerPage(m) = 16;
0064 nPlots = nPlots - 16;
0065 else
0066 plotsPerPage(m) = nPlots;
0067 nPlots = 0;
0068 end
0069 m = m+1;
0070 end
0071
0072 plotsPerPage = [plotsPerPage plotsPerPage];
0073 final_flags = zeros(1,numPlots);
0074
0075
0076 pageNum=1;
0077 for pageNum=1:num
0078 setwinsize(gcf, 1000, 750);
0079 clf;
0080 for plotNum=1:plotsPerPage(pageNum)
0081 subplot(matrix(1),matrix(2),plotNum)
0082
0083 [m,n]=swapIndex(p.swap,pageNum,plotNum);
0084 h(pageNum,plotNum,1:linesPerPlot)=plotflag(xc,flags,ax,m,n,txt,num,matrix,plotsPerPage);
0085
0086 if (length(txt)>3)
0087 if(pageNum > (num/2))
0088 bigTitle = sprintf('Channel 6 %s', txt{4}{1});
0089 else
0090 bigTitle = sprintf('Channel 1 %s', txt{4}{1});
0091 end
0092 gtitle(bigTitle);
0093 end
0094 end
0095
0096 if(saveplot)
0097 dbclear if error
0098 set(gcf,'paperposition',[0 0 6.0 6.0])
0099 eval(sprintf('print -dpng -r200 %s/%s/fig%u.png;', ...
0100 maindir,type,pageNum));
0101 dbstop if error
0102 else
0103 pause(1);
0104 end
0105
0106 pageNum=pageNum+1;
0107 end
0108
0109 return;
0110
0111
0112
0113
0114
0115
0116 function [m,n]=swapIndex(swap,i,j)
0117
0118 if (swap)
0119 m=j; n=i;
0120 else
0121 m=i; n=j;
0122 end
0123
0124 return;
0125
0126
0127 function h=plotflag(x,allflags,ax,pageNum,plotNum,txt,num,matrix,plotsPerPage)
0128
0129
0130 if(pageNum==1)
0131 dataIndex = plotNum;
0132 else
0133 dataIndex = sum(plotsPerPage(1:pageNum-1)) + plotNum;
0134 end
0135
0136
0137 h=plot(x{1,dataIndex},x{2,dataIndex}(:,1:2),'MarkerSize',10);
0138 if(isempty(ax))
0139 ax(1) = min(x{1,dataIndex});
0140 ax(2) = max(x{1,dataIndex});
0141 ax(3) = min(min(x{2,dataIndex}(:,1:2)));
0142 ax(3) = max(max(x{2,dataIndex}(:,1:2)));
0143 end
0144 manaxis(ax,x{2,dataIndex}(:,1:2));
0145
0146
0147 if(pageNum <= (num/2))
0148 plotdescription(txt,dataIndex);
0149 hold on
0150 else
0151 plotdescription(txt,dataIndex-(size(x,2)/2));
0152 hold on
0153 end
0154
0155 if(isempty(ax))
0156 ax(1) = min(x{1,dataIndex});
0157 ax(2) = max(x{1,dataIndex});
0158 ax(3) = min(min(x{2,dataIndex}(:,1:2)));
0159 ax(3) = max(max(x{2,dataIndex}(:,1:2)));
0160 end
0161
0162
0163 manaxis(ax,x{2,dataIndex}(:,1:2));
0164
0165
0166 if (~isempty(allflags{2, dataIndex}))
0167 for mm=1:2
0168 f = find(allflags{2, dataIndex}(:,mm));
0169 if (~isempty(f))
0170 h=plot(x{1, dataIndex}(f),x{2, dataIndex}(f,1:2),'g.','MarkerSize',10);
0171 end
0172 end
0173 end
0174
0175
0176 if (~isempty(allflags{1, dataIndex}))
0177 for mm=1:2
0178 f = find(allflags{1, dataIndex}(:,mm));
0179 if (~isempty(f))
0180 h=plot(x{1, dataIndex}(f),x{2, dataIndex}(f,1:2),'r.','MarkerSize',10);
0181 end
0182 end
0183 end
0184
0185
0186 hold off
0187
0188 return;
0189
0190
0191
0192 function plotdescription(txt,dataIndex);
0193
0194
0195 titleTxt = sprintf('%s # %i', txt{1}{1}, dataIndex);
0196 title(titleTxt);
0197
0198
0199 if(~isempty(txt))
0200 xlabel(char(txt{2}));
0201 ylabel(char(txt{3}));
0202 end
0203
0204 return;
0205
0206
0207
0208 function manaxis(ax,y)
0209
0210 if (~isempty(ax))
0211 ax4orig = ax(4);
0212 ymax=max(y)*1.1;
0213 if (max(y)>ax(4))
0214
0215 ax(4)=ymax;
0216 elseif (8*nanmean(y)<ax(4) & ax(3)>=0)
0217
0218
0219
0220
0221 ax(4)=ymax;
0222 elseif (isnan(ax(4)) | isnan(ax(3)))
0223 if (isnan(ax(4)))
0224 ax(4)=1;
0225 end
0226 if (isnan(ax(3)))
0227 ax(3)=0;
0228 end
0229 end
0230
0231
0232
0233
0234 if(ax(3) >= ax(4))
0235 if(ax4orig>ax(3))
0236 ax(4) = ax4orig;
0237 else
0238 ax(4) = ax(3)+1;
0239 end
0240 end
0241 axis(ax);
0242 end
0243
0244 return;
0245
0246
0247 function [inc,format,p]=evalkey(d,inc,num,type,p,numPages)
0248
0249 format='default';
0250 ch=get(gcf,'CurrentCharacter');
0251 switch ch
0252 case 'p'
0253 inc=inc-1;
0254
0255 case 'n'
0256 inc=inc+1;
0257
0258 case 'f'
0259 if (strcmp(type,'zoom'))
0260
0261 inc=-2;
0262 elseif (strcmp(type,'matrix'))
0263 inc=inc;
0264 end
0265
0266 case 'q'
0267 if (strcmp(type,'zoom'))
0268 close(2)
0269 else
0270 close(1)
0271 end
0272 inc=-1;
0273
0274 case 's'
0275 if (strcmp(type,'matrix'))
0276 format='swap';
0277 end
0278
0279 case '1'
0280 if (strcmp(type,'matrix'))
0281 p.style='flag';
0282 disp('Highlighting auto and user flags')
0283 end
0284
0285 case 'h'
0286 printhelp;
0287 inc=inc;
0288
0289 case 'l'
0290 disp('Appending figure to prints.ps')
0291
0292 dbclear if error
0293 print -dps -append prints.ps;
0294 dbstop if error
0295
0296 otherwise
0297 inc=inc;
0298 end
0299
0300 if (strcmp(type,'matrix'))
0301 if(inc>numPages)
0302 inc = 1;
0303 elseif(inc==0)
0304 inc=numPages;
0305 end
0306 else
0307 if (inc>num)
0308 inc=1;
0309 elseif (inc==0)
0310 inc=num;
0311 end
0312 end
0313
0314
0315
0316 return;
0317
0318
0319 function printhelp()
0320
0321 disp(' ')
0322 disp('******************************')
0323 disp(' Plotting Help ')
0324 disp('******************************')
0325 disp(' ');
0326 disp('ALPHA FLAGGING PLOTTING INFO');
0327 disp(' ')
0328 disp('To Flag a noise source event');
0329 disp('Simply CLICK on it');
0330 disp('h - command menu')
0331 disp('p - Previous plots')
0332 disp('n - Next plots')
0333 disp('q - exit plot')
0334 disp('l - append figure to prints.ps')
0335 disp(' ')
0336 disp('*******************WARNING*********************')
0337 disp('*******************WARNING*********************')
0338 disp('*******************WARNING*********************')
0339 disp('*******************WARNING*********************')
0340 disp('*******************WARNING*********************')
0341 disp('Do not exit plot by manually killing the window.')
0342 disp('This will cause the program to crash!')
0343 disp('***********************************************')
0344 disp(' ')
0345
0346
0347 return;
0348
0349
0350
0351 function [clr,leg]=getcolor(type)
0352
0353 clr=[ 0.2 0 0;
0354 1 0.66 0;
0355 1 0 1;
0356 0.5 0.2 1;
0357 0.2 0.2 0.8;
0358 1 0.5 0.12;
0359 0.1 0.5 0.9;
0360 0.75 1 1;
0361 0.2 0.5 0.66;
0362 0.9 0.8 0.7;
0363 0.6 0 0.1;
0364 0 0 1
0365 0.5869 0.1909 0.3461
0366 0.0576 0.8439 0.1660
0367 0.3676 0.1739 0.1556
0368 0.6315 0.1708 0.1911
0369 0.7176 0.9943 0.4225
0370 0.6927 0.4398 0.8560
0371 0.0841 0.3400 0.4902
0372 0.4544 0.3142 0.8159
0373 0.4418 0.3651 0.4608
0374 0.3533 0.3932 0.4574
0375 0.1536 0.5915 0.4507
0376 0.6756 0.1197 0.4122
0377 0.6992 0.0381 0.9016
0378 0.7275 0.4586 0.0056
0379 0.4784 0.8699 0.2974
0380 0.5548 0.9342 0.0492
0381 0.1210 0.2644 0.6932
0382 0.4508 0.1603 0.6501
0383 0.7159 0.8729 0.9830
0384 0 0 0];
0385
0386
0387 switch type
0388 case 'feature'
0389 leg = {'source', 'calibrator', 'abscal', 'blank', 'skydip', ...
0390 'noise_event', 'noise'};
0391
0392 case 'bitmask'
0393 leg={'frame','receiver', 'tracking', 'tracker', 'elevation', ...
0394 'continuous', 'fifo', 'clock', '1pps', 'cryo/servo', 'backend time', 'shortfall', 'sun', 'moon'};
0395 end
0396
0397 return;
0398
0399