SOLAR_AZIM_AN

This function computes solar azimuth from latitude, hour angle, declination, and zenith using an analytical spherical-trigonometry relation.

Azimuth describes the sun’s horizontal direction and is useful for tracker control, façade shading, and incidence-angle calculations.

A common form is:

\sin(\gamma_s)=\frac{\cos(\delta)\sin(h)}{\sin(\theta_z)}

with quadrant handling applied to obtain the final azimuth angle.

Excel Usage

=SOLAR_AZIM_AN(latitude, hourangle, declination, zenith)
  • latitude (float, required): Site latitude (radians).
  • hourangle (list[list], required): Solar hour angle (radians).
  • declination (list[list], required): Solar declination angle (radians).
  • zenith (list[list], required): Solar zenith angle (radians).

Returns (list[list]): 2D list of solar azimuth angles (radians), or an error string.

Example 1: Solar azimuth at solar noon in radians

Inputs:

latitude hourangle declination zenith
0.6936 0 0.4091 0.2845

Excel formula:

=SOLAR_AZIM_AN(0.6936, {0}, {0.4091}, {0.2845})

Expected output:

3.14159

Example 2: Morning hour angle gives eastward azimuth

Inputs:

latitude hourangle declination zenith
0.6936 -0.5 0.2 0.8

Excel formula:

=SOLAR_AZIM_AN(0.6936, {-0.5}, {0.2}, {0.8})

Expected output:

2.03455

Example 3: Afternoon hour angle gives westward azimuth

Inputs:

latitude hourangle declination zenith
0.6936 0.5 0.2 0.8

Excel formula:

=SOLAR_AZIM_AN(0.6936, {0.5}, {0.2}, {0.8})

Expected output:

4.24863

Example 4: Multiple solar geometry rows

Inputs:

latitude hourangle declination zenith
0.6936 -0.3 0.1 0.9
0.3 0.1 0.9

Excel formula:

=SOLAR_AZIM_AN(0.6936, {-0.3;0.3}, {0.1;0.1}, {0.9;0.9})

Expected output:

Result
2.0875
4.19568

Python Code

Show Code
import pandas as pd
import numpy as np
from pvlib.solarposition import solar_azimuth_analytical as result_func

def solar_azim_an(latitude, hourangle, declination, zenith):
    """
    Calculate the solar azimuth angle using an analytical expression.

    See: https://pvlib-python.readthedocs.io/en/stable/reference/generated/pvlib.solarposition.solar_azimuth_analytical.html

    This example function is provided as-is without any representation of accuracy.

    Args:
        latitude (float): Site latitude (radians).
        hourangle (list[list]): Solar hour angle (radians).
        declination (list[list]): Solar declination angle (radians).
        zenith (list[list]): Solar zenith angle (radians).

    Returns:
        list[list]: 2D list of solar azimuth angles (radians), or an error string.
    """
    try:
        def flatten_num(data):
            if not isinstance(data, list): return [float(data)]
            flat = []
            for row in data:
                row = row if isinstance(row, list) else [row]
                for val in row:
                    if val == "": flat.append(float('nan'))
                    else: flat.append(float(val))
            return flat

        ha_list = flatten_num(hourangle)
        dec_list = flatten_num(declination)
        zen_list = flatten_num(zenith)

        n = len(ha_list)
        if n == 0 or len(dec_list) != n or len(zen_list) != n:
            return "Error: All input arrays must have the same non-zero length"

        lat = float(latitude)

        res = result_func(
            latitude=lat,
            hourangle=np.array(ha_list),
            declination=np.array(dec_list),
            zenith=np.array(zen_list)
        )

        return [[float(v) if not pd.isna(v) else ""] for v in res]
    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

Site latitude (radians).
Solar hour angle (radians).
Solar declination angle (radians).
Solar zenith angle (radians).