def daybounds( season ):
    """Input is a 3-character season, e.g. JAN, JJA, ANN.  Output is bounds for that season
    in units of "days since 0".
    In most cases the bounds will be like [[lo,hi]].  But for DJF it will be like
    [[lo1,hi1],[lo2,hi2]].
    The noleap (365 day) calendar is required."""
    # This is an incredibly crude way to do it, but works for now.
    # If permanent, I would make these dictionaries global for performance.
    dbddic = { 'JAN': [[0,31]],
               'FEB': [[31,59]],
               'MAR': [[59,90]],
               'APR': [[90,120]],
               'MAY': [[120,151]],
               'JUN': [[151,181]],
               'JUL': [[181,212]],
               'AUG': [[212,243]],
               'SEP': [[243,273]],
               'OCT': [[273,304]],
               'NOV': [[304,334]],
               'DEC': [[334,365]] }
    sesdic = { 'MAM': [[ dbddic['MAR'][0][0], dbddic['MAY'][0][1] ]],
               'JJA': [[ dbddic['JUN'][0][0], dbddic['AUG'][0][1] ]],
               'SON': [[ dbddic['SEP'][0][0], dbddic['NOV'][0][1] ]],
               'DJF': [ dbddic['DEC'][0],
                        [dbddic['JAN'][0][0], dbddic['FEB'][0][1]] ],
               'ANN': [[ dbddic['JAN'][0][0], dbddic['DEC'][0][1] ]] }
    dbddic.update( sesdic )
    return dbddic[season]