import math


def _daylight_hours(sunset_hour_angle_radians):
    """
    Calculate daylight hours from a sunset hour angle.

    Based on FAO equation 34 in Allen et al (1998).

    :param sunset_hour_angle_radians: sunset hour angle, in radians
    :return: number of daylight hours corresponding to the sunset hour angle
    :rtype: float
    :raise ValueError: if the sunset hour angle is not within valid range
    """

    # validate the sunset hour angle argument, which has a valid
    # range of 0 to pi radians (180 degrees), inclusive
    # see http://mypages.iit.edu/~maslanka/SolarGeo.pdf
    if not 0.0 <= sunset_hour_angle_radians <= math.pi:
        raise ValueError("sunset hour angle outside valid range [0.0 to {math.pi!r}]: {sunset_hour_angle_radians!r}".format(sunset_hour_angle_radians))

    # calculate daylight hours from the sunset hour angle
    return (24.0 / math.pi) * sunset_hour_angle_radians