Esempio n. 1
0
def RUC_fname(utc,filetype='grib'):
    """
    Returns RUC filename for date.
    """
    version = RUC_version(utc)

    t = GIS_tools.ensure_datenum(utc)
    yr = time.gmtime(t).tm_year
    mth = time.gmtime(t).tm_mon
    day = time.gmtime(t).tm_mday
    hr = time.gmtime(t).tm_hour

    if version == 3:
        prefix = 'rap_130'
        suffix = 'grb2'
    elif version == 2:
        prefix = 'ruc2anl_130'
        suffix = 'grb2'
    elif version == 1:
        prefix = 'ruc2anl_252'
        suffix = 'grb'
    else:
        prefix = 'ruc2_252'
        suffix = 'grb'

    if filetype=='netcdf':
        suffix = 'nc'
    fname = '{0}_{1:04d}{2:02d}{3:02d}_{4:02d}00_000.{5}'.format(prefix,yr,mth,day,hr,suffix)
    return fname
Esempio n. 2
0
def RUC_version(utc,fname=False,URL=False):
    """Returns the version/fname of RUC file
    """
    t = GIS_tools.ensure_datenum(utc)
    date0 = utils.ensure_datenum((2004,1,1,0,0,0))
    date1 = utils.ensure_datenum((2007,1,1,0,0,0))
    date2 = utils.ensure_datenum((2008,1,1,0,0,0))
    date3 = utils.ensure_datenum((2009,1,1,0,0,0))
    date4 = utils.ensure_datenum((2012,5,9,0,0,0))

    if t >= date4:
        version = 3
    elif t >= date3:
        version = 2
    elif t >= date2:
        version = 0
    elif t >= date1:
        version = 1
    elif t >= date0:
        version = 0
    else:
        print("No RUC data for this date exists.")
        raise Exception

    # print("This RUC file is Version {0}.".format(version))
    return version
Esempio n. 3
0
def RUC_URL(utc):
    """
    Returns URL to download RUC file from nomads.
    """
    t = GIS_tools.ensure_datenum(utc)
    yr = time.gmtime(t).tm_year
    mth = time.gmtime(t).tm_mon
    day = time.gmtime(t).tm_mday

    URL_base = "http://nomads.ncdc.noaa.gov/data/rucanl"
    URL = '{0}/{1:04d}{2:02d}/{1:02d}{2:02d}{3:02d}/'.format(URL_base,yr,mth,day)

    return URL