Home > reduc > plotting > genfigLoad.m

genfigLoad

PURPOSE ^

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

SYNOPSIS ^

function genfigLoad(d, xc, txt, ax, prop, d0, type, field, isMains, saveplot)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 function function genfigLoad(d, xc, txt, ax, prop, d0, type, field,
 isMains, 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']
 d0      - data without correction
 isMains - 1 for mains plotting, 0 for load 

   03/05/12 (MAS): Updated to plot semilogy when plotting load correction.
    Also, modified the automatic y-scaling for these plots.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function genfigLoad(d, xc, txt, ax, prop, d0, type, field, isMains, saveplot)
0002 
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 % function function genfigLoad(d, xc, txt, ax, prop, d0, type, field,
0005 % isMains, saveplot);
0006 %
0007 % d       - data 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 % d0      - data without correction
0023 % isMains - 1 for mains plotting, 0 for load
0024 %
0025 %   03/05/12 (MAS): Updated to plot semilogy when plotting load correction.
0026 %    Also, modified the automatic y-scaling for these plots.
0027 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0028 
0029 if(nargin<10)
0030     saveplot = 1;
0031 end
0032 
0033 
0034 % check for axis setting
0035 if (~exist('ax','var'))
0036     ax=[];
0037 end
0038 
0039 if(saveplot)
0040   % get the directory to write to
0041   maindir=getMainDir(d, field);
0042 end
0043 
0044 
0045 % make it robust to switching data around for the cold load
0046 switch(size(d0.antenna0.receiver.data,2))
0047     case 6
0048         vectorsToPlot = 1:6;
0049         plotlabel = {'T1', 'Q1', 'U1', 'Q2', 'U2', 'T2'};
0050         
0051     case 8
0052         vectorsToPlot = [1 2 3 4 5 8];
0053         plotlabel = {'T1', 'Q1', 'U1', 'Q2', 'U2', 'T2'};
0054         
0055     case 10
0056         vectorsToPlot = [1 2 7 8 9 10];
0057         plotlabel = {'Tsky1', 'Tload1', 'Q3', 'U3', 'Tsky2', 'Tload2'};
0058 end
0059 
0060 % num is the number of pages to be displayed.
0061 % matrix is the size of each of the pages to be displayed.
0062 num = 1;
0063 if(isMains)
0064     setwinsize(gcf, 1200, 900);
0065     plotsPerPage = 24;
0066     matrix = [6 4];
0067     if(isfield(d0.antenna0.receiver, 'switchDataT'))
0068         data0 = d0.antenna0.receiver.switchDataT;
0069         data1 = d.antenna0.receiver.switchDataT;
0070     else
0071         data0 = d0.antenna0.receiver.switchData;
0072         data1 = d.antenna0.receiver.switchData;
0073     end
0074 else
0075     setwinsize(gcf, 1000, 750);
0076     plotsPerPage = 6;
0077     matrix = [3 2];
0078     if(isfield(d0.antenna0.receiver, 'dataT'))
0079         data0 = d0.antenna0.receiver.dataT;
0080         data1 = d.antenna0.receiver.dataT;
0081     else
0082         data0 = d0.antenna0.receiver.data(:,vectorsToPlot);
0083         data1 = d.antenna0.receiver.data(:,vectorsToPlot);
0084     end
0085 end
0086 
0087 plotoptions = {'b', 'g', 'r', 'c', 'm', 'y', 'k', ...
0088     'b.', 'g.', 'r.', 'c.', 'm.', 'y.', 'k.', ...
0089     'bo', 'go', 'ro', 'co', 'mo', 'yo', 'ko', ...
0090     'bx', 'gx', 'rx', 'cx', 'mx', 'yx', 'kx'};
0091 
0092 timeVal = d.antenna0.receiver.utc*24*60*60;
0093 timeVal = timeVal - timeVal(1);
0094 
0095 pageNum=1;
0096 fmode=logical(0);
0097 
0098 clear leg;
0099 
0100 for plotNum=1:plotsPerPage
0101     subplot(matrix(1),matrix(2),plotNum)
0102     % plot data
0103     optionIndex = 1;
0104     % before data
0105     [boo, coo, h(pageNum, plotNum,optionIndex) NFFT] = plot_powerspec(d, ...
0106         data0(:,plotNum), 1, [], [], plotoptions{1},~isMains);
0107     
0108     hold on
0109     % after data
0110     [boo1, coo1, h(pageNum, plotNum,optionIndex) NFFT] = plot_powerspec(d, ...
0111         data1(:,plotNum), 1, [],[], plotoptions{2},~isMains);
0112     
0113     
0114     if(~isMains)
0115         % calculate the change in value
0116         ff = find( (abs(boo-1.2)==min(abs(boo-1.2))) );
0117         lowerBy =  (abs(coo1(ff))./abs(coo(ff)))^2;
0118         
0119         leg{1} = 'Before';
0120         leg{2} = sprintf(' ''After (ratio of %2.2f)'' ', lowerBy);
0121         
0122         thisY1 = 2*abs(coo1(1:NFFT/2+1,:));
0123         thisY  = 2*abs(coo(1:NFFT/2+1,:));
0124         ff = find(boo>1.15 & boo<1.25);
0125         minY = median([thisY(ff); thisY1(ff)]);
0126         %    minY = min([thisY(ff); thisY1(ff)]);
0127         maxY = max([thisY(ff); thisY1(ff)]);
0128         
0129         axis([1.15 1.25 0.9*(minY) 1.1*maxY]);
0130         
0131         thisTitle = plotlabel{plotNum};
0132     else
0133         leg{1} = 'Before';
0134         leg{2} = 'After';
0135         thisTitle = sprintf('%s %u', txt{1}{1}, plotNum);
0136     end
0137     
0138     
0139     %set(gca,'fontsize',2)
0140     %legend(leg,'Location','BestOutside');
0141     %set(gca,'fontsize',5)
0142     
0143     xlabel(txt{2});
0144     ylabel(txt{3});
0145     title(thisTitle);
0146 end
0147 
0148 gtitle(txt{4});
0149 
0150 if(saveplot)
0151     dbclear if error
0152     set(gcf,'paperposition',[0 0 6.0 6.0])
0153     eval(sprintf('print -dpng -r200 %s/%s/fig%u.png;', ...
0154         maindir,type,pageNum));
0155     dbstop if error
0156 else
0157     pause(1);
0158 end
0159 
0160 return;
0161 
0162 
0163 
0164 
0165 %%%%%%%%%%%%%%%%%%%%%%%%%
0166 function p=setProperties(p)
0167 
0168 if (isempty(p))
0169     p.style='flag';
0170     p.swap=0;
0171     p.featflag=0;
0172     return
0173 end
0174 
0175 if (isfield(p,'style'))
0176     
0177 else
0178     p.style='flag';
0179     p.featflag=0;
0180 end
0181 
0182 if (~isfield(p,'swap'))
0183     p.swap=0;
0184 end
0185 
0186 return;
0187 
0188 
0189 %%%%%%%%%%%%%%%%%%%%%%%%%
0190 function manaxis(ax,y)
0191 
0192 if (~isempty(ax))
0193     ax4orig = ax(4);
0194     ymax=max(y)*1.1;
0195     if (max(y)>ax(4))
0196         % if max y is larger than mean
0197         ax(4)=ymax;
0198     elseif (8*nanmean(y)<ax(4) & ax(3)>=0)
0199         % if global mean (ax(4)) is much greater than the
0200         % local y data, rescale
0201         % but if ax(3)<0, that means we're looking at phase
0202         % so don't do anything.
0203         ax(4)=ymax;
0204     elseif (isnan(ax(4)) | isnan(ax(3)))
0205         if (isnan(ax(4)))
0206             ax(4)=1;
0207         end
0208         if (isnan(ax(3)))
0209             ax(3)=0;
0210         end
0211     end
0212     % this is in place until mike comes up with a better way to do
0213     % this - all the previous stuff at times resets the value of
0214     % ax(4) so that it is below that of ax(3) - i don't feel like
0215     % trying to figure out mike's logic, so here's a fix;
0216     if(ax(3) >= ax(4))
0217         if(ax4orig>ax(3))
0218             ax(4) = ax4orig;
0219         else
0220             ax(4) = ax(3)+1;
0221         end
0222     end
0223     axis(ax);
0224 end
0225 
0226 return;
0227 
0228 
0229 %%%%%%%%%%%%%%%%%%%%%%%%%
0230 function [clr,leg]=getcolor(type)
0231 
0232 clr=[ 0.2     0         0;
0233     1         0.66      0;
0234     1         0         1;
0235     0.5       0.2       1;
0236     0.2       0.2       0.8;
0237     1         0.5       0.12;
0238     0.1       0.5       0.9;
0239     0.75      1         1;
0240     0.2       0.5       0.66;
0241     0.9       0.8       0.7;
0242     0.6       0         0.1;
0243     0         0         1
0244     0.5869    0.1909    0.3461
0245     0.0576    0.8439    0.1660
0246     0.3676    0.1739    0.1556
0247     0.6315    0.1708    0.1911
0248     0.7176    0.9943    0.4225
0249     0.6927    0.4398    0.8560
0250     0.0841    0.3400    0.4902
0251     0.4544    0.3142    0.8159
0252     0.4418    0.3651    0.4608
0253     0.3533    0.3932    0.4574
0254     0.1536    0.5915    0.4507
0255     0.6756    0.1197    0.4122
0256     0.6992    0.0381    0.9016
0257     0.7275    0.4586    0.0056
0258     0.4784    0.8699    0.2974
0259     0.5548    0.9342    0.0492
0260     0.1210    0.2644    0.6932
0261     0.4508    0.1603    0.6501
0262     0.7159    0.8729    0.9830
0263     0         0         0];
0264 
0265 
0266 switch type
0267     case 'feature'
0268         leg = {'source', 'calibrator', 'abscal', 'blank', 'skydip', ...
0269             'noise_event', 'noise'};
0270         
0271     case 'bitmask'
0272         leg={'frame','receiver', 'tracking', 'tracker', 'elevation', ...
0273             'continuous', 'fifo', 'clock', '1pps', 'cryo/servo', 'backend time', 'shortfall', 'sun', 'moon'};
0274 end
0275 
0276 return;
0277 
0278

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