This is a static copy of a profile report

Home

apparentAzEl (1 call, 8.405 sec)
Generated 05-Aug-2011 13:00:41 using cpu time.
function in file /home/LeechJ/cbass_analysis/pointing/apparentAzEl.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
reduceData>checkFlagssubfunction1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
100
[azprime2,elprime2]=calcAzEl2(...
34.612 s54.9%
46
[azdoubleprime,eldoubleprime]=...
11.618 s19.2%
71
[azprime2,elprime2]=calcAzEl2(...
11.519 s18.1%
112
azapp= wrap360(azprime+daz);
30.131 s1.6%
113
elapp = wrap360(elprime+del);
30.120 s1.4%
All other lines  0.404 s4.8%
Totals  8.405 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
calcAzEl2function57.738 s92.1%
wrap360function60.219 s2.6%
wrap180function60.142 s1.7%
num2strfunction60 s0%
Self time (built-ins, overhead, etc.)  0.306 s3.6%
Totals  8.405 s100% 
Code Analyzer results
Line numberMessage
87The value assigned to variable 'alen' might be unused.
114The variable 'vecazerr' appears to change size on every loop iteration. Consider preallocating for speed.
115The variable 'vecelerr' appears to change size on every loop iteration. Consider preallocating for speed.
Coverage results
[ Show coverage for parent directory ]
Total lines in function133
Non-code lines (comments, blank lines)84
Code lines (lines that can run)49
Code lines that did run47
Code lines that did not run2
Coverage (did run/can run)95.92 %
Function listing
   time   calls  line
1 function d = apparentAzEl(d)
2
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 %
5 % function d = apparentAzEl(d)
6 %
7 % functions that retracts the pointing model and refraction corrections to
8 % go from encoder az/el to sky az/el.
9 %
10 % d - data structure
11 %
12 % creates new subfield:
13 % d.antenna0.servo.apparent, which is [Nby4], where each column
14 % corresponds to :
15 % [apparentAzimuth, apparentElevation, error in fit for Az, error in fit
16 % for El];
17 %
18 %
19 %aza is the apparent azimuth
20 %ela is the apparent elevation
21 %erraz is the error between the antenna coordinate recorder in the data and
22 %what we get when we use the apparent position to start with for refraction
23 %and pointing calcualtions
24 %similarly for erralt
25 %
26 % CJC
27 %
28 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
29 % ogk edit 1:
30 % Changed the condition in the while loop to
31 % Azimuth Error > threshold -> mod(Azimuth Error,360)>threshold
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33
34 %get the antenna coordinates that we start with
1 35 azprime=d.antenna0.servo.az;
1 36 elprime = d.antenna0.servo.el;
1 37 maxitr=20;
38
39 %lets just see what sort of correction we get at this antenna angle (AZ')-
40 %if we assume the difference between AZ (apparent) and AZ'(antenna) is
41 %small then we can use this number as a start approximation- here we have 3
42 %coordinates Az (apparent AZ) Az' (antenna Az) AZ'' (meaningless azimuth
43 %position calculated by applying a pointing and refraction correction to ...
44 % Az') and we
45 %make the assumptio that Az-Az' is approximately Az'-Az''
1.62 1 46 [azdoubleprime,eldoubleprime]=calcAzEl2(azprime,elprime,d);
47
48 %now we calculate what sort of offset we have, daz and del-note that this
49 %offset is between AZ' and AZ''- ie daz=AZ'-AZ''- therefore to go back to
50 %AZ we use the equation daz~=AZ-AZ' (using approximation) and therefore ...
51 % AZ=AZ'+daz
52
1 53 daz=azprime-azdoubleprime;
0.01 1 54 del=elprime-eldoubleprime;
55
56 %Now we assume that the difference between the apparent and antenna
57 %coordinates is small i.e that the same sort of correction would have been
58 %found if we'd done the calculation on the apparent coordinates- defining
59 %apparent coordinates as AZ and antenna coordinates as AZ' we have
60 %daz = AZ-AZ' (not the difference and similarity (!!!) with the calculation
61 %above
62 % AZ=AZ'+daz
63
1 64 azapp = azprime+daz;
0.01 1 65 elapp = elprime+del;
66
67 %So these are our first guesses for the apparent azimuth and elevation
68 %values- they should be ok but lets just check by going from these values
69 %back to the antenna values and comparing
70
1.52 1 71 [azprime2,elprime2]=calcAzEl2(azapp,elapp,d);
72
1 73 errazprime = (azprime-azprime2);
0.01 1 74 errelprime = (elprime-elprime2);
75
0.02 1 76 maxazerr=max(abs(errazprime));
0.01 1 77 maxelerr=max(abs(errelprime));
1 78 vecazerr=[];
1 79 vecelerr=[];
0.01 1 80 a=isnan(daz);
1 81 daz(a)=0;
1 82 a=isnan(del);
1 83 del(a)=0;
84 %Now we iteratively adjust the Az (apparent coordinate) until it produces
85 %the 'correct' AZ
86
1 87 alen=length(daz);
0.01 1 88 i=0;
89 %while(((maxazerr >0.0001) || (maxelerr>0.0001)) && (i<maxitr))
90 % i=i+1;
91 %disp(['Iteration (max): ', num2str(i),'(',num2str(maxitr),')']);
92
93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
94 % ogk edit 1: change while loop conditional statement to
95 % mod(maxazerr,360)<...
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1 97 while(((mod(maxazerr,360) >0.0001) || (maxelerr>0.0001)) && (i<maxitr))
3 98 i=i+1;
3 99 disp(['Iteration (max): ', num2str(i),'(',num2str(maxitr),')']);
4.61 3 100 [azprime2,elprime2]=calcAzEl2(azapp,elapp,d);
0.11 3 101 errazprime = wrap180(azprime - azprime2);
0.07 3 102 errelprime = wrap180(elprime - elprime2);
0.02 3 103 a=isnan(errazprime);
3 104 errazprime(a)=0;
3 105 a=isnan(errelprime);
0.01 3 106 errelprime(a)=0;
107
0.04 3 108 maxazerr=max(abs(errazprime));
0.04 3 109 maxelerr=max(abs(errelprime));
3 110 daz = daz + errazprime;
3 111 del = del + errelprime;
0.13 3 112 azapp= wrap360(azprime+daz);
0.12 3 113 elapp = wrap360(elprime+del);
3 114 vecazerr=[vecazerr maxazerr];
3 115 vecelerr=[vecelerr maxelerr];
116 %end
3 117 end
118
1 119 if i>=maxitr
120 %Error handling in case the removal of the pointing correction isn't
121 % working
122 error('Apparent Az/El not converging')
123 end
124 %might need some error checking here but otherwise
125
1 126 erraz=errazprime;
1 127 errel=errelprime;
1 128 aza=azapp;
1 129 ela=elapp;
130
0.01 1 131 d.antenna0.servo.apparent = [aza ela erraz errel];
132
1 133 return;