# Quick program to fetch NWM raw output. # Logan Karsten # National Center for Atmospheric Research # Research Applications Laboratory import datetime import subprocess hoursBack = 30 hoursLag = 6 bDate = datetime.datetime.now() for step in range(hoursBack,hoursLag,-1): dCurrent = bDate - datetime.timedelta(hours=step) if dCurrent.strftime('%H') != '00' and \ dCurrent.strftime('%H') != '06' and \ dCurrent.strftime('%H') != '12' and \ dCurrent.strftime('%H') != '18': print dCurrent.strftime('%H') continue else: print dCurrent.strftime('%H') for member in range(1,5): for fcstHr in range(6,726,6): fcstHrStr = str(fcstHr) fcstHrStr = fcstHrStr.zfill(3) longPath = 'http://www.ftp.ncep.noaa.gov/data/nccf/com/nwm/prod/nwm.' + \ dCurrent.strftime('%Y%m%d') + '/long_range_mem' + str(member) + \ '/nwm.t' + dCurrent.strftime('%H') + 'z.long_range.channel_rt_' + \ str(member) + '.f' + fcstHrStr + '.conus.nc.gz' cmd = 'wget ' + longPath subprocess.call(cmd,shell=True) longPath = 'http://www.ftp.ncep.noaa.gov/data/nccf/com/nwm/prod/nwm.' + \ dCurrent.strftime('%Y%m%d') + '/long_range_mem' + str(member) + \ '/nwm.t' + dCurrent.strftime('%H') + 'z.long_range.land_' + \ str(member) + '.f' + fcstHrStr + '.conus.nc.gz' cmd = 'wget ' + longPath subprocess.call(cmd,shell=True)