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
Incorrect AOI from pvlib.tracking.singleaxis #1221
Expected behavior
The AOI for the fixed tilt system shows values greater than 90 when the sun is behind the module plane. The AOI from singleaxis does not.
I think the source of the error is the use of abs in this line.
Screenshots
Versions:
pvlib.__version__: 0.8.1
First reported by email from Jim Wilzcak (NOAA) for the PVlib Matlab function pvl_singleaxis.m
Yes, my initial port of the matlab code was as close to 1:1 as I could make it. I don't recall second guessing the abs at the time, but I certainly should have.
@kanderso-nrel the shortcoming with using irradiance.aoi afaict is that it calls irradiance.aoi_projection which is redundant because the single axis tracker already calculates the solar vector and rotates it into the tracker reference frame to use the x and z components to calculate the tracker rotation.
COINCIDENTALLY, irradiance.aoi is already used in the SingleAzisTracker method get_aoi which afaict should be a static or class method because it NEVER uses self. I guess that's a separate issue. Anyway, it says this method isn't necessary, b/c singleaxis already returns AOI.
ALSO, I was thrown for a bit in irradiance.aoi_projection which doesn't have a lot of commentary, because when calculating the dot product of surface normal and solar vector, it shows z=cos(tilt)*cos(ze) first and x=sin(tilt)*sin(ze)*cos(az-surfaz) last. Whatever
Anyway, back to this, should we consider adjusting irradiance.aoi to allow the user to pass in the AOI projection as an alternate parameter? Seems a bit like a hacky workaround, but something like this:
# in irradiance.pydefaoi(surface_tilt, surface_azimuth, solar_zenith, solar_azimuth,
projection=None):
ifprojectionisNone:
projection=aoi_projection(
surface_tilt, surface_azimuth, solar_zenith, solar_azimuth)
# from here it's the sameaoi_value=np.rad2deg(np.arccos(projection))
...
then in singleaxis we change it to this:
# calculate angle-of-incidence on panel# aoi = np.degrees(np.arccos(np.abs(np.sum(sun_vec*panel_norm, axis=0))))projection= (xp*panel_norm[0]
+yp*panel_norm[1]
+zp*panel_norm[2])
# can't use np.dot for 2D matrices# expanding arrays is about 1.5x faster than sum# can skip sun_vec array formation, but still need panel norm for lateraoi=irradiance.aoi(None, None, None, None, projection=projection)
Activity
wholmgren commentedon May 7, 2021
I agree that
abslooks like a problem.mikofski commentedon May 12, 2021
This is an ancient line first committed April 3, 2015:
pvlib-python/pvlib/tracking.py
Line 219 in 46f69bf
wholmgren commentedon May 12, 2021
Yes, my initial port of the matlab code was as close to 1:1 as I could make it. I don't recall second guessing the
absat the time, but I certainly should have.cwhanse commentedon May 12, 2021
We (Dan and I) concluded that line is in error, in the matlab code.
kandersolar commentedon Aug 7, 2021
Should we just replace that entire line with a call to
irradiance.aoi?mikofski commentedon Aug 8, 2021
@kanderso-nrel the shortcoming with using
irradiance.aoiafaict is that it callsirradiance.aoi_projectionwhich is redundant because the single axis tracker already calculates the solar vector and rotates it into the tracker reference frame to use thexandzcomponents to calculate the tracker rotation.COINCIDENTALLY,
irradiance.aoiis already used in theSingleAzisTrackermethodget_aoiwhich afaict should be a static or class method because it NEVER uses self. I guess that's a separate issue. Anyway, it says this method isn't necessary, b/csingleaxisalready returns AOI.ALSO, I was thrown for a bit in
irradiance.aoi_projectionwhich doesn't have a lot of commentary, because when calculating the dot product of surface normal and solar vector, it showsz=cos(tilt)*cos(ze)first andx=sin(tilt)*sin(ze)*cos(az-surfaz)last. WhateverAnyway, back to this, should we consider adjusting
irradiance.aoito allow the user to pass in the AOI projection as an alternate parameter? Seems a bit like a hacky workaround, but something like this:then in
singleaxiswe change it to this:mikofski commentedon Aug 8, 2021
or maybe just to get this ball roling we use clip for now and just close it with a #TODO
mikofski commentedon Aug 8, 2021
FYI: the repro steps at the top are for a vertical tracker.
mikofski commentedon Aug 8, 2021
after #1273