def day_of_year (yr, mn, dy) :
    """ day serial number in year, Jan 01 as 1
    args:
        yr: year, 2 or 4 digit year
        mn: month, 1 to 12
        dy: day, 1 to 31, extended days also acceptable
    returns:
        day number in the year
    """
    md = [0,  31, 28, 31,  30, 31, 30,  31, 31, 30,  31, 30, 31] # days in month
    dofy = sum(md[0:mn]) + dy  # day of year
    if yr % 4 == 0 and mn > 2 : dofy += 1 # leap year
    return dofy