Home > reduc > plotting > genfigPowerSpec.m

genfigPowerSpec

PURPOSE ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

function genfigPowerSpec(d, xc, txt, ax, prop, type, field, saveplot);

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 function genfigPowerSpec(d, xc, txt, ax, prop, type, field, saveplot);

 d       - data structure
 xc      - cell element of x and y data
           x{odd}  - x axis data
           x{even} - y axis data Nx1 or Nx6 or Nx24
 txt     - axis text
           txt{1} - title
           txt{2} - x axis
           txt{3} - y axis
           txt[4} - overall title
           txt{5} - legend
 ax         - manual axis settings.  [xmin xmax ymin ymax]
 prop    - initialize properties of plotting
           p.style = {'flag','feature'}
           p.swap  = swap to display plots in time.
           p.featmask= [bitmask for style='feature']
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function genfigPowerSpec(d, xc, txt, ax, prop, type, field, saveplot);
0002 
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 % function genfigPowerSpec(d, xc, txt, ax, prop, type, field, saveplot);
0005 %
0006 % d       - data structure
0007 % xc      - cell element of x and y data
0008 %           x{odd}  - x axis data
0009 %           x{even} - y axis data Nx1 or Nx6 or Nx24
0010 % txt     - axis text
0011 %           txt{1} - title
0012 %           txt{2} - x axis
0013 %           txt{3} - y axis
0014 %           txt[4} - overall title
0015 %           txt{5} - legend
0016 % ax         - manual axis settings.  [xmin xmax ymin ymax]
0017 % prop    - initialize properties of plotting
0018 %           p.style = {'flag','feature'}
0019 %           p.swap  = swap to display plots in time.
0020 %           p.featmask= [bitmask for style='feature']
0021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0022 if(nargin<8)
0023   saveplot = 1;
0024 end
0025 
0026 
0027 % check for axis setting
0028 if (~exist('ax'))
0029   ax=[];
0030 end
0031 
0032 if(saveplot)
0033   % get the directory to write to
0034   maindir=getMainDir(d, field);
0035 end
0036 
0037   
0038 % num is the number of pages to be displayed.
0039 % matrix is the size of each of the pages to be displayed.
0040 num = 1;
0041 %plotsPerPage = 6;
0042 %matrix = [3 2];
0043 
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 
0050 data = d.antenna0.receiver.data;
0051 if(size(data,2)==8)
0052   plotIndices = [1 6 7 8];
0053   matrix = [2 2];
0054   plotsPerPage = 4;
0055 elseif(size(data,2)==6)
0056   plotIndices = [1:6];
0057   matrix = [3 2];
0058   plotsPerPage = 6;
0059 end
0060 
0061 
0062 timeVal = d.antenna0.receiver.utc*24*60*60;
0063 timeVal = timeVal - timeVal(1);
0064 
0065 pageNum=1;
0066 fmode=logical(0);
0067 
0068 setwinsize(gcf, 1000, 750); 
0069 clear leg;
0070 for plotNum=1:plotsPerPage
0071   subplot(matrix(1),matrix(2),plotNum)
0072   % plot data
0073   optionIndex = 1;
0074   % before data
0075   [boo, coo, h(pageNum, plotNum,optionIndex) NFFT] = plot_powerspec(d, ...
0076                                     data(:,plotNum), 1, [], [], plotoptions{1});      
0077   
0078   xlabel(txt{2});
0079   ylabel(txt{3});
0080   if(plotNum==1)
0081     thisTitle = sprintf('%s %u', txt{1}{1}, plotNum);
0082   elseif(plotNum==plotsPerPage)
0083     thisTitle = sprintf('%s %u', txt{1}{length(txt{1})}, plotNum);    
0084   else
0085     if(mod(plotNum,2)==0)
0086       thisTitle = sprintf('%s %u', txt{1}{2}, plotNum);          
0087     else
0088       thisTitle = sprintf('%s %u', txt{1}{3}, plotNum);                
0089     end
0090   end
0091   title(thisTitle);
0092   
0093 end
0094 
0095 gtitle('Power Spectrum Plots');
0096 
0097 if(saveplot)
0098   dbclear if error
0099   set(gcf,'paperposition',[0 0 6.0 6.0])
0100   eval(sprintf('print -dpng -r200 %s/%s/fig%d.png;', ...
0101       maindir,type,pageNum));
0102   dbstop if error
0103 else
0104   pause(1);
0105 end
0106 
0107 
0108 
0109 
0110 
0111 %%%%%%%%%%%%%%%%%%%%%%%%%
0112 function p=setProperties(p)
0113 
0114 if (isempty(p))
0115   p.style='flag';
0116   p.swap=0;
0117   p.featflag=0;
0118   return
0119 end
0120   
0121 if (isfield(p,'style'))
0122 
0123 else
0124   p.style='flag';  
0125   p.featflag=0;
0126 end
0127 
0128 if (~isfield(p,'swap'))
0129   p.swap=0;
0130 end
0131 
0132 return;
0133 
0134 
0135 %%%%%%%%%%%%%%%%%%%%%%%%%
0136 function manaxis(ax,y)
0137 
0138 if (~isempty(ax))
0139   ax4orig = ax(4);
0140   ymax=max(y)*1.1;
0141   if (max(y)>ax(4))
0142     % if max y is larger than mean
0143     ax(4)=ymax;
0144   elseif (8*nanmean(y)<ax(4) & ax(3)>=0)
0145     % if global mean (ax(4)) is much greater than the
0146     % local y data, rescale
0147     % but if ax(3)<0, that means we're looking at phase
0148     % so don't do anything.
0149     ax(4)=ymax;
0150   elseif (isnan(ax(4)) | isnan(ax(3)))
0151     if (isnan(ax(4)))
0152       ax(4)=1;
0153     end
0154     if (isnan(ax(3)))
0155       ax(3)=0;
0156     end
0157   end
0158   % this is in place until mike comes up with a better way to do
0159   % this - all the previous stuff at times resets the value of
0160   % ax(4) so that it is below that of ax(3) - i don't feel like
0161   % trying to figure out mike's logic, so here's a fix;
0162   if(ax(3) >= ax(4))
0163     if(ax4orig>ax(3))
0164           ax(4) = ax4orig;
0165     else
0166       ax(4) = ax(3)+1;
0167     end
0168   end
0169   axis(ax);
0170 end
0171 
0172 return;
0173 
0174 
0175 %%%%%%%%%%%%%%%%%%%%%%%%%
0176 function [clr,leg]=getcolor(type)
0177 
0178 clr=[ 0.2     0         0;
0179     1         0.66      0;
0180     1         0         1;
0181     0.5       0.2       1;
0182     0.2       0.2       0.8;
0183     1         0.5       0.12;
0184     0.1       0.5       0.9;
0185     0.75      1         1;
0186     0.2       0.5       0.66;
0187     0.9       0.8       0.7;
0188     0.6       0         0.1;
0189     0         0         1
0190     0.5869    0.1909    0.3461
0191     0.0576    0.8439    0.1660
0192     0.3676    0.1739    0.1556
0193     0.6315    0.1708    0.1911
0194     0.7176    0.9943    0.4225
0195     0.6927    0.4398    0.8560
0196     0.0841    0.3400    0.4902
0197     0.4544    0.3142    0.8159
0198     0.4418    0.3651    0.4608
0199     0.3533    0.3932    0.4574
0200     0.1536    0.5915    0.4507
0201     0.6756    0.1197    0.4122
0202     0.6992    0.0381    0.9016
0203     0.7275    0.4586    0.0056
0204     0.4784    0.8699    0.2974
0205     0.5548    0.9342    0.0492
0206     0.1210    0.2644    0.6932
0207     0.4508    0.1603    0.6501
0208     0.7159    0.8729    0.9830
0209     0         0         0];
0210 
0211 
0212 switch type
0213   case 'feature'
0214     leg = {'source', 'calibrator', 'abscal', 'blank', 'skydip', ...
0215     'noise_event', 'noise'};
0216     
0217   case 'bitmask'
0218     leg={'frame','receiver', 'tracking', 'tracker', 'elevation', ...
0219     'continuous', 'fifo', 'clock', '1pps', 'cryo/servo', 'backend time', 'shortfall', 'sun', 'moon'};
0220 end
0221 
0222 return;
0223 
0224

Generated on Sun 14-Jun-2015 17:12:45 by m2html © 2005