You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ambiguous descriptions of axis_azimuth and axis_tilt in pvlib.tracking.singleaxis() docs #1976
For a north-south aligned tracker axis, sloping 5 degrees down to the south, what are the inputs for axis_azimuth and axis_tilt? I assume axis_azimuth = 180, axis_tilt = 5.
For the same north-south aligned tracker axis, but sloping 5 degrees down to the north, what are the inputs? I assume axis_azimuth = 0, axis_tilt = 5, since axis_tilt must be >= 0.
Additionally, the description in the docs includes:
For example, if tracker axis_azimuth is 180 (oriented south) and axis_tilt is zero...
But the default for axis_azimuth is 0, which could lead to confusion around inputs and output sign convention.
Describe the solution you'd like
More clear docs.
Additional context
Changing definitions slightly and allowing for negative axis_tilt would make more sense to me, but maybe that causes other problems. [edit: now I don't think this is a good idea - see the full discussion below] [2nd edit: looks like code allows for this even though docs do not. Also, my opinion is easily swayed...]
For example # 2 above (sloping down to the North), allowing for axis_azimuth = 180, axis_tilt = -5 makes more since to me. You could unambigously define axis_azimuth as "the South-most direction of the axis of rotation" and axis_tilt as "the tilt of the axis of rotation, with positive values indicating downward slope towards the South-most direction, and negative values indicating downward slope towards the North-most direction...".
I'm not sure how to handle the odd case of a tracker axis aligned perfectly East-West.
And for systems in the Southern Hemisphere, I don't think anything would need to change.
Another argument for allowing negative axis tilt is to keep the common convention that rotation increases during the day, from negative in the morning when facing east to positive in the afternoon & trackers facing west. I think this only works if the axis points south?
Reacted by Will Hobbs, Adam R. Jensen and Mark Campanelli
Keeping a consistent rotation convention makes more sense to me than (the way I interpret) the existing docs for pvlib.tracking.singleaxis(): tracker_theta sign reverses depending on whether you pick 0 or 180 for axis_azimuth.
I just ran some tests in NREL SAM using both the detailed PV model and the PVWatts model - in both cases, it does not allow tilt for 1-axis trackers to be less than zero.
The documentation there is also not clear, but it appears that azimuth = 0 and tilt = 5 models a system sloping down to the north, while azimuth = 180 and tilt = 5 models a system sloping down to the south.
So, I can now see a benefit to keeping the conventions in pvlib.tracking.singleaxis() as they are and simply updating the docs a bit. But @mikofski's point about rotation angle convention is still a good one...
I left a comment on the SAM issue as well, but allowing negative input tilts would require some additional mathematical gymnastics inside the functions to make angle calculations and shading calculations work out (I'm assuming this is true for pvlib as well) - at the very least, transposition to the expected case before doing the math (i.e. if a user enters azimuth = 180, tilt = -5, the code would need to translate that to azimuth = 0, tilt = 5, then correctly re-translate the outputs). I have wondered about this issue of "how to explain which end of the tracker is the rotation around" before, since right now it follows mathematical rotational axis definitions, rather than cardinal direction conventions, that certainly aren't intuitive for most. Open to ideas here on the best way to communicate what tracker rotation angles mean...
Thanks @williamhobbs for linking the issues so we can brainstorm collectively! :)
Keeping conventions the same between pvlib and SAM seems like it would be very beneficial to users.
The rotation "convention" of negative in the morning, positive in the afternoon, would stay reversed in the case of sloping down to the North, but 1) this can be clarified in docs, and 2) is likely a pretty rare case. I think anyone that is modeling an atypical system like this and needs to carefully interpret tracker_theta is already pretty far into the "weeds" and can probable make sense of it all with decent docs.
@williamhobbs please just try it with negative axis_tilt and see if it works already as expected. I looked through the code here: https://github.com/pvlib/pvlib-python/blob/main/pvlib/tracking.py and I don’t see anything other than the docstring that limits it between zero and 90°. @janinefreeman I believe pvlib should just work even if axis tilt is negative without any changes at all because singleaxis() used arctan2 instead of cosine so should work in any quadrant.
I would vote in favor of allowing negative tilts, and thus allowing the standard convention of negative morning and positive evening tilts.
I could easily imagine simulations of larger systems (where the field is broken down into several sub-systems of uniform tilt) where one part of the field is sloping north and another is sloping south. In such a case it would be inconvenient having different axis azimuth conventions for different parts of the field.
Since negative values of axis_tilt are allowed in the code, it seems like users can use either convention and the docs simply need to be updated accordingly. And part of that is noting that if users select axis_azimuth between 270 and 90 (North-facing), the rotation angle convention is reversed.
I'm OK with negative axis tilt, as long as the definition of axis_tilt and axis_azimuth are not dependent on hemisphere, and together unambiguously define the coordinate system that defines rotation. I'd be opposed to start with a desired rotation convention (e.g. negative is east) because I'm fairly sure that will make the coordinate system depend on hemisphere.
Taking the above discussion into account, if we specify an axis_azimuth of 0 and an axis_tilt of -5, what does that mean in terms of the positioning of the trackers?
From the way the docstring is currently worded The tilt of the axis of rotation (i.e, the y-axis defined by axis_azimuth) with respect to horizontal.
seems like it would be a confusing situation where we specify that the azimuth is 0 (point towards north), but also specify that there is a -5 degree tilt, meaning that the slope is actually towards the south?
I set up what I think is a typical computational workflow using the ground slope, slope azimuth, and axis azimuth to first compute the axis tilt and cross-axis tilt using pvlib.tracking.calc_axis_tilt and pvlib.tracking.calc_cross_axis_tilt, respectively. Then, these values were fed into pvlib.tracking.singleaxis. I tried to set up the same geometry (here, a northern hemisphere setup with the array axis sloping away from the equator), using the two 180-degree opposing choices for axis azimuth. I see the expected change in sign for the rotation angles, but the computations from pvlib.tracking.singleaxis appear to be different (esp. different AOIs). I think they should have been the same, but I may be missing something.
@markcampanelli, I'm seeing similar behavior. When I previously tried "flipping around" the azimuth and tilt, I only looked at tracker theta, not AOI and surface orientation. That doesn't seem expected.
AOI looks wrong for tilt=-10 because the calculation of AOI relies on tracking.calc_surface_orientation which converts axis_tilt to the usual pvlib interpretation of tilt, i.e., a positive angle from horizontal that is ignorant of azimuth. If negative axis_tilt is not to be forbidden, this line needs to be corrected:
@cwhanse Would you agree that that the addition here of the axis_azimuth ALSO defining a rotation axis is what makes this geometric situation more complex so that "the usual pvlib interpretation of tilt, i.e., a positive angle from horizontal that is ignorant of azimuth" is insufficient?
One piece of info on existing implementation, which may be redundant at this point: Using calc_surface_orientation in singleaxis appears to make an arbitrary choice for surface_azimuth when a "typical" tracker configuration is pointing straight up. Wouldn't the mathematically correct thing to do here be to define such azimuths as NaN? (I haven't thought of a more elegant way to "define" our way out of this "discontinuity".)
axis_azimuth=0 gives surface_azimuth=90 when surface_tilt=0:
@markcampanelli I wonder if returning nan would be annoying in workflows that process surface_azimuth although I don't have an example where that would be the case. I'm slightly in favor of returning axis_azimuth.
@markcampanelli I wonder if returning nan would be annoying in workflows that process surface_azimuth although I don't have an example where that would be the case. I'm slightly in favor of returning axis_azimuth.
@cwhanse To avoid the honest, yet pesky, NaN for surface_azimuth, that seems like a good idea to use the axis_azimuth, which I think can be viewed as the well-defined limiting case of surface_tilt -> 0^+. (I think the limit needs to be one-sided to be generally well defined.) 🙂
I have to admit to just now fully reading the paper referenced in calc_surface_orientation, but just looking through the existing code suggests a way to avoid the division by zero altogether, which is where the arbitrary choice is made and which is essentially being checked for twice in the existing code:
defcalc_surface_orientation(tracker_theta, axis_tilt=0, axis_azimuth=0):
"""Avoid any division by zero."
tracker_theta=np.asanyarray(tracker_theta)
surface_tilt=acosd(cosd(tracker_theta) *cosd(axis_tilt))
# axis_azimuth is the arbitrary surface_azimuth when surface_tilt is zero.surface_azimuth=np.full_like(surface_tilt, axis_azimuth)
nonzero_surface_tilt_idx=surface_tilt!=0ifnp.any(nonzero_surface_tilt_idx):
# clip(..., -1, +1) to prevent arcsin(1 + epsilon) issues:azimuth_delta=asind(
np.clip(
sind(tracker_theta[nonzero_surface_tilt_idx]) /sind(surface_tilt[nonzero_surface_tilt_idx]),
a_min=-1,
a_max=1,
)
)
# Combine Eqs 2, 3, and 4:azimuth_delta=np.where(
abs(tracker_theta[nonzero_surface_tilt_idx]) <90,
azimuth_delta,
-azimuth_delta+np.sign(tracker_theta[nonzero_surface_tilt_idx]) *180)
surface_azimuth[nonzero_surface_tilt_idx] = (axis_azimuth[nonzero_surface_tilt_idx] +azimuth_delta) %360out= {
'surface_tilt': surface_tilt,
'surface_azimuth': surface_azimuth,
}
ifhasattr(tracker_theta, 'index'):
out=pd.DataFrame(out)
returnout
UPDATE: I think the tracker_theta = np.asanyarray(tracker_theta) breaks the pandas integration, but could be worked around. Always the pandas integration... ☹️
@markcampanelli thanks for the suggestion. There are two issues to address: accepting axis_tilt<0, and choosing surface_azimuth when surface_tilt=0. That method still yields incorrect surface_azimuth for negative axis_tilt. I think the reference's use of triangles is the underlying cause. The authors state that axis_azimuth is the direction when viewing the tracker axis from when the inclined end. That's 180 out from axis_azimuth when axis_tilt is negative. In my view, creating some if/then's to handle this case, and revisiting the trigonometry to respect all four quadrants, deviates enough from the reference that I don't think pvlib should claim to implement that computation approach. Also in my view, an approach based on 3d rotations is easier to follow and to maintain. See #2702
My two cents is that for surface_tilt=0 I prefer to choose surface_azimuth = axis_azimuth +/- 90 over axis_azimuth. Let's say I have this rectangle that I can draw in 3D as a function of surface_tilt and surface_azimuth. There would be a discontinuity at surface_tilt=0 in which this rectangle would switch longest and shortest sides. The logic I propose is surface_azimuth = np.mod(axis_azimuth + 90, 360)
@echedey-ls I'm afraid I don't follow. If you are rotating a rectangle with fixed surface_azimuth and decreasing surface_tilt, how does axis_aximuth enter?
The hypothetical situation I propose is probably just that, hypothetical. That was the first thing that came to my mind to illustrate that the fact that surface_azimut=axis_azimuth is probably unexpected in some cases as it is completely different from the neighboring values axis_azimuth +/- 90 in the typical HSAT case.
The workflow is the following: theta (variable), axis_azimuth (fixed) and axis_tilt (fixed) are inputs to pvlib.tracking.calc_surface_orientation. Surface's azimuth and tilt are obtained, and they are then used to draw this rectangle.
For non-zero thetas:
-20
-10
10
20
But for theta=0:
Code
Search for theta = and change it:
importmatplotlib.pyplotaspltimportnumpyasnpfromscipy.spatial.transformimportRotation# from pvlib.tracking import calc_surface_orientationfrompvlib.toolsimportacosd, cosd, sinddef_unit_normal(axis_azimuth, axis_tilt, theta):
theta=np.asarray(theta)
cA, sA=cosd(-axis_azimuth), sind(-axis_azimuth)
cT, sT=cosd(-axis_tilt), sind(-axis_tilt)
cTh=cosd(theta)
sTh=sind(theta)
x=sA*sT*cTh+cA*sThy=sA*sTh-cA*sT*cThz=cT*cThresult=np.column_stack((x, y, z))
returnresultdefcalc_surface_orientation(tracker_theta, axis_tilt=0, axis_azimuth=0):
withnp.errstate(invalid="ignore", divide="ignore"):
surface_tilt=acosd(cosd(tracker_theta) *cosd(axis_tilt))
# unit normal to rotated tracker surfaceunit_normal=_unit_normal(axis_azimuth, axis_tilt, tracker_theta)
# deviate from [1] to allow for negative tilt.# project unit_normal to x-y plane to calculate azimuthsurface_azimuth=np.degrees(np.arctan2(unit_normal[:, 0], unit_normal[:, 1]))
# constrain angles to [0, 360)surface_azimuth=np.mod(surface_azimuth, 360.0)
surface_azimuth=np.where(surface_tilt==0.0, axis_azimuth, surface_azimuth)
out= {
"surface_tilt": surface_tilt,
"surface_azimuth": surface_azimuth,
}
ifhasattr(tracker_theta, "index"):
out=pd.DataFrame(out)
returnoutplt.interactive(True)
# Create rectangle vertices (10 in x, 20 in y)x=np.array([-5, 5, 5, -5, -5]) # Close the loop by repeating first pointy=np.array([-10, -10, 10, 10, -10])
z=np.zeros_like(x)
# Stack coordinatespoints=np.vstack([x, y, z])
theta=0axis_azimuth=180axis_tilt=0surface_orientation=calc_surface_orientation(
theta, axis_tilt=axis_tilt, axis_azimuth=axis_azimuth
)
surface_azimuth=surface_orientation["surface_azimuth"][0]
surface_tilt=surface_orientation["surface_tilt"]
# Apply rotations# surface_azimuth = 90# surface_tilt = 30rot=Rotation.from_euler(
"ZX", [-surface_azimuth, -surface_tilt], degrees=True
)
points_rot1=rot.apply(points.T).T# Extract rotated coordinatesx_rot, y_rot, z_rot=points_rot1# Create the figure and 3D axisfig=plt.figure(figsize=(10, 8))
ax=fig.add_subplot(111, projection="3d")
# Plot wireframe (connect the vertices in order)ax.plot(x_rot, y_rot, z_rot, "b-", linewidth=2, label="Rectangle wireframe")
# The rectangle is defined by 4 vertices, we've already closed the loop# Additional lines for the rectangle structureforiinrange(4):
ax.plot(
[x_rot[i], x_rot[(i+1) %4]],
[y_rot[i], y_rot[(i+1) %4]],
[z_rot[i], z_rot[(i+1) %4]],
"b-",
linewidth=2,
)
# Set labelsax.set_xlabel("> to East")
ax.set_ylabel("< to North")
# Set equal aspect ratioax.set_box_aspect([1, 1, 1])
# Position camera to look towards Y+ direction (North)# Matplotlib convention differs from pvlib'sax.view_init(elev=30, azim=-90)
# Set limits to show the rectangle properlymax_range=20ax.set_xlim(-max_range/2-5, max_range/2+5)
ax.set_ylim(-max_range/2-5, max_range/2+5)
ax.set_zlim(-max_range/2-5, max_range/2+5)
ax.set_title(
f"Rectangle 10x20\nRotated: {surface_azimuth=:.0f}°, {surface_tilt=:.0f}°\n""Camera facing North"
)
plt.show(block=True)
Disclaimer: I don't think anybody should ever take this approach for drawing 3D PV scenes, but I can't guarantee nobody will. Note the code above is only valid for axis_tilt=0. I haven't had the energy to fix it for non-zero values.
This example is just for the purpose of illustrating that picking this value may introduce unwanted discontinuities into the dataflow.
TL:DR there's no unique way to define surface_azimuth when surface_tilt=0. But the common use case suggests either surface_azimuth = axis_azimuth - 90 or surface_azimuth = axis_azimuth + 90. I propose pvlib returns surface_azimuth = axis_azimuth - 90 instead of axis_azimuth.
Long story:
surface_tilt = acosd(cosd(tracker_theta) * cosd(axis_tilt)) so the only way that surface_tilt = 0 is if both cos(tracker_theta)=1 and cos(axis_tilt)=1, i.e, both surface_tilt=0 and tracker_theta=0.
If axis_tilt is not 0, then surface_tilt is never zero - a tilted axis tracker can never position the array horizontal.
If either axis_tilt or tracker_theta are fixed at 0, then we can consider limits as the other angle approaches zero to decide what to return when both are zero. I posit that fixing axis_tilt==0 is far more common than tracker_theta==0 (why have a tracker that fixes the torque tube in rotation, and elevates the tube)?
If axis_tilt=0 then the equation for surface azimuth simplifies to
Activity
mikofski commentedon Feb 20, 2024
Another argument for allowing negative axis tilt is to keep the common convention that rotation increases during the day, from negative in the morning when facing east to positive in the afternoon & trackers facing west. I think this only works if the axis points south?
williamhobbs commentedon Feb 20, 2024
@mikofski, I agree. Good point.
Keeping a consistent rotation convention makes more sense to me than (the way I interpret) the existing docs for
pvlib.tracking.singleaxis(): tracker_theta sign reverses depending on whether you pick 0 or 180 for axis_azimuth.williamhobbs commentedon Feb 20, 2024
I just ran some tests in NREL SAM using both the detailed PV model and the PVWatts model - in both cases, it does not allow tilt for 1-axis trackers to be less than zero.
The documentation there is also not clear, but it appears that azimuth = 0 and tilt = 5 models a system sloping down to the north, while azimuth = 180 and tilt = 5 models a system sloping down to the south.
So, I can now see a benefit to keeping the conventions in
pvlib.tracking.singleaxis()as they are and simply updating the docs a bit. But @mikofski's point about rotation angle convention is still a good one...janinefreeman commentedon Feb 20, 2024
I left a comment on the SAM issue as well, but allowing negative input tilts would require some additional mathematical gymnastics inside the functions to make angle calculations and shading calculations work out (I'm assuming this is true for pvlib as well) - at the very least, transposition to the expected case before doing the math (i.e. if a user enters azimuth = 180, tilt = -5, the code would need to translate that to azimuth = 0, tilt = 5, then correctly re-translate the outputs). I have wondered about this issue of "how to explain which end of the tracker is the rotation around" before, since right now it follows mathematical rotational axis definitions, rather than cardinal direction conventions, that certainly aren't intuitive for most. Open to ideas here on the best way to communicate what tracker rotation angles mean...
Thanks @williamhobbs for linking the issues so we can brainstorm collectively! :)
williamhobbs commentedon Feb 20, 2024
Keeping conventions the same between pvlib and SAM seems like it would be very beneficial to users.
The rotation "convention" of negative in the morning, positive in the afternoon, would stay reversed in the case of sloping down to the North, but 1) this can be clarified in docs, and 2) is likely a pretty rare case. I think anyone that is modeling an atypical system like this and needs to carefully interpret tracker_theta is already pretty far into the "weeds" and can probable make sense of it all with decent docs.
mikofski commentedon Feb 20, 2024
@williamhobbs please just try it with negative
axis_tiltand see if it works already as expected. I looked through the code here: https://github.com/pvlib/pvlib-python/blob/main/pvlib/tracking.py and I don’t see anything other than the docstring that limits it between zero and 90°. @janinefreeman I believe pvlib should just work even if axis tilt is negative without any changes at all becausesingleaxis()usedarctan2instead of cosine so should work in any quadrant.AdamRJensen commentedon Feb 20, 2024
I would vote in favor of allowing negative tilts, and thus allowing the standard convention of negative morning and positive evening tilts.
I could easily imagine simulations of larger systems (where the field is broken down into several sub-systems of uniform tilt) where one part of the field is sloping north and another is sloping south. In such a case it would be inconvenient having different axis azimuth conventions for different parts of the field.
williamhobbs commentedon Feb 20, 2024
@mikofski you are correct, it works with negative axis_tilt.
(edit: code below)
williamhobbs commentedon Feb 20, 2024
Since negative values of axis_tilt are allowed in the code, it seems like users can use either convention and the docs simply need to be updated accordingly. And part of that is noting that if users select axis_azimuth between 270 and 90 (North-facing), the rotation angle convention is reversed.
cwhanse commentedon Feb 20, 2024
I'm OK with negative axis tilt, as long as the definition of axis_tilt and axis_azimuth are not dependent on hemisphere, and together unambiguously define the coordinate system that defines rotation. I'd be opposed to start with a desired rotation convention (e.g. negative is east) because I'm fairly sure that will make the coordinate system depend on hemisphere.
matsuobasho commentedon Mar 19, 2024
Taking the above discussion into account, if we specify an
axis_azimuthof 0 and anaxis_tiltof -5, what does that mean in terms of the positioning of the trackers?From the way the docstring is currently worded
The tilt of the axis of rotation (i.e, the y-axis defined by axis_azimuth) with respect to horizontal.seems like it would be a confusing situation where we specify that the azimuth is 0 (point towards north), but also specify that there is a -5 degree tilt, meaning that the slope is actually towards the south?
markcampanelli commentedon Feb 12, 2026
I set up what I think is a typical computational workflow using the ground slope, slope azimuth, and axis azimuth to first compute the axis tilt and cross-axis tilt using
pvlib.tracking.calc_axis_tiltandpvlib.tracking.calc_cross_axis_tilt, respectively. Then, these values were fed intopvlib.tracking.singleaxis. I tried to set up the same geometry (here, a northern hemisphere setup with the array axis sloping away from the equator), using the two 180-degree opposing choices for axis azimuth. I see the expected change in sign for the rotation angles, but the computations frompvlib.tracking.singleaxisappear to be different (esp. different AOIs). I think they should have been the same, but I may be missing something.First representation:
Outputs:
pvlib.tracking.calc_axis_tilt: -10.0°
pvlib.tracking.calc_cross_axis_tilt: -0.0°
pvlib.tracking.singleaxis:
Second representation:
Outputs:
pvlib.tracking.calc_axis_tilt : 10.0°
pvlib.tracking.calc_cross_axis_tilt: 0.0°
williamhobbs commentedon Feb 12, 2026
@markcampanelli, I'm seeing similar behavior. When I previously tried "flipping around" the azimuth and tilt, I only looked at tracker theta, not AOI and surface orientation. That doesn't seem expected.
cwhanse commentedon Feb 13, 2026
AOI looks wrong for tilt=-10 because the calculation of AOI relies on
tracking.calc_surface_orientationwhich convertsaxis_tiltto the usual pvlib interpretation of tilt, i.e., a positive angle from horizontal that is ignorant of azimuth. If negativeaxis_tiltis not to be forbidden, this line needs to be corrected:pvlib-python/pvlib/tracking.py
Line 246 in bba49c0
markcampanelli commentedon Feb 14, 2026
@cwhanse Would you agree that that the addition here of the axis_azimuth ALSO defining a rotation axis is what makes this geometric situation more complex so that "the usual pvlib interpretation of tilt, i.e., a positive angle from horizontal that is ignorant of azimuth" is insufficient?
11 remaining items
markcampanelli commentedon Mar 9, 2026
One piece of info on existing implementation, which may be redundant at this point: Using
calc_surface_orientationinsingleaxisappears to make an arbitrary choice forsurface_azimuthwhen a "typical" tracker configuration is pointing straight up. Wouldn't the mathematically correct thing to do here be to define such azimuths asNaN? (I haven't thought of a more elegant way to "define" our way out of this "discontinuity".)axis_azimuth=0givessurface_azimuth=90whensurface_tilt=0:axis_azimuth=180givessurface_azimuth=270whensurface_tilt=0:cwhanse commentedon Mar 9, 2026
@markcampanelli I wonder if returning
nanwould be annoying in workflows that processsurface_azimuthalthough I don't have an example where that would be the case. I'm slightly in favor of returningaxis_azimuth.markcampanelli commentedon Mar 9, 2026
@cwhanse To avoid the honest, yet pesky,
NaNforsurface_azimuth, that seems like a good idea to use theaxis_azimuth, which I think can be viewed as the well-defined limiting case ofsurface_tilt-> 0^+. (I think the limit needs to be one-sided to be generally well defined.) 🙂I have to admit to just now fully reading the paper referenced in
calc_surface_orientation, but just looking through the existing code suggests a way to avoid the division by zero altogether, which is where the arbitrary choice is made and which is essentially being checked for twice in the existing code:UPDATE: I think the☹️
tracker_theta = np.asanyarray(tracker_theta)breaks the pandas integration, but could be worked around. Always the pandas integration...cwhanse commentedon Mar 11, 2026
@markcampanelli thanks for the suggestion. There are two issues to address: accepting
axis_tilt<0, and choosingsurface_azimuthwhensurface_tilt=0. That method still yields incorrectsurface_azimuthfor negativeaxis_tilt. I think the reference's use of triangles is the underlying cause. The authors state thataxis_azimuthis the direction when viewing the tracker axis from when the inclined end. That's 180 out fromaxis_azimuthwhenaxis_tiltis negative. In my view, creating some if/then's to handle this case, and revisiting the trigonometry to respect all four quadrants, deviates enough from the reference that I don't think pvlib should claim to implement that computation approach. Also in my view, an approach based on 3d rotations is easier to follow and to maintain. See #2702echedey-ls commentedon Apr 2, 2026
My two cents is that for
surface_tilt=0I prefer to choosesurface_azimuth = axis_azimuth +/- 90overaxis_azimuth. Let's say I have this rectangle that I can draw in 3D as a function ofsurface_tiltandsurface_azimuth. There would be a discontinuity atsurface_tilt=0in which this rectangle would switch longest and shortest sides. The logic I propose issurface_azimuth = np.mod(axis_azimuth + 90, 360)cwhanse commentedon Apr 2, 2026
@echedey-ls I'm afraid I don't follow. If you are rotating a rectangle with fixed
surface_azimuthand decreasingsurface_tilt, how doesaxis_aximuthenter?echedey-ls commentedon Apr 2, 2026
The hypothetical situation I propose is probably just that, hypothetical. That was the first thing that came to my mind to illustrate that the fact that
surface_azimut=axis_azimuthis probably unexpected in some cases as it is completely different from the neighboring valuesaxis_azimuth +/- 90in the typical HSAT case.The workflow is the following:
theta(variable),axis_azimuth(fixed) andaxis_tilt(fixed) are inputs topvlib.tracking.calc_surface_orientation. Surface's azimuth and tilt are obtained, and they are then used to draw this rectangle.For non-zero
thetas:But for
theta=0:Code
Search for
theta =and change it:Disclaimer: I don't think anybody should ever take this approach for drawing 3D PV scenes, but I can't guarantee nobody will. Note the code above is only valid for
axis_tilt=0. I haven't had the energy to fix it for non-zero values.This example is just for the purpose of illustrating that picking this value may introduce unwanted discontinuities into the dataflow.
cwhanse commentedon Apr 2, 2026
Thanks, I understand your point now. Thinking...
cwhanse commentedon Apr 5, 2026
TL:DR there's no unique way to define
surface_azimuthwhensurface_tilt=0. But the common use case suggests eithersurface_azimuth = axis_azimuth - 90orsurface_azimuth = axis_azimuth + 90. I propose pvlib returnssurface_azimuth = axis_azimuth - 90instead ofaxis_azimuth.Long story:
surface_tilt = acosd(cosd(tracker_theta) * cosd(axis_tilt))so the only way thatsurface_tilt = 0is if bothcos(tracker_theta)=1andcos(axis_tilt)=1, i.e, bothsurface_tilt=0andtracker_theta=0.If
axis_tiltis not 0, thensurface_tiltis never zero - a tilted axis tracker can never position the array horizontal.If either
axis_tiltortracker_thetaare fixed at 0, then we can consider limits as the other angle approaches zero to decide what to return when both are zero. I posit that fixingaxis_tilt==0is far more common thantracker_theta==0(why have a tracker that fixes the torque tube in rotation, and elevates the tube)?If
axis_tilt=0then the equation for surface azimuth simplifies tosurface_azimuth = atan2(cos(-axis_azimuth) * sin(theta), sin(-axis_azimuth) * sin(theta))Reminder: axis_azimuth is negated in the conversion from azimuth to a rotation angle about the z-azis.
Considering the limit as
theta-> 0+ (from the positive side) yieldssurface_azimuth = axis_azimuth - 90.As
theta-> 0-, the script flips toaxis_azimuth + 90.Arbitrarily, I suggest we choose
surface_azimuth = axis_azimuth - 90.echedey-ls commentedon Apr 7, 2026
@cwhanse thanks for bringing clarity to my comment, that's exactly what I meant.
kandersolar commentedon Apr 7, 2026
I am +1 to
surface_azimuth = axis_azimuth ± 90and have no preference between them.