This is a static copy of a profile reportHome
plot1overf>getStatsPlots (2 calls, 224.897 sec)
Generated 05-Aug-2011 13:00:43 using cpu time.
subfunction in file /home/LeechJ/cbass_analysis/reduc/plotting/plot1overf.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Function Name | Function Type | Calls |
plot1overf | function | 2 |
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
134 | [alpha1 fknee1 white1 fn1 meas... | 860 | 220.787 s | 98.2% |  |
219 | eval(sprintf('print -dpng -r20... | 2 | 1.650 s | 0.7% |  |
98 | d = applyFlags(d); | 2 | 0.820 s | 0.4% |  |
132 | stareData = interp1(goodLength... | 860 | 0.557 s | 0.2% |  |
191 | loglog(fn1, allMeas); | 20 | 0.219 s | 0.1% |  |
All other lines | | | 0.863 s | 0.4% |  |
Totals | | | 224.897 s | 100% | |
Children (called functions)
Code Analyzer results
Line number | Message |
109 | The value assigned to variable 'start_string' might be unused. |
141 | The variable 'fn1_all' appears to change size on every loop iteration. Consider preallocating for speed. |
142 | The variable 'meas1_all' appears to change size on every loop iteration. Consider preallocating for speed. |
143 | The variable 'fit1_all' appears to change size on every loop iteration. Consider preallocating for speed. |
149 | The value assigned to variable 'thisSize' might be unused. |
153 | The variable 'thisSize' appears to change size on every loop iteration. Consider preallocating for speed. |
157 | The value assigned to variable 'allMes' might be unused. |
163 | The variable 'allMeas' appears to change size on every loop iteration. Consider preallocating for speed. |
164 | The variable 'allFit' appears to change size on every loop iteration. Consider preallocating for speed. |
171 | The variable 'allMeas' appears to change size on every loop iteration. Consider preallocating for speed. |
172 | The variable 'allFit' appears to change size on every loop iteration. Consider preallocating for speed. |
175 | The variable 'allMeas' appears to change size on every loop iteration. Consider preallocating for speed. |
176 | The variable 'allFit' appears to change size on every loop iteration. Consider preallocating for speed. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 142 |
Non-code lines (comments, blank lines) | 42 |
Code lines (lines that can run) | 100 |
Code lines that did run | 100 |
Code lines that did not run | 0 |
Coverage (did run/can run) | 100.00 % |
Function listing
time calls line
83 function [noise_fknee noise_alpha noise_white mjd errorFlags] = getStatsPlots(d,stareEndPoints,gen, field, figNum)
84
2 85 nChannel = size(d.antenna0.receiver.data,2);
2 86 grid = [nChannel/2 2]; % subplot grid for this plot.
2 87 sample_frequency = 100;
88
89 % we'll cut nStare down depending on how well they do.
2 90 nStare=size(stareEndPoints,1);
2 91 noise_white=zeros(nStare,nChannel);
2 92 noise_alpha=zeros(nStare,nChannel);
2 93 noise_fknee=zeros(nStare,nChannel);
2 94 mjd=zeros(nStare,1);
2 95 errorFlags=zeros(nStare,nChannel);
96
97 % apply the flags
0.82 2 98 d = applyFlags(d);
99
100
2 101 for stareIndex=1:nStare,
102
96 103 stare_start_index=stareEndPoints(stareIndex,1);
96 104 stare_end_index=stareEndPoints(stareIndex,2);
105
96 106 stareRange1=stare_start_index+1:stare_end_index-1;
107
96 108 start_utc = d.antenna0.receiver.utc(stare_start_index);
0.11 96 109 start_string = mjd2string(start_utc);
96 110 mjd(stareIndex) = start_utc;
111
0.01 96 112 for channel=1:nChannel,
0.01 960 113 stareData=d.antenna0.receiver.data(stareRange1,channel);
114 % check for the length of unflagged-ness
0.01 960 115 lflag = length(find(isnan(stareData)));
960 116 ll = length(stareData);
960 117 if(lflag > 0.05*ll)
118 % too much flagged data, don't trust
100 119 alpha1 = nan;
100 120 fknee1 = nan;
100 121 white1 = nan;
100 122 fn1 = nan;
100 123 measuredn1 = nan;
100 124 fittedn1 = nan;
100 125 errorFlag1 = nan;
860 126 else
127 % interpolate so we have continuous data stream
860 128 goodStareData = stareData;
860 129 goodLength = 1:ll;
0.01 860 130 goodLength(isnan(stareData)) = [];
0.01 860 131 goodStareData(isnan(stareData)) = [];
0.56 860 132 stareData = interp1(goodLength, goodStareData, 1:ll, 'linear', ...
133 'extrap');
220.79 860 134 [alpha1 fknee1 white1 fn1 measuredn1 fittedn1 errorFlag1] = fitOneOverF(sample_frequency,stareData');
0.01 860 135 end
136
960 137 noise_white(stareIndex, channel) = white1;
960 138 noise_alpha(stareIndex, channel) = alpha1;
960 139 noise_fknee(stareIndex, channel) = fknee1;
960 140 errorFlags(stareIndex, channel) = errorFlag1;
960 141 fn1_all{stareIndex, channel} = fn1;
960 142 meas1_all{stareIndex, channel} = measuredn1;
960 143 fit1_all{stareIndex, channel} = fittedn1;
0.01 960 144 end
96 145 end
146
147 % next we make our plot, first we need to get an average fn1 on which we
148 % sample measuredn1 and fittedn1
0.01 2 149 thisSize = [];
2 150 for m=1:nChannel
20 151 thisSize = [];
20 152 for mm=1:size(fn1_all,1)
960 153 thisSize = [thisSize; length(fn1_all{mm,m})];
960 154 end
20 155 f = find(thisSize == max(thisSize),1);
20 156 fn1 = fn1_all{f,m};
20 157 allMes = [];
20 158 allFit = [];
20 159 for mm=1:size(fn1_all,1)
0.02 960 160 if(~isnan(fn1_all{mm,m}))
0.04 860 161 if(length(fn1) == length(fn1_all{mm,m}))
162 % no interpolation needed.
440 163 allMeas(mm,:) = meas1_all{mm,m};
0.02 440 164 allFit(mm,:) = fit1_all{mm,m};
420 165 else
166 % interpolate on same data scale.
0.13 420 167 thisMeas = interp1(fn1_all{mm,m}, meas1_all{mm,m}, fn1, 'linear', ...
168 'extrap');
0.19 420 169 thisFit = interp1(fn1_all{mm,m}, fit1_all{mm,m}, fn1, 'linear', ...
170 'extrap');
420 171 allMeas(mm,:) = thisMeas;
420 172 allFit(mm,:) = thisFit;
420 173 end
100 174 else
100 175 allMeas(mm,:) = nan(size(fn1));
100 176 allFit(mm,:) = nan(size(fn1));
100 177 end
960 178 end
179
180 % next we take an average
181 %thisMeas = nanmean(allMeas, 2);
182 %thisStd = nanstd(allMeas, [], 2);
183 %thisFit = nanmean(allFit,2);
20 184 mean_white = nanmean(noise_white(:,m));
20 185 mean_fknee = nanmean(noise_fknee(:,m));
20 186 mean_alpha = nanmean(noise_alpha(:,m));
187
188
189 % let's not take the average, let's just plot them all.
0.11 20 190 subplot(grid(1), grid(2), m);
0.22 20 191 loglog(fn1, allMeas);
20 192 if(m==grid(1) || m==nChannel)
4 193 xlabel('Frequency [Hz]');
4 194 end
0.08 20 195 ylabel('Power');
0.04 20 196 title(sprintf('Channel %d [%e, %e, %e]', m, mean_alpha, mean_fknee, mean_white));
20 197 end
198
2 199 numGoodScans = ~isnan(noise_fknee);
2 200 numGoodScans = sum(numGoodScans,1);
2 201 numGoodScans = median(numGoodScans);
202
203
2 204 switch(figNum)
2 205 case 1
1 206 gtitle(sprintf('Power Spectra for %d Scans', numGoodScans));
207
1 208 case 2
1 209 gtitle(sprintf('Power Spectra for %d Noise Source Events', numGoodScans));
1 210 end
211
212
213 % if we're generating a plot, do so
2 214 if(gen)
215 % get the directory to write to
2 216 maindir=getmaindir(d, field);
2 217 dbclear if error
2 218 set(gcf,'paperposition',[0 0 6.0 6.0])
1.65 2 219 eval(sprintf('print -dpng -r200 %s/overf/fig%d.png;', ...
220 maindir, figNum));
0.01 2 221 dbstop if error
2 222 end
223
2 224 return;
Other subfunctions in this file are not included in this listing.