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
Consider extracting the surface orientation calculation in pvlib.tracking.singleaxis() to its own function #1471
Is your feature request related to a problem? Please describe.
The usual workflow for modeling single-axis tracking in pvlib is to treat tracker rotation (tracker_theta) as an unknown to be calculated from solar position and array geometry. However, sometimes a user might have their own tracker rotations but not have the corresponding surface_tilt and surface_azimuth values. Here are a few motivating examples:
Using measured rotation angles
Post-processing the output of tracking.singleaxis() to include wind stow events or tracker stalls
Other tracking algorithms that determine rotation differently from the astronomical method
Assuming I have my tracker rotations already in hand, getting the corresponding surface_tilt and surface_azimuth angles is not as easy as it should be. For the specific case of horizontal N-S axis the math isn't so bad, but either way it's annoying to have to DIY when pvlib already has code to calculate those angles from tracker rotation.
Describe the solution you'd like
A function pvlib.tracking.rotation_to_orientation that implements the same math in pvlib.tracking.singleaxis to go from tracker_theta to surface_tilt and surface_azimuth. Basically extract out the second half of tracking.singleaxis into a new function. Suggestions for the function name are welcome. To be explicit, this is more or less what I'm imagining:
defrotation_to_orientation(tracker_theta, axis_tilt=0, axis_azimuth=0, max_angle=90):
# insert math from second half of tracking.singleaxis() hereout= {'tracker_theta': tracker_theta, 'aoi': aoi,
'surface_tilt': surface_tilt, 'surface_azimuth': surface_azimuth}
returnpandas_if_needed(out)
Describe alternatives you've considered
Continue suffering
Additional context
This is one step towards a broader goal I have for pvlib.tracking to house other methods to determine tracker rotation in addition to the current astronomical method, the same way we have multiple temperature and transposition models. These functions would be responsible for determining tracker rotations, and they'd all use this rotation_to_orientation function to convert rotation to module orientation.
Separately, I wonder if the code could be simplified using the tilt and azimuth equations in Bill's technical report (https://www.nrel.gov/docs/fy13osti/58891.pdf) -- seems like what we're doing is overly complicated, although maybe I've just not studied it closely enough.
@kanderso-nrel Nice meeting you at PVSC the other day. I've been working on this a bit using the tilt and azimuth equations in the technical report by Bill Marion mentioned. I would like to use this for the custom backtracking schedules Nevados generates for the terrain following trackers.
I have surface tilt working. It requires a dataframe df of axis tilt angles. I use the dataframe because Nevados has a different axis tilt for each bay in our tracker. stdf (surface tilt dataframe) starts as a dataframe of rotation angles (theta) indexed by timestep and is transformed into surface tilts. col.name is used to match the tracker and bay's rotation angle to their corresponding axis tilt.
Unfortunately I can't seem to get surface azimuth working correctly. sadf (surface angle data frame) is almost equal to surface azimuth as calculated by pvlib, but not quite in the middle of the day. ts2 is the output of pvlib.tracking.singleaxis
Thanks @kurt-rhee for this investigation. Trying some simple examples on my end, things seem to line up. Here's a complete copy/pasteable example where I get negligible difference between the current pvlib approach and your code. Note that I did replace the hard-coded axis_azimuth of 180 in the surface_azimuth calculation.
Oh interesting, thanks for pointing that out. Clearly for a tracker inclined slightly facing north as I interpret axis_tilt = -5 and axis_azimuth = 180 to mean, surface_azimuth should be 0/360 at solar noon. But negative axis tilt isn't something I've considered before. I've always thought of axis_tilt as being in the range [0, 90], and "negative" axis tilt is achieved by keeping axis_tilt positive and adding 180 to axis_azimuth. Bill's technical report defines axis tilt as being in [0, 90] as well.
As a point of reference, SAM/SSC claims MIN=0/MAX=90 for tilt as well, although "tilt" is overloaded there to refer to both fixed-tilt racking and SAT, so not an exact comparison. Interestingly though SAM does accept negative tilts for SAT simulations, and produces the same (incorrect) surface_azimuth curve:
@kurt-rhee do you think people will want to use pvlib with negative axis_tilt values? I'm wondering if this is a valid use case worth supporting or if we should just document that axis_tilt must be >= 0 and call it a day. I slightly object to negative axis_tilt on principle, but maybe that view isn't universal.
Thanks for that, very illuminating and clear as always. I think just a note in the documentation to keep axis_tilt >= 0 is enough. Better to keep 1 right way of doing things to avoid confusion.
Another thing I noticed about the calculation is that keeping axis_tilt positive and rotating axis azimuth by 180 degrees gives different answers using the Marion equations. This should be apparent given the below equation where azimuth is added to, but I was curious about the difference between pvlib's implementation and Marion's at axis azimuth >270 degrees. and <0 degrees.
The left column of these plots are surface angles calculated by pvlib, the right column are calculated by equations. The top row is at 0 degrees, the bottom row is at 360 degrees.
Activity
williamhobbs commentedon Jun 14, 2022
I like this.
This is related to an issue submitted for NREL SAM, NatLabRockies/SAM#850, and I think @mjprilliman is looking at something related.
kurt-rhee commentedon Jun 16, 2022
@kanderso-nrel Nice meeting you at PVSC the other day. I've been working on this a bit using the tilt and azimuth equations in the technical report by Bill Marion mentioned. I would like to use this for the custom backtracking schedules Nevados generates for the terrain following trackers.
I have surface tilt working. It requires a dataframe
dfof axis tilt angles. I use the dataframe because Nevados has a different axis tilt for each bay in our tracker. stdf (surface tilt dataframe) starts as a dataframe of rotation angles (theta) indexed by timestep and is transformed into surface tilts. col.name is used to match the tracker and bay's rotation angle to their corresponding axis tilt.Unfortunately I can't seem to get surface azimuth working correctly. sadf (surface angle data frame) is almost equal to surface azimuth as calculated by pvlib, but not quite in the middle of the day.
ts2is the output ofpvlib.tracking.singleaxiskandersolar commentedon Jun 17, 2022
Thanks @kurt-rhee for this investigation. Trying some simple examples on my end, things seem to line up. Here's a complete copy/pasteable example where I get negligible difference between the current pvlib approach and your code. Note that I did replace the hard-coded axis_azimuth of 180 in the surface_azimuth calculation.
Click to expand!
kandersolar commentedon Jun 17, 2022
Not that there was much doubt, but I've convinced myself that Bill's surface orientation equations are mathematically equivalent to the approach pvlib takes. Here are some notes if anyone is interested: https://gist.github.com/kanderso-nrel/ac3051de41261df317180c794144d6a9
If we do switch to Bill's equations we should be sure to preserve the handling of NaN and edge cases of the current implementation.
kurt-rhee commentedon Jun 18, 2022
I realize that my small error metric is due to a small timeshift that I had in my data that changed my answer when resampling / averaging.
Cheers
kurt-rhee commentedon Jul 5, 2022
@kanderso-nrel
I tried this code with a negative axis tilt and had some issues:
kurt-rhee commentedon Jul 5, 2022
@kanderso-nrel
Here is the difference between the two
Surface azimuth as calculated by pvlib in blue
Surface azimuth as calculated by the above script in orange
kandersolar commentedon Jul 6, 2022
Oh interesting, thanks for pointing that out. Clearly for a tracker inclined slightly facing north as I interpret
axis_tilt = -5andaxis_azimuth = 180to mean,surface_azimuthshould be 0/360 at solar noon. But negative axis tilt isn't something I've considered before. I've always thought ofaxis_tiltas being in the range [0, 90], and "negative" axis tilt is achieved by keepingaxis_tiltpositive and adding 180 toaxis_azimuth. Bill's technical report defines axis tilt as being in [0, 90] as well.As a point of reference, SAM/SSC claims
MIN=0/MAX=90for tilt as well, although "tilt" is overloaded there to refer to both fixed-tilt racking and SAT, so not an exact comparison. Interestingly though SAM does accept negative tilts for SAT simulations, and produces the same (incorrect)surface_azimuthcurve:@kurt-rhee do you think people will want to use pvlib with negative
axis_tiltvalues? I'm wondering if this is a valid use case worth supporting or if we should just document thataxis_tilt must be >= 0and call it a day. I slightly object to negativeaxis_tilton principle, but maybe that view isn't universal.kurt-rhee commentedon Jul 6, 2022
kurt-rhee commentedon Jul 6, 2022
Hey @kanderso-nrel,
Thanks for that, very illuminating and clear as always. I think just a note in the documentation to keep axis_tilt >= 0 is enough. Better to keep 1 right way of doing things to avoid confusion.
Another thing I noticed about the calculation is that keeping axis_tilt positive and rotating axis azimuth by 180 degrees gives different answers using the Marion equations. This should be apparent given the below equation where azimuth is added to, but I was curious about the difference between pvlib's implementation and Marion's at axis azimuth >270 degrees. and <0 degrees.
The left column of these plots are surface angles calculated by pvlib, the right column are calculated by equations. The top row is at 0 degrees, the bottom row is at 360 degrees.
williamhobbs commentedon Jul 6, 2022
I just submitted this issue for NREL SAM: NatLabRockies/SAM#1087.
cwhanse commentedon Jul 6, 2022
@kurt-rhee are all four of those surface_azimuth curves equivalent (once the angle is constrained to be in [0, 360))? Maybe I'm missing something.
kandersolar commentedon Jul 6, 2022
@kurt-rhee instead of the quick mockup code from earlier in this thread, I suggest testing the implementation in #1480: https://github.com/pvlib/pvlib-python/pull/1480/files#diff-85ef163d90257651a76daf9d07052201a78139739b429ea96947451caad3dfb8R470-R521
One relevant difference is that
surface_azimuthis constrained to [0, 360) as @cwhanse mentions.kurt-rhee commentedon Jul 6, 2022
@cwhanse They are equivalent! Thank you for pointing that out. Calculating POA using both methods gives slightly different answers.
@kanderso-nrel Nice, I will try that out right now.
kurt-rhee commentedon Jul 6, 2022
@kanderso-nrel Works perfectly!
kandersolar commentedon Jul 6, 2022
Great, thanks for checking! Any interest in submitting a PR for clarifying the >=0 requirement in the
pvlib.trackingdocstrings?kurt-rhee commentedon Jul 6, 2022
I would love to!