Skip to content

Commit 24af13d

Browse files
committed
line length fixes to comments and docs
1 parent 46f69bf commit 24af13d

File tree

1 file changed

+48
-33
lines changed

1 file changed

+48
-33
lines changed

pvlib/tracking.py

Lines changed: 48 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ def singleaxis(SunZen, SunAz, Latitude=1,
1919
required.
2020
2121
Rotation angle is determined in a panel-oriented coordinate system.
22-
The tracker azimuth AxisAzimuth defines the positive y-axis; the positive
23-
x-axis is 90 degress clockwise from the y-axis and parallel to the
24-
earth surface, and the positive z-axis is normal and oriented towards the sun.
22+
The tracker azimuth AxisAzimuth defines the positive y-axis;
23+
the positive x-axis is 90 degress clockwise from the y-axis
24+
and parallel to the earth surface, and the positive z-axis is
25+
normal and oriented towards the sun.
2526
Rotation angle TrkrTheta indicates tracker position relative to horizontal:
2627
TrkrTheta = 0 is horizontal, and positive TrkrTheta is a clockwise rotation
27-
around the y axis in the x, y, z coordinate system. For example, if tracker azimuth
28-
AxisAzimuth is 180 (oriented south), TrkrTheta = 30 is a rotation of
29-
30 degrees towards the west, and TrkrTheta = -90 is a rotation to the
30-
vertical plane facing east.
28+
around the y axis in the x, y, z coordinate system.
29+
For example, if tracker azimuth AxisAzimuth is 180 (oriented south),
30+
TrkrTheta = 30 is a rotation of 30 degrees towards the west,
31+
and TrkrTheta = -90 is a rotation to the vertical plane facing east.
3132
3233
Parameters
3334
----------
@@ -97,7 +98,7 @@ def singleaxis(SunZen, SunAz, Latitude=1,
9798

9899
pvl_logger.debug('tracking.singleaxis')
99100

100-
# initial matlab to python conversion by
101+
# MATLAB to Python conversion by
101102
# Will Holmgren, U. Arizona, March, 2015. @wholmgren
102103

103104
# Calculate sun position x, y, z using coordinate system as in [1], Eq 2.
@@ -109,7 +110,8 @@ def singleaxis(SunZen, SunAz, Latitude=1,
109110
# Equations in [1] assume solar azimuth is relative to reference vector
110111
# pointed south, with clockwise positive. Here, the input solar azimuth
111112
# is degrees East of North, i.e., relative to a reference vector pointed
112-
# north with clockwise positive. Rotate sun azimuth to coordinate system as in [1]
113+
# north with clockwise positive.
114+
# Rotate sun azimuth to coordinate system as in [1]
113115
# to calculate sun position.
114116

115117
times = SunAz.index
@@ -123,27 +125,30 @@ def singleaxis(SunZen, SunAz, Latitude=1,
123125
# translate array azimuth from compass bearing to [1] coord system
124126
AxisAz = AxisAzimuth - 180
125127

126-
# translate input array tilt angle axistilt to [1] coordinate system. In
127-
# [1] coordinates, axistilt is a rotation about the x-axis. For a system
128-
# with array azimuth (y-axis) oriented south, the x-axis is oriented west,
129-
# and a positive axistilt is a counterclockwise rotation, i.e, lifting the
130-
# north edge of the panel. Thus, in [1] coordinate system, in the northern
131-
# hemisphere a positive axistilt indicates a rotation toward the equator,
128+
# translate input array tilt angle axistilt to [1] coordinate system.
129+
130+
# In [1] coordinates, axistilt is a rotation about the x-axis.
131+
# For a system with array azimuth (y-axis) oriented south,
132+
# the x-axis is oriented west, and a positive axistilt is a
133+
# counterclockwise rotation, i.e, lifting the north edge of the panel.
134+
# Thus, in [1] coordinate system, in the northern hemisphere a positive
135+
# axistilt indicates a rotation toward the equator,
132136
# whereas in the southern hemisphere rotation toward the equator is
133-
# indicated by axistilt<0. Here, the input axistilt is always positive and
134-
# is a rotation toward the equator.
137+
# indicated by axistilt<0. Here, the input axistilt is
138+
# always positive and is a rotation toward the equator.
135139

136140
# Calculate sun position (xp, yp, zp) in panel-oriented coordinate system:
137141
# positive y-axis is oriented along tracking axis at panel tilt;
138142
# positive x-axis is orthogonal, clockwise, parallel to earth surface;
139143
# positive z-axis is normal to x-y axes, pointed upward.
140144
# Calculate sun position (xp,yp,zp) in panel coordinates using [1] Eq 11
145+
# note that equation for yp (y' in Eq. 11 of Lorenzo et al 2011) is
146+
# corrected, after conversation with paper's authors.
147+
141148
xp = x*cosd(AxisAz) - y*sind(AxisAz);
142149
yp = (x*cosd(AxisTilt)*sind(AxisAz) +
143150
y*cosd(AxisTilt)*cosd(AxisAz) -
144151
z*sind(AxisTilt))
145-
# note that equation for yp (y' in Eq. 11 of Lorenzo et al 2011) is
146-
# corrected, after conversation with paper's authors
147152
zp = (x*sind(AxisTilt)*sind(AxisAz) +
148153
y*sind(AxisTilt)*cosd(AxisAz) +
149154
z*cosd(AxisTilt))
@@ -160,11 +165,15 @@ def singleaxis(SunZen, SunAz, Latitude=1,
160165
# can we use atan2?
161166

162167
# filter to avoid undefined inverse tangent
163-
#tmp(xp~=0) = atand(zp./xp) # angle from x-y plane to projection of sun vector onto x-z plane
164-
tmp = np.degrees(np.arctan(zp/xp)) # angle from x-y plane to projection of sun vector onto x-z plane
168+
169+
# angle from x-y plane to projection of sun vector onto x-z plane
170+
#tmp(xp~=0) = atand(zp./xp)
171+
# angle from x-y plane to projection of sun vector onto x-z plane
172+
tmp = np.degrees(np.arctan(zp/xp))
165173
#tmp(xp==0 & zp>=0) = 90 # fill in when atan is undefined
166174
#tmp(xp==0 & zp<0) = -90 # fill in when atan is undefined
167175
#tmp=tmp(:); # ensure tmp is a column vector
176+
168177
# Obtain wid by translating tmp to convention for rotation angles.
169178
# Have to account for which quadrant of the x-z plane in which the sun
170179
# vector lies. Complete solution here but probably not necessary to
@@ -188,7 +197,11 @@ def singleaxis(SunZen, SunAz, Latitude=1,
188197
pvl_logger.debug('applying backtracking')
189198
Lew = 1/GCR
190199
temp = np.minimum(Lew*cosd(wid), 1)
191-
wc = np.degrees(np.arccos(temp)) # backtrack angle; always positive (acosd returns values between 0 and 180)
200+
201+
# backtrack angle
202+
# (always positive b/c acosd returns values between 0 and 180)
203+
wc = np.degrees(np.arccos(temp))
204+
192205
v = wid < 0
193206
widc = pd.Series(index=times)
194207
widc[~v] = wid[~v] - wc[~v]; # Eq 4 applied when wid in QI
@@ -219,25 +232,27 @@ def singleaxis(SunZen, SunAz, Latitude=1,
219232
AOI = np.degrees(np.arccos(np.abs(np.sum(P*Norm, axis=0))))
220233
#AOI(~u) = 0 # set to zero when sun is below panel horizon
221234

222-
# calculate panel elevation SurfEl and azimuth SurfAz in a coordinate system where the
223-
# panel elevation is the angle from horizontal, and the panel azimuth is
224-
# the compass angle (clockwise from north) to the projection of the panel's
225-
# normal to the earth's surface. These outputs are provided for
226-
# convenience and comparison with other PV software which use these angle
227-
# conventions.
235+
# calculate panel elevation SurfEl and azimuth SurfAz
236+
# in a coordinate system where the panel elevation is the
237+
# angle from horizontal, and the panel azimuth is
238+
# the compass angle (clockwise from north) to the projection
239+
# of the panel's normal to the earth's surface.
240+
# These outputs are provided for convenience and comparison
241+
# with other PV software which use these angle conventions.
228242

229-
# project normal vector to earth surface. First rotate
230-
# about x-axis by angle -AxisTilt so that y-axis is also parallel to earth
231-
# surface, then project.
232-
#rotation matrix
243+
# project normal vector to earth surface.
244+
# First rotate about x-axis by angle -AxisTilt so that y-axis is
245+
# also parallel to earth surface, then project.
246+
247+
# Calculate standard rotation matrix
233248
Rot_x = np.array([[1, 0, 0],
234249
[0, cosd(-AxisTilt), -sind(-AxisTilt)],
235250
[0, sind(-AxisTilt), cosd(-AxisTilt)]])
236251

237252
# temp contains the normal vector expressed in earth-surface coordinates
238253
# (z normal to surface, y aligned with tracker axis parallel to earth)
239254
temp = np.dot(Rot_x, Norm)
240-
temp = temp.T # ensure column format
255+
temp = temp.T
241256

242257
# projection to plane tangent to earth surface,
243258
# in earth surface coordinates

0 commit comments

Comments
 (0)