This is a static copy of a profile report

Home

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)

Function NameFunction TypeCalls
deglitchWrapperfunction1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
27
a(:,m) = smooth(data(:,m));
61.027 s39.0%
18
dnonoise = cutObs(d, 'noise', ...
10.514 s19.5%
49
da = deriv(dnonoise.antenna0.r...
10.492 s18.7%
30
stdVals  = std(diffVals);
10.186 s7.1%
31
diffNorm = abs(diffVals)./repm...
10.153 s5.8%
All other lines  0.262 s10.0%
Totals  2.634 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
smoothfunction60.896 s34.0%
cutObsfunction10.503 s19.1%
derivfunction10.492 s18.7%
stdfunction10.186 s7.1%
setNewFlagfunction10.077 s2.9%
repmatfunction10.022 s0.8%
Self time (built-ins, overhead, etc.)  0.459 s17.4%
Totals  2.634 s100% 
Code Analyzer results
Line numberMessage
27The variable 'a' appears to change size on every loop iteration. Consider preallocating for speed.
67Use TRUE or FALSE instead of LOGICAL(1) or LOGICAL(0).
71The value assigned here to 'dnew' appears to be unused. Consider replacing it by ~.
Coverage results
[ Show coverage for parent directory ]
Total lines in function75
Non-code lines (comments, blank lines)46
Code lines (lines that can run)29
Code lines that did run29
Code lines that did not run0
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.