# Solar panel angle to the Sun

• I

## Main Question or Discussion Point

Moved into a house with some solar panels facing due south and some facing due west. Our latitude is 33.8 North in California. We are in the Mojave desert with very little cloud cover. The angle of the roof is 22 degrees from horizontal.

What is the equation that will accept the azimuth and elevation of the sun, combine with the azimuth and elevation of the panels, and determine the angle of the sun from the solar panel perpendicular.

Everything found so far requires two vectors. This is not two vectors, it is two angles.

For example suppose some hours after solar local noon when the sun is at 45 degrees azimuth from the south and be 40 degrees from horizontal. The panel has an azimuth of due south (45 from the sun) and an elevation 22 from the horizontal. How many degrees is the sun from a perpendicular from the solar panel?

mfb
Mentor
You can convert the angles to vectors. The azimuth gives a relation between the two horizontal components and the elevation gives you the vertical component. Normalize the vector to get a third constraint on the three components.

I don't know how to work with vectors that are three dimensional, meaning two angles and a length. I am not interested in the length. The length of the vector to the sun is 93 million miles and the length of the vector representing the panel is infinite.
I already did the google search and find many places that tell me the optimum panel angle, but none that describe what I want. I refer back to the OP and the fourth paragraph. How is that solved?

In addition to the angle arithmetic I need the calculate the angle to the sun and any time and any day. This site comes the closest: http://success.homerenergy.com/energy-resource/angle-of-incidence/ but their equation does not make sense. It states that the solar declination is calculated by:
declination = (23.45 degrees) * sin( (360 degrees) * (284 + n ) / 365 )
I don't understand their meaning of ( x degrees ) multiplied by (some number) I put it into an Excel workbook and my answers were obviously not correct.
The phrase (284 + n) / 365 does not do the job because it begins on day 1, January first, with a value of 0.68 and evenly ramps up to 1.66 on day 360, which should be about the same as day 1.

Tom.G
I don't know how to work with vectors that are three dimensional, meaning two angles and a length.
There aren't any in the link I gave you. It is all solid geometry for which they supply the needed equations and definitions.

but their equation does not make sense. It states that the solar declination is calculated by:
declination = (23.45 degrees) * sin( (360 degrees) * (284 + n ) / 365 )
I don't understand their meaning of ( x degrees ) multiplied by (some number) I put it into an Excel workbook and my answers were obviously not correct.
The 23.45° is the tilt of the Earths axis.
284 is related to the day of an Equinox, a day of the year that the sun is directly over the equator.
360/365 is the number of {degrees per day} that the apparent position of the Sun shifts North or South of the Equator, due to the Earth axis tilt.

The result is that (284+n) is the {number of days} from the Equinox to the date (day number) you enter. This {number of days} is multiplied by the {degrees per day} to yield how far in degrees the apparent Sun position (known as the Subsolar Point) is from the Equator. When the sine operator is applied, the returned value is between +1 (on June 21 for the start of Summer [Northern hemisphere]), and -1 (Dec 22 for the start of Winter). (Those are the dates the Sun appears the furthest North and the furthest South of the Equator.)

The sine result in the range of +1 to -1 then multiplies the 23.45° of axis tilt to give a result that tells how far, in degrees, the Sun is North or South of the Equator at Solar Noon on that day.

To finally get the Solar Elevation at you location, you then subtract your Latitude from this Subsolar Point and add 90°, the result is the Elevation of the Sun at your location at Solar Noon. (SolarElevation = SubsolarPoint - Lat + 90)

I think everything else you need is covered in the link in post #3.

If you are getting in this deeper than you care to, I suggest further use of on-line searches for a calculator for your specific problem.

Cheers,
Tom

phyzguy
Below is some Python code that answers you question.

The first routine calculates the altitude and azimuth of the sun given:
H: The sun's hour angle. H is 0 degress when the sun is due south,(local noon) and 90 degrees when the sun is due west. H changes by 15 degrees per hour.
delta: The sun's declination. delta is +23.5 degrees on the summer solstice, -23.5 degrees on the winter solstice, and 0 on the equinoxes.

The second routine calculates the angle of the panel to the sun given:
alts, azs: The altitude and azimuth of the sun, as calculated from the first routine.
altp, azp: The altitude and azimuth of your panel. You said the roof is 22 degrees from horizontal, so that would be an altitude of (90 - 22) = 68 degrees. The panels pointed due south would have an azimuth of 0 degrees, and the panels pointed due west would have an azimuth of 90 degrees.

If you don't know or have access to Python, you should be able to enter these formulas into Excel. Note that the pi/180 and 180/pi terms are for converting between degrees and radians. If you have questions, just ask.

Python:
def AltAzfromHDelta(H, delta, lat):
alts=180.0/pi*arcsin(sin(delta*pi/180.0)*sin(lat*pi/180.0)+cos(delta*pi/180.0)*cos(lat*pi/180.0)*cos(H*pi/180.0))
azs=180.0/pi*arcsin(sin(H*pi/180.0)*cos(delta*pi/180.0)/cos(alts*pi/180.0))
return [alts,azs]

