This is a static copy of a profile reportHome
deglitch (1 call, 2.634 sec)
Generated 05-Aug-2011 13:00:38 using cpu time.
function in file /home/LeechJ/cbass_analysis/reduc/flag/deglitch.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
27 | a(:,m) = smooth(data(:,m)); | 6 | 1.027 s | 39.0% |  |
18 | dnonoise = cutObs(d, 'noise', ... | 1 | 0.514 s | 19.5% |  |
49 | da = deriv(dnonoise.antenna0.r... | 1 | 0.492 s | 18.7% |  |
30 | stdVals = std(diffVals); | 1 | 0.186 s | 7.1% |  |
31 | diffNorm = abs(diffVals)./repm... | 1 | 0.153 s | 5.8% |  |
All other lines | | | 0.262 s | 10.0% |  |
Totals | | | 2.634 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
smooth | function | 6 | 0.896 s | 34.0% |  |
cutObs | function | 1 | 0.503 s | 19.1% |  |
deriv | function | 1 | 0.492 s | 18.7% |  |
std | function | 1 | 0.186 s | 7.1% |  |
setNewFlag | function | 1 | 0.077 s | 2.9% |  |
repmat | function | 1 | 0.022 s | 0.8% |  |
Self time (built-ins, overhead, etc.) | | | 0.459 s | 17.4% |  |
Totals | | | 2.634 s | 100% | |
Code Analyzer results
Line number | Message |
27 | The variable 'a' appears to change size on every loop iteration. Consider preallocating for speed. |
67 | Use TRUE or FALSE instead of LOGICAL(1) or LOGICAL(0). |
71 | The value assigned here to 'dnew' appears to be unused. Consider replacing it by ~. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 75 |
Non-code lines (comments, blank lines) | 46 |
Code lines (lines that can run) | 29 |
Code lines that did run | 29 |
Code lines that did not run | 0 |
Coverage (did run/can run) | 100.00 % |
Function listing
time calls line
1 function flags = deglitch(d, params)
2
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 %
5 % function d = deglitch(d, params)
6 %
7 % rough function to find and flag glitches in the data, focusing on
8 % spurious points and on RFIs. Needs a lot of improvement. Right now
9 % might flag too much data.
10 %
11 % params = [threshld on channel 1, threshold on channel 2];
12 %
13 % sjcm & act
14 %
15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16
17 % first we only want to flag on data is not the noise source.
0.51 1 18 dnonoise = cutObs(d, 'noise', 'not');
19
1 20 data = dnonoise.antenna0.receiver.data;
21
22 % first we check to see if there spurious points.
1 23 indSpurious = zeros(size(data,1),1);
1 24 stop = 0;
1 25 while(stop==0)
1 26 for m=1:size(data,2)
1.03 6 27 a(:,m) = smooth(data(:,m));
6 28 end
0.02 1 29 diffVals = a-dnonoise.antenna0.receiver.data;
0.19 1 30 stdVals = std(diffVals);
0.15 1 31 diffNorm = abs(diffVals)./repmat(stdVals, [size(diffVals,1) 1]);
0.03 1 32 badVals = diffNorm>3;
0.01 1 33 newIndSpurious = sum(badVals,2)>1;
34
0.01 1 35 indSpurious(newIndSpurious) = 1;
0.03 1 36 data(newIndSpurious,:) = a(newIndSpurious,:);
37
1 38 l = length(find(newIndSpurious));
1 39 newOnes = length(find(indSpurious)) - l;
40
1 41 if(newOnes<1)
1 42 stop = 1;
1 43 end
1 44 end
45
46
47 % next we look for values where the data spikes up over a small amount of
48 % time.
0.49 1 49 da = deriv(dnonoise.antenna0.receiver.data);
0.03 1 50 indDeriv = abs(da(:,1))>params(1) | abs(da(:,6)>params(2));
51
52
53 % next we check for the boxCarRejection on the "pseudo-good" data
54 % NOT DOING UNTIL WE FIND THE RIGHT PARAMETERS
55 %dnonoise.antenna0.receiver.data(indSpurious | indDeriv,:) = nan;
56 %[rfiFlag] = boxRejection(dnonoise,5,10);
57 %t = (dnonoise.antenna0.receiver.utc - dnonoise.antenna0.receiver.utc(1))*24*60*60;
58 %plot(t, log(dnonoise.antenna0.receiver.data(:,1)));
59 %hold on
60 %plot(t(rfiFlag), log(dnonoise.antenna0.receiver.data(rfiFlag,1)), '.r');
61 %hold off
62
63 % combine the ones we flagged on
1 64 indDeglitchFast = indSpurious | indDeriv;
65
66 % convert to size of d, (instead of dnonoise)
1 67 indFinal = logical(zeros(size(d.flags.fast,1),1));
0.01 1 68 indFinal(~d.index.noise.fast) = indDeglitchFast;
69
70 % convert to other timescales.
0.08 1 71 [dnew, flags] = setNewFlag(d, indFinal, 'deglitch');
72
1 73 clear dnew;
74 % now we have to set the proper flags in the flag field
1 75 return;
Other subfunctions in this file are not included in this listing.