def solar_azimuth_analytical(latitude, hourangle, declination, zenith):
numer = (np.cos(zenith) * np.sin(latitude) - np.sin(declination))<EOL>denom = (np.sin(zenith) * np.cos(latitude))<EOL>with np.errstate(invalid='<STR_LIT:ignore>', divide='<STR_LIT:ignore>'):<EOL><INDENT>cos_azi = numer / denom<EOL><DEDENT>cos_azi =np.where(np.isclose(denom,    <NUM_LIT:0.0>, rtol=<NUM_LIT:0.0>, atol=<NUM_LIT>),  <NUM_LIT:1.0>, cos_azi)<EOL>cos_azi =np.where(np.isclose(cos_azi,  <NUM_LIT:1.0>, rtol=<NUM_LIT:0.0>, atol=<NUM_LIT>),  <NUM_LIT:1.0>, cos_azi)<EOL>cos_azi =np.where(np.isclose(cos_azi, -<NUM_LIT:1.0>, rtol=<NUM_LIT:0.0>, atol=<NUM_LIT>), -<NUM_LIT:1.0>, cos_azi)<EOL>with np.errstate(invalid='<STR_LIT:ignore>'):<EOL><INDENT>sign_ha = np.sign(hourangle)<EOL><DEDENT>return sign_ha * np.arccos(cos_azi) + np.pi<EOL>
Analytical expression of solar azimuth angle based on spherical
trigonometry.

Parameters
----------
latitude : numeric
    Latitude of location in radians.
hourangle : numeric
    Hour angle in the local solar time in radians.
declination : numeric
    Declination of the sun in radians.
zenith : numeric
    Solar zenith angle in radians.

Returns
-------
azimuth : numeric
    Solar azimuth angle in radians.

References
----------
[1] J. A. Duffie and W. A. Beckman,  "Solar Engineering of Thermal
Processes, 3rd Edition" pp. 14, J. Wiley and Sons, New York (2006)

[2] J. H. Seinfeld and S. N. Pandis, "Atmospheric Chemistry and Physics"
p. 132, J. Wiley (1998)

[3] `Wikipedia: Solar Azimuth Angle
<https://en.wikipedia.org/wiki/Solar_azimuth_angle>`_

[4] `PVCDROM: Azimuth Angle <http://www.pveducation.org/pvcdrom/2-
properties-sunlight/azimuth-angle>`_

See Also
--------
declination_spencer71
declination_cooper69
hour_angle
solar_zenith_analytical