def AnglefromAltsAzs(alts, azs, altp, azp):
altsm = (90.0-alts)
altpm = (90.0-altp)
deltaaz = (azs-azp)
ctheta=cos(pi/180.0*altsm)*cos(pi/180.0*altpm)+sin(pi/180.0*altsm)*sin(pi/180.0*altpm)*cos(pi/180.0*deltaaz)
return 180.0 / pi * arccos(ctheta)

Last edited:
OmCheeto
Gold Member
...

azs=180.0/pi*arcsin(sin(H*pi/180.0)*cos(delta*pi/180.0)/cos(alt*pi/180.0))

...
I'm getting an error code in line 3.
Where is "alt" defined?

OmCheeto
Gold Member
I'm getting an error code in line 3.
Where is "alt" defined?
azs=180.0/pi*arcsin(sin(H*pi/180.0)*cos(delta*pi/180.0)/cos(alts*pi/180.0))​

Thanks!

phyzguy
I'm getting an error code in line 3.
Where is "alt" defined?
Sorry, that should be alts. I also messed up the zero point of the azimuth, which is 0 degrees due south. Both errors have been corrected now my post. Let me know if you see any other issues.

• OmCheeto
Tom G,
Thanks for the reply. You prompted me to really dig into that formula. I have a workbook that calculates the sun’s noontime elevation for the entire year.

Phyzguy,
Thanks for your reply. I don’t have Python. I presume your code works, but cramming everything into so few lines with no comments makes it really difficult to read and discern what it is doing and why.

After more thought, It now seems to be than if I know the sun's azimuth and elevation then I can subtract the az and el of the panel to determine the angle of the sun to the panel. Now my next step is to calculate the azimuth and elevation of the sun for each hour of any given day. I don’t know how I will do that.

phyzguy
Phyzguy,
Thanks for your reply. I don’t have Python. I presume your code works, but cramming everything into so few lines with no comments makes it really difficult to read and discern what it is doing and why.

After more thought, It now seems to be than if I know the sun's azimuth and elevation then I can subtract the az and el of the panel to determine the angle of the sun to the panel. Now my next step is to calculate the azimuth and elevation of the sun for each hour of any given day. I don’t know how I will do that.
Let me try and simplify it, and if you still have questions, please ask:

(1) The sun's declination (delta) varies through the year from +23.5 degrees to -23.5 degrees. You can either look it up, or you can calculate it from the formula:
delta = 23.5 * sin(days from the spring equinox * 360 / 365)

or, as you said in post #4:

delta = (23.45 degrees) * sin( (360 degrees) * (284 + n ) / 365 )

where n is the day of the year (Thanks to Tom.G for correcting this).

(2) The sun's hour angle (H) varies throughout the day. It is zero degrees at local noon, and changes at 15 degrees per hour. So one hour before local noon it is -15 degrees and three hours after local noon it is +45 degrees, and so on.

(3) Once you know the sun's declination and hour angle (and your latitude, which I assume you know), you can calculate the sun's altitude and azimuth from the following fomulas:

alts=arcsin(sin(delta)*sin(lat)+cos(delta)*cos(lat)*cos(H))
azs=arcsin(sin(H)*cos(delta)/cos(alts))

(4) Next you need to know the altitude and azimuth of the point your solar panels are pointing at. For the parameters you gave these values are:

south facing panels:
altp = 68 degrees
azp = 0

west facing panels:
altp = 68 degrees
azp = 90 degrees

(5) Now given the altitude and azimuth of the sun and the altitude and azimuth of the panel, you have two points on the sky, and you can calculate the angle between them. This is a problem in spherical trigonometry and is not given by simply taking the difference in altitude and the difference in azimuth. The formula for the angle is:

angle = arccos(cos(90-alts)*cos(90-altp)+sin(90-alts)*sin(90-altp)*cos(azs-azp))

or, more simply:

angle = arccos(sin(alts)*sin(altp)+cos(alts)*cos(altp)*cos(azs-azp))

Last edited:
Tom.G
An added term and a little bit of history.
delta = 23.5 * sin(days from the spring equinox)
Don't you need: delta = 23.5 * sin([days from spring equinox] * [degrees per day])
With [degrees per day] = [360/365] and,
[days from spring equinox] = (day of year) -81 Note: Spring equinox is on year day 81

This is shown in post #4 as:
declination = (23.45 degrees) * sin( (360 degrees) * (284 + n ) / 365 )
Where the "+ 284" is an optimization that originally was "- 81". Since the sin function wraps at 360°, the end result is the same, with the advantage that addition is simpler than the subtraction when calculating manually.

phyzguy
An added term and a little bit of history.

Don't you need: delta = 23.5 * sin([days from spring equinox] * [degrees per day])
With [degrees per day] = [360/365] and,
[days from spring equinox] = (day of year) -81 Note: Spring equinox is on year day 81

This is shown in post #4 as:

Where the "+ 284" is an optimization that originally was "- 81". Since the sin function wraps at 360°, the end result is the same, with the advantage that addition is simpler than the subtraction when calculating manually.
Of course. Thanks for the correction. I edited my post.