Home > reduc > plotting > genfigMainsReg.m

genfigMainsReg

PURPOSE ^

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

SYNOPSIS ^

function data=genfigMainsReg(d, txt, ax, type, field, saveplot)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 function data=plotMainsReg(d, txt, axtype, field, saveplot)

 d       - data structure
 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]

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function data=genfigMainsReg(d, txt, ax, type, field, saveplot)
0002 
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 % function data=plotMainsReg(d, txt, axtype, field, saveplot)
0005 %
0006 % d       - data structure
0007 % txt     - axis text
0008 %           txt{1} - title
0009 %           txt{2} - x axis
0010 %           txt{3} - y axis
0011 %           txt[4} - overall title
0012 %           txt{5} - legend
0013 % ax         - manual axis settings.  [xmin xmax ymin ymax]
0014 %
0015 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0016 
0017 if(nargin<6)
0018   saveplot = 1;
0019 end
0020 
0021 
0022 % check for axis setting
0023 if (~exist('ax'))
0024   ax=[];
0025 end
0026 
0027 if(saveplot)
0028   % get the directory to write to
0029   maindir=getMainDir(d, field);
0030 end
0031 
0032   
0033 % num is the number of pages to be displayed.
0034 % matrix is the size of each of the pages to be displayed.
0035 num = 1;
0036 plotsPerPage = 6;
0037 matrix = [3 2];
0038 
0039 plotoptions = {'b', 'g', 'r', 'c', 'm', 'y', 'k', ...
0040     'b.', 'g.', 'r.', 'c.', 'm.', 'y.', 'k.', ...    
0041     'bo', 'go', 'ro', 'co', 'mo', 'yo', 'ko', ...    
0042     'bx', 'gx', 'rx', 'cx', 'mx', 'yx', 'kx'};
0043 
0044 data = d.antenna0.receiver.data;
0045 data(d.flags.fast) = nan;
0046 timeVal = d.antenna0.receiver.utc*24*60*60;
0047 
0048 fmode=logical(0);
0049 
0050 for pageNum=1:num
0051   clear leg;
0052   for plotNum=1:plotsPerPage
0053     indices = d.correction.mains.indices(plotNum,:);
0054     subplot(matrix(1),matrix(2),plotNum)
0055     % plot data
0056     optionIndex = 1;
0057     for mm=1:size(d.correction.mains.factors,2)
0058       if(mm==1)
0059     % plot uncorrected data
0060     [boo, coo, h(pageNum, plotNum,optionIndex)] = plot_powerspec(d, ...
0061         data(:,plotNum), indices(1), indices(2), ...
0062         0, plotoptions{optionIndex});
0063     hold on;
0064     leg{optionIndex} = 'Orig';
0065     optionIndex = optionIndex+1;
0066       end
0067       clear boo;
0068       clear coo;
0069       
0070       
0071       % remove the harmonic of hte mains
0072       best_freq = d.correction.mains.factors(plotNum,mm,1);
0073       best_phase= d.correction.mains.factors(plotNum,mm,2);
0074       best_amp  = d.correction.mains.factors(plotNum,mm,3);
0075       best_fit_sin = sin(timeVal*2*pi*best_freq + ...
0076       best_phase)*best_amp;
0077       data(:,plotNum) = data(:,plotNum)-best_fit_sin;
0078       
0079       % plot the one with it removed
0080       [boo, coo, h(pageNum, plotNum,optionIndex)] = plot_powerspec(d, ...
0081       data(:,plotNum), indices(1), indices(2), ...
0082       0, plotoptions{optionIndex});
0083       hold on;
0084       leg{optionIndex} = sprintf('Harmonic %u', mm);
0085       optionIndex = optionIndex+1;    
0086     end
0087     xlabel(txt{2});
0088     ylabel(txt{3});
0089     thisTitle = sprintf('%s %u', txt{1}{1}, plotNum);
0090     title(thisTitle);
0091   end
0092     
0093   legend(leg,'Location','Best');
0094   gtitle('Mains Hum Removal');
0095 
0096   if(saveplot)
0097     dbclear if error
0098     set(gcf,'paperposition',[0 0 6.0 6.0])
0099     eval(sprintf('print -dpng -200 %s/%s/fig%u.png;', ...
0100     maindir,type,pageNum));
0101     dbstop if error
0102   else
0103     pause(1);
0104   end
0105   
0106 end
0107 
0108 return;
0109 
0110 
0111 
0112 %%%%%%%%%%%%%%%%%%%%%%%%%
0113 function [clr,leg]=getcolor(type)
0114 
0115 clr=[ 0.2     0         0;
0116     1         0.66      0;
0117     1         0         1;
0118     0.5       0.2       1;
0119     0.2       0.2       0.8;
0120     1         0.5       0.12;
0121     0.1       0.5       0.9;
0122     0.75      1         1;
0123     0.2       0.5       0.66;
0124     0.9       0.8       0.7;
0125     0.6       0         0.1;
0126     0         0         1
0127     0.5869    0.1909    0.3461
0128     0.0576    0.8439    0.1660
0129     0.3676    0.1739    0.1556
0130     0.6315    0.1708    0.1911
0131     0.7176    0.9943    0.4225
0132     0.6927    0.4398    0.8560
0133     0.0841    0.3400    0.4902
0134     0.4544    0.3142    0.8159
0135     0.4418    0.3651    0.4608
0136     0.3533    0.3932    0.4574
0137     0.1536    0.5915    0.4507
0138     0.6756    0.1197    0.4122
0139     0.6992    0.0381    0.9016
0140     0.7275    0.4586    0.0056
0141     0.4784    0.8699    0.2974
0142     0.5548    0.9342    0.0492
0143     0.1210    0.2644    0.6932
0144     0.4508    0.1603    0.6501
0145     0.7159    0.8729    0.9830
0146     0         0         0];
0147 
0148 
0149 switch type
0150   case 'feature'
0151     leg = {'source', 'calibrator', 'abscal', 'blank', 'skydip', ...
0152     'noise_event', 'noise'};
0153     
0154   case 'bitmask'
0155     leg={'frame','receiver', 'tracking', 'tracker', 'elevation', ...
0156     'continuous', 'fifo', 'clock', '1pps', 'cryo/servo', 'backend time', 'shortfall', 'sun', 'moon'};
0157 end
0158 
0159 return;
0160 
0161

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