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