def pentad_to_jday(pentad, pmin=0, day=3):
    """
    Returns day of year for a pentad (indexed from pmin).

    Input day determines which day (1-5) in the pentad to return.
    Usage: jday = pentad_to_jday(pentad, pmin)
    """

    if day not in range(1, 6):
        raise ValueError('Invalid day ' + str(day))

    jday = 5*(pentad - pmin) + day
    return jday