0001 function plotLoad(d, flags, xc, txt, ax, prop, d0, isMains)
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
0031 if(nargin<8)
0032 isMains = 0;
0033 end
0034
0035 if(exist('w')~=1)
0036 w = 2;
0037 end
0038
0039
0040 if (~exist('ax'))
0041 ax=[];
0042 end
0043
0044
0045 if (exist('prop'))
0046 p=setProperties(prop);
0047 else
0048 p=setProperties([]);
0049 end
0050
0051
0052
0053 num = 1;
0054
0055
0056 switch(size(d0.antenna0.receiver.data,2))
0057 case 6
0058 vectorsToPlot = 1:6;
0059 plotlabel = {'T1', 'Q1', 'U1', 'Q2', 'U2', 'T2'};
0060
0061 case 8
0062 vectorsToPlot = [1 2 5 6 7 8];
0063 plotlabel = {'T1', 'Q1', 'U1', 'Q2', 'U2', 'T2'};
0064
0065 case 10
0066 vectorsToPlot = [1 2 7 8 9 10];
0067 plotlabel = {'Tsky1', 'Tload1', 'Q3', 'U3', 'Tsky2', 'Tload2'};
0068 end
0069
0070 if(isMains)
0071 setwinsize(gcf, 1200, 900);
0072 plotsPerPage = 24;
0073 matrix = [6 4];
0074 if(isfield(d0.antenna0.receiver, 'switchDataT'))
0075 data0 = d0.antenna0.receiver.switchDataT;
0076 data1 = d.antenna0.receiver.switchDataT;
0077 else
0078 data0 = d0.antenna0.receiver.switchData;
0079 data1 = d.antenna0.receiver.switchData;
0080 end
0081 else
0082 setwinsize(gcf, 1000, 750);
0083 plotsPerPage = 6;
0084 matrix = [3 2];
0085 if(isfield(d0.antenna0.receiver, 'dataT'))
0086 data0 = d0.antenna0.receiver.dataT;
0087 data1 = d.antenna0.receiver.dataT;
0088 else
0089 data0 = d0.antenna0.receiver.data(:,vectorsToPlot);
0090 data1 = d.antenna0.receiver.data(:,vectorsToPlot);
0091 end
0092
0093 end
0094
0095
0096 plotoptions = {'b', 'g', 'r', 'c', 'm', 'y', 'k', ...
0097 'b.', 'g.', 'r.', 'c.', 'm.', 'y.', 'k.', ...
0098 'bo', 'go', 'ro', 'co', 'mo', 'yo', 'ko', ...
0099 'bx', 'gx', 'rx', 'cx', 'mx', 'yx', 'kx'};
0100
0101
0102
0103
0104 timeVal = d.antenna0.receiver.utc*24*60*60;
0105 timeVal = timeVal - timeVal(1);
0106
0107 pageNum=1;
0108 fmode=logical(0);
0109
0110 while(1)
0111 if (w~=0 & w~=1)
0112 clear leg;
0113 for plotNum=1:plotsPerPage
0114 subplot(matrix(1),matrix(2),plotNum)
0115
0116 optionIndex = 1;
0117
0118 [boo, coo, h(pageNum, plotNum,optionIndex) NFFT] = plot_powerspec(d, ...
0119 data0(:,plotNum), 1, [], [], plotoptions{1},~isMains);
0120
0121 hold on
0122
0123 [boo1, coo1, h(pageNum, plotNum,optionIndex) NFFT] = plot_powerspec(d, ...
0124 data1(:,plotNum), 1, [],[], plotoptions{2},~isMains);
0125
0126
0127
0128 if(~isMains)
0129
0130
0131
0132
0133
0134 leg{1} = 'Before';
0135 leg{2} = 'After';
0136
0137
0138 thisY1 = 2*abs(coo1(1:NFFT/2+1,:));
0139 thisY = 2*abs(coo(1:NFFT/2+1,:));
0140 ff = find(boo>1.15 & boo<1.25);
0141 minY = nanmedian([thisY(ff); thisY1(ff)]);
0142 maxY = nanmax([thisY(ff); thisY1(ff)]);
0143
0144 axis([1.15 1.25 0.9*(minY) 1.1*maxY]);
0145 thisTitle = plotlabel{plotNum};
0146 else
0147 leg{1} = 'Before';
0148 leg{2} = 'After';
0149 thisTitle = sprintf('%s %u', txt{1}{1}, plotNum);
0150
0151 end
0152 legend(leg,'Location','Best');
0153
0154
0155 xlabel(txt{2});
0156 ylabel(txt{3});
0157 title(thisTitle);
0158 end
0159
0160 gtitle(txt{4});
0161 w=waitforbuttonpress;
0162 if (~w)
0163
0164
0165 else
0166
0167
0168 [pageNum,format,p]=evalkey(d,pageNum,plotsPerPage,'matrix',p,num);
0169
0170 if(pageNum<0)
0171 return
0172 end
0173 if (strcmp(format,'swap'))
0174 numbuf=num;
0175 num=matrix;
0176 matrix=numbuf;
0177 pageNum=1;
0178 p.swap=~p.swap;
0179 clear h;
0180 close(1)
0181 end
0182 end
0183
0184 w=2;
0185 else
0186 if (~w)
0187
0188
0189 child=get(gca,'Children');
0190 ind2 = find(h(ind1,:)==child(1));
0191 if (isempty(ind2))
0192 if (isempty(chunk))
0193 disp(' Unknown plot. Default to channel 1');
0194 ind2=1;
0195 else
0196 ind2=chunk;
0197 end
0198 end
0199 else
0200
0201
0202 [ind2,format,p] = evalkey(d,chunk,plotsPerPage,'zoom',p,num);
0203
0204
0205 if(ind2==-1)
0206 break;
0207 elseif (ind2==-2)
0208 fmode = logical(1);
0209 ind2 = chunk;
0210 end
0211 end
0212
0213 end
0214 end
0215
0216
0217
0218
0219
0220 function p=setProperties(p)
0221
0222 if (isempty(p))
0223 p.style='flag';
0224 p.swap=0;
0225 p.featflag=0;
0226 return
0227 end
0228
0229 if (isfield(p,'style'))
0230
0231 else
0232 p.style='flag';
0233 p.featflag=0;
0234 end
0235
0236 if (~isfield(p,'swap'))
0237 p.swap=0;
0238 end
0239
0240 return;
0241
0242
0243
0244
0245
0246 function [m,n]=swapIndex(swap,i,j)
0247
0248 if (swap)
0249 m=j; n=i;
0250 else
0251 m=i; n=j;
0252 end
0253
0254
0255
0256 function h=plotflag(x,allflags,ax,pageNum,plotNum,txt,w,num,matrix,swap, multLinesPerPlot)
0257
0258 [flag,autoflag,scriptflag]=cloneflag(allflags);
0259
0260
0261 if(size(x,1)==4)
0262 plot(x{1,pageNum},x{4,pageNum}(:,plotNum),'c.','MarkerSize',10);
0263 hold on;
0264 end
0265
0266
0267
0268 h=plot(x{1,pageNum},x{2,pageNum}(:,plotNum),'b.','MarkerSize',10);
0269 manaxis(ax,x{2,pageNum}(:,plotNum))
0270 hold on;
0271
0272 plotdescription(txt,plotNum,pageNum,num,matrix,swap);
0273
0274
0275
0276 manaxis(ax,x{2,pageNum}(:,plotNum));
0277
0278
0279 numpts = size(x{1,pageNum},1);
0280
0281
0282 if (~isempty(autoflag))
0283 f = find(autoflag{1,pageNum}(:,plotNum));
0284 if (~isempty(f))
0285 h=plot(x{1,pageNum}(f),x{2,pageNum}(f,plotNum),'m.','MarkerSize',10);
0286 end
0287 end
0288
0289
0290 if (~isempty(scriptflag))
0291 f = find(scriptflag{1,pageNum}(:,plotNum));
0292 if (~isempty(f))
0293 h=plot(x{1,pageNum}(f),x{2,pageNum}(f,plotNum),'g.','MarkerSize',10);
0294 end
0295 end
0296
0297
0298 if (~isempty(flag))
0299
0300 f = find(flag{1,pageNum}(:,plotNum));
0301 if (~isempty(f))
0302 h=plot(x{1,pageNum}(f),x{2,pageNum}(f,plotNum),'r.','MarkerSize',10);
0303 end
0304 end
0305
0306 hold off
0307
0308 return;
0309
0310
0311
0312 function [h, leg] = plotfeat(x,allflags,ax,pageNum,plotNum,txt,w,num,matrix,swap)
0313
0314
0315
0316
0317
0318 [flag,autoflag,scriptflag]=cloneflag(allflags);
0319
0320
0321 [clr, legall] = getcolor('feature');
0322
0323
0324 index = 1;
0325 leg = [];
0326 for m=1:length(legall)
0327 txt1 = sprintf('a = x{1,pageNum}(x{3,pageNum}.%s);', legall{m});
0328 txt2 = sprintf('b = x{2,pageNum}(x{3,pageNum}.%s, plotNum);', legall{m});
0329 eval(txt1); eval(txt2);
0330
0331
0332 if(sum(a)>0)
0333 txtPlot = sprintf('h = plot(a, b, ''.'', ''markerfacecolor'', clr(m,:), ''markeredgecolor'', clr(m,:), ''MarkerSize'',10);');
0334 eval(txtPlot);
0335 hold on;
0336 leg{index} = legall{m};
0337 index = index+1;
0338 end
0339 end
0340
0341
0342
0343 if (~isempty(autoflag))
0344 f = find(autoflag{1,pageNum}(:,plotNum));
0345 if (~isempty(f))
0346 h=plot(x{1,pageNum}(f),x{2,pageNum}(f,plotNum),'m.','MarkerSize',10);
0347 leg{index} = 'auto flag';
0348 index = index+1;
0349 end
0350 end
0351
0352
0353 if (~isempty(scriptflag))
0354 f = find(scriptflag{1,pageNum}(:,plotNum));
0355 if (~isempty(f))
0356 h=plot(x{1,pageNum}(f),x{2,pageNum}(f,plotNum),'g.','MarkerSize',10);
0357 leg{index} = 'script flag';
0358 index = index+1;
0359 end
0360 end
0361
0362
0363 if (~isempty(flag))
0364
0365 f = find(flag{1,pageNum}(:,plotNum));
0366 if (~isempty(f))
0367 h=plot(x{1,pageNum}(f),x{2,pageNum}(f,plotNum),'r.','MarkerSize',10);
0368 leg{index} = 'user flag';
0369 index = index+1;
0370 end
0371 end
0372
0373
0374
0375 manaxis(ax,x{2,pageNum}(:,plotNum))
0376 plotdescription(txt,plotNum,pageNum,num,matrix,swap);
0377
0378 hold off
0379
0380 return;
0381
0382
0383
0384 function plotdescription(txt,n,m,num,matrix,swap)
0385
0386 if (matrix(1)==2 & matrix(2)==3)
0387
0388 title(sprintf('Channel: %u', n));
0389 elseif (matrix(1)==4 & matrix(2)==6)
0390
0391 title(sprintf('Switch State Number: %u Ant: %u',n));
0392 elseif (num==6)
0393
0394 title(sprintf('Channel Number: %u', m));
0395 elseif(num==24)
0396
0397 title(sprintf('Switch State Number: %u', m));
0398 elseif(matrix(1) == 1 & matrix(2)==2)
0399
0400 title(sprintf('Opacity for Channel: %u', m));
0401 end
0402
0403 if(~isempty(txt))
0404 xlabel(char(txt{2}));
0405 ylabel(char(txt{3}));
0406 end
0407
0408 return;
0409
0410
0411
0412 function manaxis(ax,y)
0413
0414 if (~isempty(ax))
0415 ax4orig = ax(4);
0416 ymax=max(y)*1.1;
0417 if (max(y)>ax(4))
0418
0419 ax(4)=ymax;
0420 elseif (8*nanmean(y)<ax(4) & ax(3)>=0)
0421
0422
0423
0424
0425 ax(4)=ymax;
0426 elseif (isnan(ax(4)) | isnan(ax(3)))
0427 if (isnan(ax(4)))
0428 ax(4)=1;
0429 end
0430 if (isnan(ax(3)))
0431 ax(3)=0;
0432 end
0433 end
0434
0435
0436
0437
0438 if(ax(3) >= ax(4))
0439 if(ax4orig>ax(3))
0440 ax(4) = ax4orig;
0441 else
0442 ax(4) = ax(3)+1;
0443 end
0444 end
0445 axis(ax);
0446 end
0447
0448 return;
0449
0450
0451 function [inc,format,p]=evalkey(d,inc,num,type,p,numPages)
0452
0453 format='default';
0454 ch=get(gcf,'CurrentCharacter');
0455 switch ch
0456 case 'p'
0457 inc=inc-1;
0458
0459 case 'n'
0460 inc=inc+1;
0461
0462 case 'q'
0463 if (strcmp(type,'zoom'))
0464 close(2)
0465 else
0466 close(1)
0467 end
0468 inc=-1;
0469
0470 otherwise
0471 inc=inc;
0472 end
0473
0474 if (strcmp(type,'matrix'))
0475 if(inc>numPages)
0476 inc = 1;
0477 elseif(inc==0)
0478 inc=numPages;
0479 end
0480 else
0481 if (inc>num)
0482 inc=1;
0483 elseif (inc==0)
0484 inc=num;
0485 end
0486 end
0487
0488
0489
0490 return;
0491
0492
0493 function printhelp()
0494
0495 disp(' ')
0496 disp('******************************')
0497 disp(' Plotting Help ')
0498 disp('******************************')
0499 disp(' ');
0500 disp('IN PLOT WINDOW (MATRIX and ZOOM)')
0501 disp(' ')
0502 disp('h - command menu')
0503 disp('p - Previous plots')
0504 disp('n - Next plots')
0505 disp('q - exit plot')
0506 disp(' ')
0507 disp(' ')
0508 disp('*******************WARNING*********************')
0509 disp('*******************WARNING*********************')
0510 disp('*******************WARNING*********************')
0511 disp('*******************WARNING*********************')
0512 disp('*******************WARNING*********************')
0513 disp('Do not exit plot by manually killing the window.')
0514 disp('This will cause the program to crash!')
0515 disp('***********************************************')
0516 disp(' ')
0517
0518
0519 return;
0520
0521
0522
0523 function [clr,leg]=getcolor(type)
0524
0525 clr=[ 0.2 0 0;
0526 1 0.66 0;
0527 1 0 1;
0528 0.5 0.2 1;
0529 0.2 0.2 0.8;
0530 1 0.5 0.12;
0531 0.1 0.5 0.9;
0532 0.75 1 1;
0533 0.2 0.5 0.66;
0534 0.9 0.8 0.7;
0535 0.6 0 0.1;
0536 0 0 1
0537 0.5869 0.1909 0.3461
0538 0.0576 0.8439 0.1660
0539 0.3676 0.1739 0.1556
0540 0.6315 0.1708 0.1911
0541 0.7176 0.9943 0.4225
0542 0.6927 0.4398 0.8560
0543 0.0841 0.3400 0.4902
0544 0.4544 0.3142 0.8159
0545 0.4418 0.3651 0.4608
0546 0.3533 0.3932 0.4574
0547 0.1536 0.5915 0.4507
0548 0.6756 0.1197 0.4122
0549 0.6992 0.0381 0.9016
0550 0.7275 0.4586 0.0056
0551 0.4784 0.8699 0.2974
0552 0.5548 0.9342 0.0492
0553 0.1210 0.2644 0.6932
0554 0.4508 0.1603 0.6501
0555 0.7159 0.8729 0.9830
0556 0 0 0];
0557
0558
0559 switch type
0560 case 'feature'
0561 leg = {'source', 'calibrator', 'abscal', 'blank', 'skydip', ...
0562 'noise_event', 'noise'};
0563
0564 case 'bitmask'
0565 leg={'frame','receiver', 'tracking', 'tracker', 'elevation', ...
0566 'continuous', 'fifo', 'clock', '1pps', 'cryo/servo', 'backend time', 'shortfall', 'sun', 'moon'};
0567 end
0568
0569 return;
0570
0571