This is a static copy of a profile report

Home

reduceData (1 call, 441.366 sec)
Generated 05-Aug-2011 13:01:02 using cpu time.
function in file /home/LeechJ/cbass_analysis/reduc/reduceData.m
Copy to new window for comparing multiple runs

Parents (calling functions)
No parent
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
259
overfWrapper(d, plotparams, pa...
1233.050 s52.8%
230
d = mainsWrapper(d, plotparams...
147.524 s10.8%
226
d = rfiWrapper(d, plotparams, ...
143.622 s9.9%
263
rmsWrapper(d, plotparams, parm...
122.636 s5.1%
192
introPlots(d, plotparams, fiel...
114.963 s3.4%
All other lines  79.571 s18.0%
Totals  441.366 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
overfWrapperfunction1233.039 s52.8%
mainsWrapperfunction147.513 s10.8%
rfiWrapperfunction143.611 s9.9%
rmsWrapperfunction122.636 s5.1%
introPlotsfunction114.952 s3.4%
loadWrapperfunction112.209 s2.8%
reduceData>checkFlagssubfunction112.056 s2.7%
alphaWrapperfunction111.630 s2.6%
flagSummaryfunction18.394 s1.9%
deglitchWrapperfunction17.848 s1.8%
reduceData>writeOutFitssubfunction17.837 s1.8%
webpipefunction14.656 s1.1%
powerSpecWrapperfunction14.164 s0.9%
tsysWrapperfunction13.421 s0.8%
reduceData>checkAlphaDatabasesubfunction12.918 s0.7%
tauCalWrapperfunction12.383 s0.5%
gainWrapperfunction10.743 s0.2%
createDirfunction10.557 s0.1%
noiseWrapperfunction10.426 s0.1%
readScriptfunction10.044 s0.0%
reduceData>gosubfunction170.033 s0.0%
reduceData>matchRevsubfunction10.033 s0.0%
closefunction10.022 s0.0%
pointingWrapperfunction10.011 s0.0%
strcatfunction10.011 s0.0%
searchStructfunction10 s0%
getMainDirfunction10 s0%
reduceData>setRunFlagssubfunction10 s0%
reduceData>welcomesubfunction10 s0%
Self time (built-ins, overhead, etc.)  0.219 s0.0%
Totals  441.366 s100% 
Code Analyzer results
Line numberMessage
46WARNING('OFF',msgID) is faster than WARNING('OFF').
52EXIST with two input arguments is generally faster and clearer than with one input argument.
69EXIST with two input arguments is generally faster and clearer than with one input argument.
78The value assigned to variable 'interactive' might be unused.
85The value assigned to variable 'interactive' might be unused.
89The value assigned to variable 'interactive' might be unused.
91The value assigned to variable 'interactive' might be unused.
144Use || instead of | as the OR operator in (scalar) conditional statements.
170To improve performance, replace ISEMPTY(FIND(X)) with ISEMPTY(FIND( X, 1 )).
189Variable 'time', apparently a structure, is changed but the value seems to be unused.
289Best practice is for CATCH to be followed by an identifier that gets the error information.
294TRY might not be aligned with its matching END (line 298).
296Best practice is for CATCH to be followed by an identifier that gets the error information.
321The value assigned to variable 'plotflag' might be unused.
324The value assigned to variable 'plotflag' might be unused.
330DISP(SPRINTF(...)) can usually be replaced by FPRINTF(...).
Coverage results
[ Show coverage for parent directory ]
Total lines in function353
Non-code lines (comments, blank lines)130
Code lines (lines that can run)223
Code lines that did run124
Code lines that did not run99
Coverage (did run/can run)55.61 %
Function listing
   time   calls  line
1 function d = reduceData(d, fn, interactive, field,sched_name)
2
3 % function dcal = reduceData(d, fn, interactive, field,sched_name)
4 %
5 % VERSION 1.5
6 %
7 % Reduction Routine Using Matlab.
8 %
9 % Inputs:
10 % d - raw/partially calibrated data structure
11 % output from read_arc.m
12 %
13 % Optional:
14 % fn - reduceData auto script, *.red
15 % interactive - 1/0 for user input during the pipeline
16 % field - fieldname you want the plots to be saved to. if you leave it
17 % blank it will default to "other"
18 % sched_name - Name of the schedule if known (this will usually be passed in by
19 % % day_reduce)
20 %
21 % Stephen Muchovej
22 %
23 % Other contributors:
24 %
25 %
26 % HISTORY:
27 % version 0.0: had many different sizes for the flags
28 % version 1.0: all flagging will be done on basis of I1, all polarization,
29 % and I2 (implemented December 8, 2010)
30 % version 1.1: changed step 'rfi1' to 'rfi'. Removed step 'rfi2'.
31 % (MAS Jan 7, 2011).
32 % version 1.2: routine list is now an input in .red file; alpha correction
33 % can be specified in that file, r-factor no longer combines the data. (sjcm, 2/24/2011)
34 % version 1.3: gen, field now in script; removed 'intro' as an input
35 % (3/29/2010)
36 % version 1.4: interactive now as input. Major mods to subfunctions
37 % version 1.5: plot in only 3 colors. blah blah blah. see sjcm's email
38 % april 25,2011.
39 %
40 % define version number
1 41 REV='1.5';
42 % Add in a history field for history logging purposes.
43 %d.history={'Began Data Reduction...'};
44
45 % turn warnings off
1 46 warning off
47
48 % welcome!
1 49 welcome(REV);
50
51 % Check the inputs
1 52 if (exist('fn'))
1 53 if (~isempty(fn))
1 54 disp('Reading script')
0.03 1 55 pause(1)
56
0.07 1 57 parm=readScript(fn);
0.03 1 58 if (~matchRev(parm,REV))
59 return
60 end
0.02 1 61 pause(1)
62 else
63 parm = [];
64 end
65 else
66 parm = [];
67 end
68
1 69 if (~exist('sched_name'))
1 70 sched_name = 'not supplied';
1 71 end;
72
73 % check the inputs, and set defaults
1 74 if(nargin==1)
75 display('Interactive mode with only one input');
76 display('Setting default values');
77 parm = [];
78 interactive = 1;
79 field = 'other';
1 80 elseif(nargin==2)
81 % check if script was read properly
82 if(isempty(parm))
83 display('WARNING: script bad');
84 display('Giving you interactive mode');
85 interactive = 1;
86 field = 'other';
87 else
88 if(isfield(parm, 'interactive'));
89 interactive = parm.interactive.flag;
90 else
91 interactive = 1;
92 parm.interactive.flag = 1;
93 end
94 if(isfield(parm, 'field'))
95 field = parm.field.name;
96 else
97 field = 'other';
98 parm.field.name = 'other';
99 end
100 end
1 101 elseif(nargin==3)
102 display('interactive variable in function call will supersede one in script');
103 parm.interactive.flag = interactive;
104 if(isfield(parm, 'field'))
105 field = parm.field.name;
106 else
107 field = 'other';
108 parm.field.name = field;
109 end
1 110 elseif(nargin==4)
1 111 display('interactive and field variable in function call will supersed one in script');
1 112 parm.interactive.flag = interactive;
1 113 if(isempty(field))
114 field = 'other';
115 end
1 116 parm.field.name = field;
1 117 end
118 % done checking inputs
119
0.01 1 120 d.par = parm;
121
122 % tag version to data
1 123 d.rev=REV;
124
125 % make sure the alpha database is uptodate
2.92 1 126 isup2date = checkAlphaDatabase((d.array.frame.utc(1)));
1 127 if(~isup2date)
128 display('Your alpha database is not up to date');
129 if(parm.interactive.flag)
130 display('You will update the database');
131 display('Don''t fudge it up');
132 updateAlphaDatabase_DD(last(d.array.frame.utc));
133 else
134 display('Proceeding with last valid value');
135 end
136 end
137
138
139 % check run flags
1 140 [plotparams, autorun]=setRunFlags(parm); % from the file
141
142
143 % check if we actually have any data.
1 144 if(isempty(d.array.frame.utc) | all(d.array.frame.features==0))
145 display('You have no data in this structure');
146 display('Why would you try to calibrate it?');
147 return;
148 end
149
150
1 151 if (plotparams.save)
0.56 1 152 createDir(d,field);
1 153 end
154
155
156
157 % perform the first level of flagging
1 158 if(plotparams.save)
1 159 maindir = getMainDir(d, field);
0.01 1 160 fn = strcat(maindir, '/flags.txt');
1 161 diary(fn);
1 162 diary on;
12.06 1 163 d = checkFlags(d, parm);
1 164 diary off;
165 else
166 d = checkFlags(d, parm);
167 end
168
169 % if there's no noise source diode events, you can't calibrate.
1 170 if(isempty(find(d.index.noise_event.fast)))
171 display('There are no Noise Source diode events in your data');
172 display('Can not calibrate this data set');
173 return;
174 end
175
176
177
178 % check for the integration shortfall correction
179 %[d,q] = logcal(d, 'shortfall');
180 %if(~q)
181 % display('Correcting for the Integration Shortfall');
182 % d = shortfallCorr(d);
183 %end
184
185
186
187 % log start time
1 188 time.startTime=d.array.frame.utc(1);
1 189 time.stopTime=d.array.frame.utc(length(d.array.frame.utc));
190
191 % plot the intro plots
14.96 1 192 introPlots(d, plotparams, field);
193
194 % set autoflag false
1 195 autoflag=0;
1 196 par=[];
1 197 lastpar='auto';
1 198 disp(' ')
199
200
201 % now the meat of the function
1 202 while (1)
17 203 if (autorun)
0.03 17 204 [par,lastpar,autorun]=go(par,lastpar,autorun, parm);
205 else
206 [par,lastpar,autoflag]=prompt(par,lastpar,autoflag, parm);
207 end
208
17 209 switch par
17 210 case 'help'
211 menu;
212
17 213 case 'intro'
214 introPlots(d, plotparams, field);
215
17 216 case 'pointing'
0.01 1 217 display('Checking the pointing');
0.02 1 218 pointingWrapper(d, plotparams, parm, field);
219
16 220 case 'deglitch'
1 221 display('Deglitching data');
7.85 1 222 d = deglitchWrapper(d, plotparams, parm, field);
223
15 224 case 'rfi'
1 225 display('RFI Flagging');
43.62 1 226 d = rfiWrapper(d, plotparams, parm, field);
227
14 228 case 'mains'
1 229 display('60Hz Mains correction');
47.52 1 230 d = mainsWrapper(d, plotparams, parm, field);
231
13 232 case 'alpha'
1 233 display('Alpha Correction');
11.63 1 234 d = alphaWrapper(d, plotparams, parm, field);
235
12 236 case 'rfactor'
237 display('R-factor correction');
238 d = rfactorWrapper(d, plotparams, parm, field);
239
12 240 case 'load'
1 241 display('Cold Load fluctuation Removal');
12.22 1 242 d = loadWrapper(d, plotparams, parm, field);
243
11 244 case 'tau'
1 245 display('Calculating the atmospheric opacity');
2.39 1 246 d = tauCalWrapper(d, plotparams, parm, field);
247
10 248 case 'astro'
1 249 display('Applying Astronomical Calibration');
1 250 display('not done yet');
251 %d = astroCalWrapper(d, plotparams, parm, field);
252
9 253 case 'power'
1 254 display('Power Spectrum Plot');
4.18 1 255 powerSpecWrapper(d, plotparams, parm, field);
256
8 257 case 'overf'
1 258 display('1/f plot');
233.05 1 259 overfWrapper(d, plotparams, parm, field);
260
0.01 7 261 case 'rms'
1 262 display('RMS calculation');
22.64 1 263 rmsWrapper(d, plotparams, parm, field);
264
6 265 case 'tsys'
1 266 display('Calculating system temperature of data');
3.42 1 267 d = tsysWrapper(d, plotparams, parm, field);
268
5 269 case 'noise'
1 270 display('Calculating temperature of noise diode');
0.43 1 271 d = noiseWrapper(d, plotparams, parm, field);
272
4 273 case 'gain'
1 274 display('Calculating time-varying gain');
0.74 1 275 d = gainWrapper(d, plotparams, parm, field);
276
3 277 case 'summary'
1 278 display('Displaying the summary of all the flags');
8.39 1 279 flagSummary(d, plotparams, parm, field);
280
2 281 case 'fits'
1 282 if(searchStruct(d, {'correction', 'tsys', 'allbad'}))
1 283 if(d.correction.tsys.allbad == 1)
284 display('Not writing out this crap data');
1 285 else
1 286 display('Writing out data to fits file');
1 287 try
7.84 1 288 writeOutFits(maindir, d, parm);
289 catch
290 disp('Failed to write to fits data')
291 end
1 292 end
293 else
294 try
295 writeOutFits(maindir, d, parm);
296 catch
297 disp('Failed to write to fits data')
298 end
299 end
300
301
1 302 case 'auto'
303 disp(' ')
304 disp('********Auto mode***********')
305 disp('After each step any standard')
306 disp('command will work')
307 disp(' ')
308 disp('To continue with calibration')
309 disp('Hit RETURN without typing anything')
310 disp(' ')
311 autoflag=1;
312 close all;
313
1 314 case 'key'
315 keyboard;
316
1 317 case 'close'
318 close all
319
1 320 case 'plot off'
321 plotflag=0;
322
1 323 case 'plot on'
324 plotflag=1;
325
1 326 case 'save'
327 save dataRed.mat
328
1 329 case 'exit'
1 330 disp(sprintf('Thank you for using Cbass Data Reduction. Now go away\n'))
1 331 break;
332
333 otherwise
334 disp('Unknown command');
335 disp(' ')
336
337 end
16 338 end
339
340 % next, if we generated the plots, we should generate the pages.
1 341 if(plotparams.save)
1 342 display('Generating webpages of all previous plots');
4.68 1 343 webpipe(d, field,0,sched_name);
1 344 end
345
346 % make sure your plots appear from now on
1 347 if(plotparams.plot==0)
0.02 1 348 close all;
1 349 end
350
351
352
1 353 return;

Other subfunctions in this file are not included in this listing.