Home > reduc > plotting > genfigRms.m

genfigRms

PURPOSE ^

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

SYNOPSIS ^

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

DESCRIPTION ^

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

 d       - data structure
 flag    - flag 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']
 type    - 'rms'
 field   - field to analyze

 Extensively modified by ogk on 16 June 2011.

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function genfigRms(d, flags, xc, txt, ax, prop, type, field, saveplot);
0002 
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 % function genfigRms(d, flags, xc, txt, ax, prop, type, field, saveplot);
0005 %
0006 % d       - data structure
0007 % flag    - flag structure
0008 % xc      - cell element of x and y data
0009 %           x{odd}  - x axis data
0010 %           x{even} - y axis data Nx1 or Nx6 or Nx24
0011 % txt     - axis text
0012 %           txt{1} - title
0013 %           txt{2} - x axis
0014 %           txt{3} - y axis
0015 %           txt[4} - overall title
0016 %           txt{5} - legend
0017 % ax         - manual axis settings.  [xmin xmax ymin ymax]
0018 % prop    - initialize properties of plotting
0019 %           p.style = {'flag','feature'}
0020 %           p.swap  = swap to display plots in time.
0021 %           p.featmask= [bitmask for style='feature']
0022 % type    - 'rms'
0023 % field   - field to analyze
0024 %
0025 % Extensively modified by ogk on 16 June 2011.
0026 %
0027 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0028 
0029 if(nargin<9)
0030   saveplot = 1;
0031 end
0032 
0033 % check for axis setting
0034 if (~exist('ax'))
0035   ax=[];
0036 end
0037 
0038 if(saveplot)
0039   % get the directory to write to
0040   maindir=getMainDir(d, field);
0041 end
0042 
0043 % num is the number of pages to be displayed.
0044 % matrix is the size of each of the pages to be displayed.
0045 num = 1;
0046 %plotsPerPage = 6;
0047 %matrix = [3 2];
0048 plotsPerPage = 1;
0049 matrix = [1 1];
0050 
0051 plotoptions = {'b', 'g', 'r', 'c', 'm', 'y', 'k', ...
0052     'b.', 'g.', 'r.', 'c.', 'm.', 'y.', 'k.', ...    
0053     'bo', 'go', 'ro', 'co', 'mo', 'yo', 'ko', ...    
0054     'bx', 'gx', 'rx', 'cx', 'mx', 'yx', 'kx'};
0055 
0056 % first we cut only the on-source data
0057 %d = cutObs(d, 'source', 'only');
0058 
0059 % MAS (May 28, 2013):
0060 % No, actually let's just subtract off the noise diode events.
0061 d = noiseRemove(d);
0062 
0063 
0064 if(isempty(d.array.frame.features))
0065   display('No data to display');
0066   return;
0067 end
0068 
0069 
0070 
0071 switch (size(d.antenna0.receiver.data,2))
0072   case 6
0073     % The data to be acted on is:
0074     I1 = d.antenna0.receiver.data(:,1);
0075     I2 = d.antenna0.receiver.data(:,6);
0076     Q = d.antenna0.receiver.data(:,2);
0077     U = d.antenna0.receiver.data(:,3);
0078   case 8
0079     % The data to be acted on is:
0080     I1 = d.antenna0.receiver.data(:,1);
0081     I2 = d.antenna0.receiver.data(:,8);
0082     Q = d.antenna0.receiver.data(:,6);
0083     U = d.antenna0.receiver.data(:,7);
0084     
0085   case 10
0086     % The data to be acted on is:
0087     I1 = d.antenna0.receiver.data(:,1);
0088     I2 = d.antenna0.receiver.data(:,9);
0089     Q = d.antenna0.receiver.data(:,7);
0090     U = d.antenna0.receiver.data(:,8);
0091 end
0092 
0093 % next we flag the data
0094 % diffData( sum(d.flags.fast,2)>0 ) = [];
0095 % Don't flag the data: this will mess up the filtering by changing the time
0096 % base.
0097 
0098 % What we can do is limit the data to a number of samples which are a
0099 % factor of 2:
0100 Nsel = 2^(floor(log2(size(I1,1))));
0101 
0102 % Create a matrix of data to be passed to the notchFilter routine:
0103 Y = [I1(1:Nsel) I2(1:Nsel) Q(1:Nsel) U(1:Nsel)];
0104 
0105 % Apply the standard notches, and some high-pass filters
0106 % MAS (May 28, 2013):  Standard notches don't make any sense.  Just do
0107 % high-pass filters.
0108 Yn005 = notchFilter(Y,[0 0.005]);
0109 Yn050 = notchFilter(Y,[0 0.05]);
0110 Yn500 = notchFilter(Y,[0 0.5]);
0111 
0112 % The data to integrate down:
0113 Yintegrate = [Y Yn005 Yn050 Yn500];
0114 if Nsel >= 4000
0115     intLength = 1:10:2000; % number of samples to integrate down to
0116 else
0117     intLength = 1:10:floor(Nsel/2); % number of samples to integrate down to
0118 end
0119 Ystd = integrateDown(Yintegrate,intLength);
0120 
0121 % corresponding times.
0122 timeVal = intLength*0.01;  % in seconds
0123 
0124 % actual plotting
0125 setwinsize(gcf, 750, 500); 
0126 
0127 tI = intLength*0.01;
0128 %Ystd should always be positive
0129 ylims = [0.95*nanmin(nanmin(Ystd)) 1.05*nanmax(nanmax(Ystd))];
0130 xlims = [0 max(tI)];
0131 if(any(isnan(ylims)))
0132   ylims = [0 0.2];
0133 end
0134 
0135 subplot(2,2,1)
0136 loglog(tI,Ystd(:,1),'k-',tI,Ystd(:,5),'r-',tI,1./sqrt(intLength)*Ystd(1,9),'k--',tI,Ystd(:,9),'b-',tI,Ystd(:,13),'g-')
0137 loglog(tI,Ystd(:,1),'k-',tI,1./sqrt(intLength)*Ystd(1,5),'k--',tI,Ystd(:,9),'b-',tI,Ystd(:,13),'g-')
0138 ylabel('I1 RMS')
0139 ylim(ylims)
0140 xlim(xlims)
0141 legend('Unfiltered','5mHz HPF','Ideal','50mHz HPF','500mHz HPF','Location','SouthWest')
0142 
0143 subplot(2,2,2)
0144 loglog(tI,Ystd(:,2),'k-',tI,Ystd(:,6),'r-',tI,1./sqrt(intLength)*Ystd(1,10),'k--',tI,Ystd(:,10),'b-',tI,Ystd(:,14),'g-')
0145 ylabel('I2 RMS')
0146 ylim(ylims)
0147 xlim(xlims)
0148 
0149 subplot(2,2,3)
0150 loglog(tI,Ystd(:,3),'k-',tI,Ystd(:,7),'r-',tI,1./sqrt(intLength)*Ystd(1,11),'k--',tI,Ystd(:,11),'b-',tI,Ystd(:,15),'g-')
0151 xlabel('Integration time [s]')
0152 ylim(ylims)
0153 ylabel('Q RMS')
0154 xlim(xlims)
0155 
0156 subplot(2,2,4)
0157 loglog(tI,Ystd(:,4),'k-',tI,Ystd(:,8),'r-',tI,1./sqrt(intLength)*Ystd(1,12),'k--',tI,Ystd(:,12),'b-',tI,Ystd(:,16),'g-')
0158 xlabel('Integration time [s]')
0159 xlim(xlims)
0160 ylim(ylims)
0161 ylabel('U RMS')
0162 
0163 
0164 gtitle('RMS Plot');
0165 
0166 
0167 pageNum=1;
0168 if(saveplot)
0169   dbclear if error
0170   set(gcf,'paperposition',[0 0 6.0 6.0])
0171   eval(sprintf('print -dpng -r200 %s/%s/fig%d.png;', ...
0172       maindir,type,pageNum));
0173   dbstop if error
0174 else
0175   pause(1);
0176 end
0177 
0178 
0179   
0180 return;

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