This is a static copy of a profile report

Home

calcSourceDist (3 calls, 2.886 sec)
Generated 05-Aug-2011 13:00:47 using cpu time.
function in file /home/LeechJ/cbass_analysis/constants/calcSourceDist.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
flagMaskfunction1
flagRFI_posfunction2
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
69
[az,el] = radec2azel(raInt, de...
30.918 s31.8%
72
dist = spaceangle(az, el, d.an...
30.831 s28.8%
65
lstInt = interp1(trackutc, tra...
30.415 s14.4%
45
raInt  = interp1(mjd, ra, d.an...
30.350 s12.1%
46
decInt = interp1(mjd, dec, d.a...
30.328 s11.4%
All other lines  0.044 s1.5%
Totals  2.886 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
interp1function91.093 s37.9%
radec2azelfunction30.907 s31.4%
spaceanglefunction30.831 s28.8%
uniquefunction30 s0%
Self time (built-ins, overhead, etc.)  0.055 s1.9%
Totals  2.886 s100% 
Code Analyzer results
Line numberMessage
75To improve performance, use logical indexing instead of FIND.
Coverage results
[ Show coverage for parent directory ]
Total lines in function76
Non-code lines (comments, blank lines)35
Code lines (lines that can run)41
Code lines that did run29
Code lines that did not run12
Coverage (did run/can run)70.73 %
Function listing
   time   calls  line
1 function [dist,az,el] = calcSourceDist(d, source)
2
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 %
5 % function [dist,az,el] = calcSourceDist(d, source)
6 %
7 %
8 % calculates the distance between where the antenna is pointing and the
9 % source given by 'source'. source can either be 'sun' or 'moon', and d
10 % must be the data structure with az/el
11 %
12 % sjcm
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
3 15 switch source
3 16 case 'moon'
17 % load the source ephemeris in
18 % moon = load('constants/moon_ephem2.m');
0.02 2 19 moon = load('constants/moon.ephem');
2 20 mjd = moon(:,1) - 2400000.5;
21
2 22 ra = moon(:,2) + moon(:,3)/60 + moon(:,4)/3600; % in hours
23
24
2 25 ind = moon(:,5)<0;
2 26 dec(ind) = moon(ind,5) + moon(ind,6)/60 + moon(ind,7)/3600;
0.01 2 27 dec(~ind) = -(-moon(~ind,5) + moon(~ind,6)/60 + moon(~ind,7)/3600); % in degrees
28
1 29 case 'sun'
0.01 1 30 sun = load('constants/sun.ephem');
1 31 mjd = sun(:,1) - 2400000.5;
32
1 33 ra = sun(:,2) + sun(:,3)/60 + sun(:,4)/3600;
1 34 ra = ra*15; % in degrees
35
1 36 ind = sun(:,5)<0;
1 37 dec(ind) = sun(ind,5) + sun(ind,6)/60 + sun(ind,7)/3600;
1 38 dec(~ind) = -(-sun(~ind,5) + sun(~ind,6)/60 + sun(~ind,7)/3600); % in degrees
39
40 otherwise
41 error('source not recognized');
42 end
43
44
0.35 3 45 raInt = interp1(mjd, ra, d.antenna0.receiver.utc, 'spline');
0.33 3 46 decInt = interp1(mjd, dec, d.antenna0.receiver.utc, 'spline');
47
48 % make sure we don't have repeated data in tracker.utc and tracker.lst
3 49 if(length(d.antenna0.tracker.utc)~=length(unique(d.antenna0.tracker.utc)))
50 indBadTime = zeros(size(d.antenna0.tracker.utc));
51 aa = sort(d.antenna0.tracker.utc);
52 f = find(diff(aa)==0);
53 for m=1:length(f)
54 ff = find(d.antenna0.tracker.utc == aa(f(m)));
55 indBadTime(ff(2:length(ff))) = 1;
56 end
57
58 trackutc = d.antenna0.tracker.utc(~indBadTime);
59 tracklst = d.antenna0.tracker.lst(~indBadTime);
3 60 else
3 61 trackutc = d.antenna0.tracker.utc;
3 62 tracklst = d.antenna0.tracker.lst;
3 63 end
64
0.42 3 65 lstInt = interp1(trackutc, tracklst, ...
66 d.antenna0.receiver.utc);
67
68 % from RA/DEC to az/el
0.92 3 69 [az,el] = radec2azel(raInt, decInt, lstInt);
70
71 % next we find the distance to what we're currently pointing at
0.83 3 72 dist = spaceangle(az, el, d.antenna0.servo.az, d.antenna0.servo.el, 'deg');
73
3 74 f = find(isnan(dist));
3 75 dist(f) = 0;
3 76 return;

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