This is a static copy of a profile reportHome
getCalTemps (1 call, 0.044 sec)
Generated 05-Aug-2011 13:00:40 using cpu time.
function in file /home/LeechJ/cbass_analysis/constants/getCalTemps.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 |
23 | tsys = load(filename); | 1 | 0.033 s | 75.0% |  |
60 | dateDif = aDate - repmat(date2... | 1 | 0.011 s | 25.0% |  |
166 | return; | 1 | 0 s | 0% |  |
163 | outTsys.trx = tsysVals(:,7:... | 1 | 0 s | 0% |  |
162 | outTsys.tnoise = tsysVals(:,5:... | 1 | 0 s | 0% |  |
All other lines | | | 0.000 s | 0.0% |  |
Totals | | | 0.044 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
repmat | function | 2 | 0 s | 0% |  |
Self time (built-ins, overhead, etc.) | | | 0.044 s | 100.0% |  |
Totals | | | 0.044 s | 100% | |
Code Analyzer results
Line number | Message |
65 | Assignment to 'f' might be unnecessary. |
83 | Use of brackets [] is unnecessary. Use parentheses to group, if needed. |
89 | The variable 'tsysVals' appears to change size on every loop iteration. Consider preallocating for speed. |
101 | Use of brackets [] is unnecessary. Use parentheses to group, if needed. |
107 | The variable 'tsysVals' appears to change size on every loop iteration. Consider preallocating for speed. |
113 | The value assigned to variable 'stop' might be unused. |
115 | Use of brackets [] is unnecessary. Use parentheses to group, if needed. |
121 | Use of brackets [] is unnecessary. Use parentheses to group, if needed. |
127 | The variable 'tsysVals' appears to change size on every loop iteration. Consider preallocating for speed. |
139 | Use of brackets [] is unnecessary. Use parentheses to group, if needed. |
145 | The variable 'tsysVals' appears to change size on every loop iteration. Consider preallocating for speed. |
151 | The value assigned to variable 'stop' might be unused. |
153 | Use of brackets [] is unnecessary. Use parentheses to group, if needed. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 166 |
Non-code lines (comments, blank lines) | 48 |
Code lines (lines that can run) | 118 |
Code lines that did run | 46 |
Code lines that did not run | 72 |
Coverage (did run/can run) | 38.98 % |
Function listing
time calls line
1 function [outTsys] = getCalTemps(date1, date2, filename)
2
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 %
5 % function [outTsys] = getCalTemps(date1, date2, filename)
6 %
7 % function that reads an ASCII text file, given by filename, and finds the
8 % tsys and noise diode temps that should be applied to the data for the
9 % time given by date
10 %
11 % sjcm
12 %
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
15 % note. this function will not work if we have too many values set to nan.
16 % will work on a fix for this in the future.
17
18
1 19 if(nargin<3)
1 20 filename = 'constants/calibration_values.txt';
1 21 end
22
0.03 1 23 tsys = load(filename);
24
1 25 aDate = tsys(:,1);
26
27 % first put things in chronological order
1 28 [aDateChron, sortOrder] = sort(aDate);
1 29 aChron = tsys(sortOrder,:);
30
31 % redefine the variables
1 32 aDate = aDateChron;
1 33 tsys = aChron;
34
35
36 % let's get rid of the repeats - always trust the lastest one
1 37 reps = find(diff(aDate)==0);
1 38 aDate(reps,:) = [];
1 39 tsys(reps,:) = [];
40
41 % find the prior good time.
1 42 dateDif = aDate - repmat(date1, size(aDate));
1 43 f = find(dateDif > 0);
1 44 if(isempty(f))
45 f = length(dateDif);
1 46 else
1 47 f = f-1;
1 48 f = f(1);
1 49 end
1 50 if(f==0)
1 51 f=1;
1 52 end
53
54 % look for how many values are from within an hour of that one.
1 55 inPriorHour = find(aDate>(aDate(f)-1/24) & aDate<=aDate(f));
1 56 tsysPrior = tsys(inPriorHour,:);
57
58 % next we check for the post time.
59 % find the prior good time.
0.01 1 60 dateDif = aDate - repmat(date2, size(aDate));
1 61 f = find(dateDif > 0);
1 62 if(isempty(f))
63 f = length(dateDif);
1 64 else
1 65 f = f;
1 66 f = f(1);
1 67 end
1 68 if(f==0)
69 f=1;
70 end
71
72 % look for how many values are from within an hour of that one.
1 73 inPostHour = find(aDate<(aDate(f)+1/24) & aDate>=aDate(f));
1 74 tsysPost = tsys(inPostHour,:);
75
76
77 % now we have all our data sets as:
1 78 tsysVals = [tsysPrior; tsysPost];
79
80 % next we check that all our values are not nan-ed.
81 % check for nan's
1 82 if(all(isnan(tsysVals(:,3))))
83 display(['Found some NaN values.']);
84 display('Will find next good data');
85 stop = 0;
86 m = last(inPostHour);
87 while(stop==0)
88 if(~isnan(tsys(m,3)))
89 tsysVals = [tsysVals; tsys(m,:)];
90 stop = 1;
91 else
92 m = m+1;
93 end
94 if(m==length(tsys))
95 stop = 1;
96 end
97 end
98 end
99
1 100 if(all(isnan(tsysVals(:,3))))
101 display(['Still many NaN values']);
102 display('Will find previous good data');
103 stop = 0;
104 m = inPriorHour(1);
105 while(stop==0)
106 if(~isnan(tsys(m,3)))
107 tsysVals = [tsysVals; tsys(m,:)];
108 stop = 1;
109 else
110 m = m-1;
111 end
112 if(m==0)
113 stop = 1;
114 display('CAN''T DO SHIT!!!');
115 error(['ALL your Tsys values for this channel are bad']);
116 end
117 end
118 end
119
1 120 if(all(isnan(tsysVals(:,4))))
121 display(['Found some NaN values.']);
122 display('Will find next good data');
123 stop = 0;
124 m = last(inPostHour);
125 while(stop==0)
126 if(~isnan(tsys(m,4)))
127 tsysVals = [tsysVals; tsys(m,:)];
128 stop = 1;
129 else
130 m = m+1;
131 end
132 if(m==length(tsys))
133 stop = 1;
134 end
135 end
136 end
137
1 138 if(all(isnan(tsysVals(:,4))))
139 display(['Still many NaN values']);
140 display('Will find previous good data');
141 stop = 0;
142 m = inPriorHour(1);
143 while(stop==0)
144 if(~isnan(tsys(m,4)))
145 tsysVals = [tsysVals; tsys(m,:)];
146 stop = 1;
147 else
148 m = m-1;
149 end
150 if(m==0)
151 stop = 1;
152 display('CAN''T DO SHIT!!!');
153 error(['ALL your Tsys values for this channel are bad']);
154 end
155 end
156 end
157
1 158 outTsys.time = tsysVals(:,1);
1 159 outTsys.source = tsysVals(:,2);
1 160 outTsys.val = tsysVals(:,3:4);
1 161 outTsys.flag = isnan(tsysVals(:,3:4));
1 162 outTsys.tnoise = tsysVals(:,5:6);
1 163 outTsys.trx = tsysVals(:,7:8);
164
165 % that's it
1 166 return;
Other subfunctions in this file are not included in this listing.