0001 function plotdnoflag(d, flags, xc, txt, ax, prop, w, chunk, h, ind1)
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
0028
0029
0030 if(exist('w')~=1)
0031 w = 2;
0032 end
0033
0034
0035 newflag = [];
0036
0037
0038 if (~exist('ax'))
0039 ax=[];
0040 end
0041
0042
0043 if (exist('prop'))
0044 p=setProperties(prop);
0045 else
0046 p=setProperties([]);
0047 end
0048
0049
0050
0051 if(~p.swap)
0052 num = size(xc,2);
0053 plotsPerPage = size(xc{2,1},2);
0054 if(plotsPerPage==6)
0055 matrix = [2 3];
0056 elseif(plotsPerPage==1)
0057 matrix = [1 1];
0058 elseif(plotsPerPage==24)
0059 matrix = [2 3];
0060 plotsPerPage = 6;
0061 elseif(plotsPerPage==2)
0062
0063
0064 matrix = [2 1];
0065 plotsPerPage = 2;
0066 elseif(plotsPerPage==8)
0067 matrix = [4 2];
0068 elseif(plotsPerPage==10)
0069 matrix = [5 2];
0070 else
0071 error('Unrecognized number of plots');
0072 end
0073 else
0074 num = size(xc{2,1},2);
0075 plotsPerPage = size(xc,2);
0076 matrix = ceil(sqrt(size(xc,2)));
0077 matrix = [matrix; matrix];
0078 end
0079
0080
0081 pageNum=1;
0082 fmode=logical(0);
0083 while(1)
0084 if (w~=0 & w~=1)
0085 figure(1)
0086 if(plotsPerPage==2)
0087 setwinsize(gcf, 1000, 400);
0088 else
0089 setwinsize(gcf, 1000, 750);
0090 end
0091
0092 for plotNum=1:plotsPerPage
0093 subplot(matrix(1),matrix(2),plotNum)
0094
0095 [m,n]=swapIndex(p.swap,pageNum,plotNum);
0096 switch p.style
0097 case 'flag'
0098 h(pageNum,plotNum)=plotflag(xc,flags,ax,m,n,txt,w,num,matrix,p.swap);
0099
0100 case 'feature'
0101 [h(pageNum,plotNum),leg]=plotfeat(xc,flags,ax,m,n,txt,w,num, ...
0102 matrix,p.swap, p.type);
0103
0104 end
0105 end
0106 if (strcmp(p.style,'feature') & ~isempty(leg))
0107 legend(leg,'Location','Best');
0108
0109 leg=[];
0110 end
0111 if(length(txt) == 5)
0112 eval(sprintf('legend(''%s'', ''%s'', ''Location'',''Best'');', ...
0113 txt{5}{1}, txt{5}{2}));
0114 end
0115 if (length(txt)>3)
0116 gtitle(txt{4});
0117 end
0118
0119 w=waitforbuttonpress;
0120 if (~w)
0121
0122 plotdnoflag(d,flags,xc,txt,ax,p,w,[],h,pageNum);
0123 else
0124
0125
0126 [pageNum,format,p]=evalkey(d,pageNum,plotsPerPage,'matrix',p,num);
0127
0128 if(pageNum<0)
0129 return
0130 end
0131 if (strcmp(format,'swap'))
0132 numbuf=num;
0133 num=matrix;
0134 matrix=numbuf;
0135 pageNum=1;
0136 p.swap=~p.swap;
0137 clear h;
0138 close(1)
0139 end
0140 end
0141
0142 w=2;
0143 else
0144 if (~w)
0145
0146
0147 child=get(gca,'Children');
0148 ind2 = find(h(ind1,:)==child(1));
0149 if (isempty(ind2))
0150 if (isempty(chunk))
0151 disp(' Unknown plot. Default to channel 1');
0152 ind2=1;
0153 else
0154 ind2=chunk;
0155 end
0156 end
0157 else
0158
0159
0160 [ind2,format,p] = evalkey(d,chunk,plotsPerPage,'zoom',p,num);
0161
0162
0163 if(ind2==-1)
0164 break;
0165 elseif (ind2==-2)
0166 fmode = logical(1);
0167 ind2 = chunk;
0168 end
0169 end
0170
0171 figure(2)
0172 [m,n] = swapIndex(p.swap,ind1,ind2);
0173 switch p.style
0174 case 'flag'
0175 plotflag(xc,flags,ax,m,n,txt,w,num,matrix,p.swap);
0176
0177 case 'feature'
0178 plotfeat(xc,flags,ax,m,n,txt,w,num,matrix,p.swap, p.type);
0179
0180 end
0181
0182
0183 grid
0184
0185 if (fmode)
0186 display('No Flagging allowed yet');
0187 end
0188 hold off
0189 w = waitforbuttonpress;
0190 plotdnoflag(d,flags,xc,txt,ax,p,w,ind2,h,ind1);
0191 break;
0192 end
0193 end
0194
0195
0196
0197
0198
0199 function p=setProperties(p)
0200
0201 if (isempty(p))
0202 p.style='flag';
0203 p.swap=0;
0204 p.featflag=0;
0205 return
0206 end
0207
0208 if (isfield(p,'style'))
0209
0210 else
0211 p.style='flag';
0212 p.featflag=0;
0213 end
0214
0215 if (~isfield(p,'swap'))
0216 p.swap=0;
0217 end
0218
0219 return;
0220
0221
0222
0223
0224
0225 function [m,n]=swapIndex(swap,i,j)
0226
0227 if (swap)
0228 m=j; n=i;
0229 else
0230 m=i; n=j;
0231 end
0232
0233
0234
0235 function h=plotflag(x,allflags,ax,pageNum,plotNum,txt,w,num,matrix,swap, multLinesPerPlot)
0236
0237
0238 if(size(x,1)==4)
0239 if(size(x{1,pageNum},1) == size(x{4,pageNum},1))
0240 plot(x{1,pageNum},x{4,pageNum}(:,plotNum),'c.','MarkerSize',5);
0241 hold on;
0242 else
0243 plot(x{3,pageNum},x{4,pageNum}(:,plotNum),'c.','MarkerSize',5);
0244 hold on;
0245 end
0246 end
0247
0248
0249 h=plot(x{1,pageNum},x{2,pageNum}(:,plotNum),'b.','MarkerSize',5);
0250 manaxis(ax,x{2,pageNum}(:,plotNum))
0251 hold on;
0252
0253 plotdescription(txt,plotNum,pageNum,num,matrix,swap);
0254
0255
0256
0257 manaxis(ax,x{2,pageNum}(:,plotNum));
0258
0259
0260 numpts = size(x{1,pageNum},1);
0261
0262
0263 if (~isempty(allflags{2,pageNum}))
0264 f = find(allflags{2,pageNum}(:,plotNum));
0265 if (~isempty(f))
0266 h=plot(x{1,pageNum}(f),x{2,pageNum}(f,plotNum),'g.','MarkerSize',5);
0267 end
0268 end
0269
0270
0271 if (~isempty(allflags{1,pageNum}))
0272
0273 f = find(allflags{1,pageNum}(:,plotNum));
0274 if (~isempty(f))
0275 h=plot(x{1,pageNum}(f),x{2,pageNum}(f,plotNum),'r.','MarkerSize',5);
0276 end
0277 end
0278
0279 hold off
0280
0281 return;
0282
0283
0284
0285 function [h, leg] = plotfeat(x,allflags,ax,pageNum,plotNum,txt,w,num,matrix,swap, type)
0286
0287
0288
0289
0290
0291 [clr, legall] = getcolor(type, x);
0292
0293
0294 switch type
0295 case 'allflags'
0296
0297 h = plot(x{1,pageNum}, x{2,pageNum}(:,plotNum), 'k.'); hold on
0298 index = 2;
0299 leg{1} = 'data';
0300
0301 case 'feature'
0302 index = 1;
0303 leg = [];
0304 h = [];
0305 end
0306
0307 for m=1:length(legall)
0308 switch type
0309 case 'allflags'
0310 txt1 = sprintf('a = x{1,pageNum}(x{3,pageNum}.%s(:,plotNum));', legall{m});
0311 txt2 = sprintf('b = x{2,pageNum}(x{3,pageNum}.%s(:,plotNum), plotNum);', legall{m});
0312
0313 case 'feature'
0314 txt1 = sprintf('a = x{1,pageNum}(x{3,pageNum}.%s);', legall{m});
0315 txt2 = sprintf('b = x{2,pageNum}(x{3,pageNum}.%s, plotNum);', legall{m});
0316 end
0317
0318 eval(txt1); eval(txt2);
0319
0320
0321 if(sum(a)>0)
0322 txtPlot = sprintf('h = plot(a, b, ''.'', ''markerfacecolor'', clr(m,:), ''markeredgecolor'', clr(m,:), ''MarkerSize'',5);');
0323 eval(txtPlot);
0324 hold on;
0325 leg{index} = legall{m};
0326 index = index+1;
0327 end
0328 end
0329
0330 if(isempty(h))
0331
0332 a = x{1,pageNum};
0333 b = zeros(size(a));
0334 h = plot(a,b,'w');
0335 text(a(1), b(1), 'DATA HAS NO INTENT', 'FontSize', 18);
0336 text(a(1), -0.25, 'FOR THIS TIME PERIOD', 'FontSize', 18);
0337 end
0338
0339 manaxis(ax,x{2,pageNum}(:,plotNum))
0340 plotdescription(txt,plotNum,pageNum,num,matrix,swap);
0341
0342 hold off
0343
0344 return;
0345
0346
0347
0348 function plotdescription(txt,n,m,num,matrix,swap)
0349
0350 if(length(txt{1})>1)
0351 title(txt{1}{n})
0352 xlabel(char(txt{2}));
0353 ylabel(char(txt{3}));
0354 return;
0355 end
0356
0357 if (matrix(1)==2 & matrix(2)==3)
0358
0359 title(sprintf('Channel: %u', n));
0360 elseif (matrix(1)==4 & matrix(2)==6)
0361
0362 title(sprintf('Switch State Number: %u Ant: %u',n));
0363 elseif (num==6)
0364
0365 title(sprintf('Channel Number: %u', m));
0366 elseif(num==24)
0367
0368 title(sprintf('Switch State Number: %u', m));
0369 elseif(matrix(1) == 1 & matrix(2)==2)
0370
0371 title(sprintf('Total Intensity Channel: %u', n));
0372 end
0373
0374 if(~isempty(txt))
0375 xlabel(char(txt{2}));
0376 ylabel(char(txt{3}));
0377 end
0378
0379 return;
0380
0381
0382
0383 function manaxis(ax,y)
0384
0385 if (~isempty(ax))
0386 ax4orig = ax(4);
0387 ymax=max(y)*1.1;
0388 if (max(y)>ax(4))
0389
0390 ax(4)=ymax;
0391 elseif (8*nanmean(y)<ax(4) & ax(3)>=0)
0392
0393
0394
0395
0396 ax(4)=ymax;
0397 elseif (isnan(ax(4)) | isnan(ax(3)))
0398 if (isnan(ax(4)))
0399 ax(4)=1;
0400 end
0401 if (isnan(ax(3)))
0402 ax(3)=0;
0403 end
0404 end
0405
0406
0407
0408
0409 if(ax(3) >= ax(4))
0410 if(ax4orig>ax(3))
0411 ax(4) = ax4orig;
0412 else
0413 ax(4) = ax(3)+1;
0414 end
0415 end
0416 axis(ax);
0417 end
0418
0419 return;
0420
0421
0422 function [inc,format,p]=evalkey(d,inc,num,type,p,numPages)
0423
0424 format='default';
0425 ch=get(gcf,'CurrentCharacter');
0426 switch ch
0427 case 'p'
0428 inc=inc-1;
0429
0430 case 'n'
0431 inc=inc+1;
0432
0433 case 'f'
0434 if (strcmp(type,'zoom'))
0435
0436 inc=-2;
0437 elseif (strcmp(type,'matrix'))
0438 inc=inc;
0439 end
0440
0441 case 'q'
0442 if (strcmp(type,'zoom'))
0443 close(2)
0444 else
0445 close(1)
0446 end
0447 inc=-1;
0448
0449 case 's'
0450 if (strcmp(type,'matrix'))
0451 format='swap';
0452 end
0453
0454 case '1'
0455 if (strcmp(type,'matrix'))
0456 p.style='flag';
0457 disp('Highlighting auto and user flags')
0458 end
0459
0460 case 'h'
0461 printhelp;
0462 inc=inc;
0463
0464 case 'l'
0465 disp('Appending figure to prints.ps')
0466
0467 dbclear if error
0468 print -dps -append prints.ps;
0469 dbstop if error
0470
0471 otherwise
0472 inc=inc;
0473 end
0474
0475 if (strcmp(type,'matrix'))
0476 if(inc>numPages)
0477 inc = 1;
0478 elseif(inc==0)
0479 inc=numPages;
0480 end
0481 else
0482 if (inc>num)
0483 inc=1;
0484 elseif (inc==0)
0485 inc=num;
0486 end
0487 end
0488
0489
0490
0491 return;
0492
0493
0494 function printhelp()
0495
0496 disp(' ')
0497 disp('******************************')
0498 disp(' Plotting Help ')
0499 disp('******************************')
0500 disp(' ');
0501 disp('IN PLOT WINDOW (MATRIX and ZOOM)')
0502 disp(' ')
0503 disp('h - command menu')
0504 disp('p - Previous plots')
0505 disp('n - Next plots')
0506 disp('q - exit plot')
0507 disp('l - append figure to prints.ps')
0508 disp(' ')
0509
0510
0511
0512
0513
0514
0515 disp(' ')
0516 disp(' ')
0517 disp('ZOOM ONLY')
0518 disp('click on plot to zoom and flag')
0519 disp(' ')
0520 disp('FLAGGING FROM ZOOM')
0521 disp(' ')
0522 disp('These commands are only available in flag mode')
0523 disp('Hit ''f''')
0524 disp(' ')
0525 disp('**Flagging**')
0526 disp(' ')
0527 disp('GLOBAL TYPE COMMANDS')
0528 disp('s - flag single channel');
0529 disp('a - all channels for this timestamp');
0530 disp(' ')
0531 disp('LOCAL TYPE COMMANDS')
0532 disp('c - chunk of data. click 2 corners of a rectangle')
0533 disp('t - time chunk. like ''c'' but only uses x-axis as constraint')
0534 disp('- - flags everything below y-value')
0535 disp('= - flags everything above y-value')
0536 disp('m - flags specific bands')
0537 disp('n - flags specific baselines/antennas')
0538 disp(' ')
0539 disp('EDIT TYPE COMMANDS')
0540 disp('f - flag mode')
0541 disp('u - unflag mode')
0542 disp('e - erases all new flags')
0543 disp(' ')
0544 disp('**Zoom**')
0545 disp('z - box zoom')
0546 disp('x - zoom x axis')
0547 disp('y - zoom y axis')
0548 disp('o - original plot (unzoom)')
0549 disp(' ')
0550 disp('**Misc Display**')
0551 disp('g - toggle grid on/off')
0552 disp('q - exit flag mode')
0553 disp('h - help')
0554 disp(' ')
0555 disp(' ')
0556 disp('In matrix mode, [p,n] will cycle through antennas/baselines.')
0557 disp('In zoom mode, these will cycle through bands')
0558 disp('Once in zoom mode, you must exit it to regain control')
0559 disp('of matrix mode. ''q'' in zoom mode returns to the matrix plot')
0560 disp('''q'' in matrix exits plot')
0561 disp(' ')
0562 disp('*******************WARNING*********************')
0563 disp('*******************WARNING*********************')
0564 disp('*******************WARNING*********************')
0565 disp('*******************WARNING*********************')
0566 disp('*******************WARNING*********************')
0567 disp('Do not exit plot by manually killing the window.')
0568 disp('This will cause the program to crash!')
0569 disp('***********************************************')
0570 disp(' ')
0571
0572
0573 return;
0574
0575
0576
0577 function [clr,leg]=getcolor(type, x)
0578
0579 clr=[ 0.2 0 0;
0580 1 0.66 0;
0581 1 0 1;
0582 0.5 0.2 1;
0583 0.2 0.2 0.8;
0584 1 0.5 0.12;
0585 0.1 0.5 0.9;
0586 0.75 1 1;
0587 0.2 0.5 0.66;
0588 0.9 0.8 0.7;
0589 0.6 0 0.1;
0590 0 0 1
0591 0.5869 0.1909 0.3461
0592 0.0576 0.8439 0.1660
0593 0.3676 0.1739 0.1556
0594 0.6315 0.1708 0.1911
0595 0.7176 0.9943 0.4225
0596 0.6927 0.4398 0.8560
0597 0.0841 0.3400 0.4902
0598 0.4544 0.3142 0.8159
0599 0.4418 0.3651 0.4608
0600 0.3533 0.3932 0.4574
0601 0.1536 0.5915 0.4507
0602 0.6756 0.1197 0.4122
0603 0.6992 0.0381 0.9016
0604 0.7275 0.4586 0.0056
0605 0.4784 0.8699 0.2974
0606 0.5548 0.9342 0.0492
0607 0.1210 0.2644 0.6932
0608 0.4508 0.1603 0.6501
0609 0.7159 0.8729 0.9830
0610 0 0 0];
0611
0612
0613 switch type
0614 case 'feature'
0615 leg = fieldnames(x{3});
0616
0617 case 'allflags'
0618 leg = getFlagNames;
0619
0620 case 'bitmask'
0621 leg={'frame','receiver', 'tracking', 'tracker', 'elevation', ...
0622 'continuous', 'fifo', 'clock', '1pps', 'cryo/servo', 'backend time', 'shortfall', 'sun', 'moon'};
0623
0624 end
0625
0626 return;
0627
0628