#!/usr/bin/env python import os, sys, string, re, time # the EDEX installer prepends to LD_LIBRARY_PATH the path # /lib, where is something like # /awips (the default), /opt/awips, or $HOME/awips. if not os.environ.has_key( "LD_LIBRARY_PATH" ): print "" print "LD_LIBRARY_PATH is not set. Has EDEX been installed?" print "If so, open a new terminal and try again" print "" sys.exit( 1 ) lib_path = "" lib_path_array = os.environ.get("LD_LIBRARY_PATH").split(":") for elem in lib_path_array: if not elem.find("/awips/lib") == -1: lib_path = elem break if len(lib_path) == 0: print "" print "LD_LIBRARY_PATH is not set. Has EDEX been installed?" print "" sys.exit( 1 ) local_edex_sbn_dir = os.path.dirname( lib_path ) local_edex_sbn_dir += "/edex/data/sbn" print "sbn dir = " + local_edex_sbn_dir os.chdir(local_edex_sbn_dir + "/grib") # # Create the directory time variables from the "last" GMT hour # prevhour = time.strftime("%H", time.gmtime(time.time() - 3600.0)) prevdate = time.strftime("%Y%m%d", time.gmtime(time.time() - 3600.0)) print "Getting RUC80 files at " + prevhour + "Z" print "On date: " + prevdate # # Get the files # ftp_site="ftp://tgftp.nws.noaa.gov" filesToGet = ['fh.0001_tl.press_gr.us80km', 'fh.0009_tl.press_gr.us80km', 'fh.0002_tl.press_gr.us80km', 'fh.0012_tl.press_gr.us80km', 'fh.0003_tl.press_gr.us80km', 'fh.anal_tl.press_gr.us80km', 'fh.0006_tl.press_gr.us80km'] for each in filesToGet: try: os.system("/usr/bin/wget " + ftp_site + "/SL.us008001/ST.opnl/MT.ruc_CY." + prevhour + "/RD." + prevdate + "/PT.grid_DF.gr2/" + each + " -O " + each + "." + prevdate + "." + prevhour) except: continue