def frac_year(hour, leap_year=False):
    """
    This function calculates the fraction of the year.

    Parameters
    ----------
    hour : integer, float
        The hour of the day. Could be a decimal value.
    leap_year : boolean
        Indicates if the year is a leap year. Default
        is False.

    Returns
    -------
    B : float
        The fraction of the year
    """
    if leap_year:
        n_days = 366
    else:
        n_days = 365

    B = (hour - 1944) / 24 * 360 / n_days
    return B