This is a static copy of a profile reportHome
soradna1 (1 call, 0.033 sec)
Generated 05-Aug-2011 13:03:56 using cpu time.
function in file /home/LeechJ/cbass_analysis/matutils/soradna1.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Function Name | Function Type | Calls |
sunrise | function | 1 |
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
39 | gtime=greg2(yd,yr); | 1 | 0.022 s | 66.7% |  |
147 | sorad(ii)=(Solar_const./RV(ii)... | 1 | 0 s | 0% |  |
146 | ii=z>0; | 1 | 0 s | 0% |  |
145 | sorad=zeros(n,m); | 1 | 0 s | 0% |  |
144 | [n,m]=size(z); | 1 | 0 s | 0% |  |
All other lines | | | 0.011 s | 33.3% |  |
Totals | | | 0.033 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
greg2 | function | 1 | 0 s | 0% |  |
as_consts | script | 1 | 0 s | 0% |  |
Self time (built-ins, overhead, etc.) | | | 0.033 s | 100.0% |  |
Totals | | | 0.033 s | 100% | |
Code Analyzer results
Line number | Message |
54 | Use && instead of & as the AND operator in (scalar) conditional statements. |
56 | Use && instead of & as the AND operator in (scalar) conditional statements. |
130 | The value assigned to variable 'L' might be unused. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 147 |
Non-code lines (comments, blank lines) | 79 |
Code lines (lines that can run) | 68 |
Code lines that did run | 56 |
Code lines that did not run | 12 |
Coverage (did run/can run) | 82.35 % |
Function listing
time calls line
1 function [z,sorad]=soradna1(yd,yr,long,lat)
2 % SORADNA1: computes no-sky solar radiation and solar altitude.
3 % [z,sorad]=SORADNA1(yd,yr,long,lat) computes instantaneous values of
4 % solar radiation and solar altitude from yearday, year, and position
5 % data. It is put together from expressions taken from Appendix E in the
6 % 1978 edition of Almanac for Computers, Nautical Almanac Office, U.S.
7 % Naval Observatory. They are reduced accuracy expressions valid for the
8 % years 1800-2100. Solar declination computed from these expressions is
9 % accurate to at least 1'. The solar constant (1368.0 W/m^2) represents a
10 % mean of satellite measurements made over the last sunspot cycle (1979-1995)
11 % taken from Coffey et al (1995), Earth System Monitor, 6, 6-10. Assumes
12 % yd is either a column or row vector, the other input variables are scalars,
13 % OR yd is a scalar, the other inputs matrices.
14 % University of Maine Ocean Modelling Group http://rocky.umeoce.maine.edu/hjx/courses/SMS585/my2.5/air_sea/
15 % INPUT: yd - decimal yearday (e.g., 0000Z Jan 1 is 0.0)
16 % yr - year (e.g., 1995)
17 % long - longitude (west is positive!) [deg]
18 % lat - latitude [deg]
19 %
20 % OUTPUT: z - solar altitude [deg]
21 % sorad- no atmosphere solar radiation [W/m^2]
22
23 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
24 % 3/8/97: version 1.0
25 % 8/28/98: version 1.1 (vectorized by RP)
26 % 8/5/99: version 2.0
27 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28
29 % get constants
1 30 as_consts;
31
32 % convert yd to column vector if necessary
1 33 [n,m]=size(yd);
1 34 if m > n
35 yd=yd';
36 end
37
38 % convert yearday to calender time
0.02 1 39 gtime=greg2(yd,yr);
40
1 41 SC=gtime(:,6);
1 42 MN=fix(gtime(:,5));
1 43 HR=fix(gtime(:,4));
1 44 D=fix(gtime(:,3));
1 45 M=fix(gtime(:,2));
1 46 Y=fix(gtime(:,1));
47
48 % convert to new variables
1 49 LONG=long;
1 50 LAT=lat;
51
52 % two options - either long/lat are vectors, time is a scalar
53
1 54 if length(LONG)==1 & length(LAT)>1,
55 LONG=LONG(ones(size(LAT)));
1 56 elseif length(LONG)>1 & length(LAT)==1,
57 LAT=LAT(ones(size(LAT)));
58 end;
59
1 60 if length(SC)==1,
61 osiz=ones(size(LONG));
62 SC=SC(osiz);
63 MN=MN(osiz);
64 HR=HR(osiz);
65 D=D(osiz);
66 M=M(osiz);
67 Y=Y(osiz);
1 68 elseif length(LONG)==1,
1 69 LONG=LONG(ones(size(SC)));
1 70 LAT=LAT(ones(size(SC)));
1 71 end;
72
73 % constants
1 74 DTR=3.14159265/180;
1 75 RTD=1./DTR;
76
77 % compute Universal Time in hours
1 78 UT = HR+(MN+SC./60.)./60;
79
80 % compute Julian ephemeris date in days (Day 1 is 1 Jan 4713 B.C.=-4712 Jan 1)
1 81 JED=367.*Y-fix(7.*(Y+fix((M+9)./12))./4)+fix(275.*M./9)+D+1721013 + UT./24;
82
83 % compute interval in Julian centuries since 1900
1 84 T=(JED-2415020.0)./36525;
85
86 % compute mean anomaly of the sun
1 87 G=358.475833+35999.049750.*T-.000150.*T.^2;
1 88 NG=fix(G./360);
1 89 G=(G-NG.*360).*DTR;
90
91 % compute mean longitude of sun
1 92 L=279.696678+36000.768920.*T+.000303.*T.^2;
1 93 NL=fix(L./360);
1 94 L=(L-NL.*360).*DTR;
95
96 % compute mean anomaly of Jupiter
1 97 JUP=225.444651+2880.0.*T+154.906654.*T;
1 98 NJUP=fix(JUP/360);
1 99 JUP=(JUP-NJUP.*360).*DTR;
100
101 % compute longitude of the ascending node of the moon's orbit
1 102 NM=259.183275-1800.*T-134.142008.*T+.002078.*T.^2;
1 103 NNM=fix(NM./360);
1 104 NM=(NM-NNM.*360+360).*DTR;
105
106 % compute mean anomaly of Venus
1 107 V=212.603219+58320.*T+197.803875.*T+.001286.*T.^2;
1 108 NV=fix(V/360);
1 109 V=(V-NV.*360.).*DTR;
110
111 % compute sun theta
1 112 THETA=.397930.*sin(L)+.009999.*sin(G-L)+.003334.*sin(G+L)...
113 -.000208.*T.*sin(L)+.000042.*sin(2.*G+L)-.000040.*cos(L)...
114 -.000039.*sin(NM-L)-.000030.*T.*sin(G-L)-.000014.*sin(2.*G-L)...
115 -.000010.*cos(G-L-JUP)-.000010.*T.*sin(G+L);
116
117 % compute sun rho
1 118 RHO=1.000421-.033503.*cos(G)-.000140.*cos(2*G)...
119 +.000084.*T.*cos(G)-.000033.*sin(G-JUP)+.000027.*sin(2.*G-2.*V);
120
121 % compute declination
1 122 DECL=asin(THETA./sqrt(RHO));
123
124 % compute equation of time (in seconds of time) (L in degrees)
1 125 L = 276.697+0.98564734.*(JED-2415020.0);
1 126 L = (L - 360.*fix(L./360.)).*DTR;
1 127 EQT = -97.8.*sin(L)-431.3.*cos(L)+596.6.*sin(2.*L)-1.9.*cos(2.*L)...
128 +4.0.*sin(3.*L)+19.3.*cos(3.*L)-12.7.*sin(4.*L);
1 129 EQT = EQT./60;
1 130 L = L.*RTD;
131
132 % compute local hour angle
1 133 GHA = 15.*(UT-12.) + 15.*EQT./60;
1 134 LHA = GHA - LONG;
135
136 % compute radius vector
1 137 RV=sqrt(RHO);
138
139 % compute solar altitude
1 140 SZ=sin(DTR.*LAT).*sin(DECL)+cos(DTR.*LAT).*cos(DECL).*cos(DTR.*LHA);
1 141 z=RTD.*asin(SZ);
142
143 % compute solar radiation outside atmosphere
1 144 [n,m]=size(z);
1 145 sorad=zeros(n,m);
1 146 ii=z>0;
1 147 sorad(ii)=(Solar_const./RV(ii).^2).*sin(DTR.*z(ii));
Other subfunctions in this file are not included in this listing.