Exemplo n.º 1
0
class Hybrid:

  def __init__(self, data_dir):
    self.hrrr = NOAAFetch(HRRR(), base='{0}/hrrr'.format(data_dir))
    self.rap = NOAAFetch(RAP(), base='{0}/rap'.format(data_dir))
    self.nam = NOAAFetch(NAM(), base='{0}/nam'.format(data_dir))

  def fetch_time(self, dtime):
    '''
    Tries to download a file from HRRR, then falls back to RAP if that fails
    '''
    try:
      return self.hrrr.download_time(dtime)
    except urllib2.HTTPError:
      print "Downloading from HRR failed, trying RAP..."
      try:
        return self.rap.download_time(dtime)
      except urllib2.HTTPError:
        print "Download from RAP failed, trying NAM..."
        return self.nam.download_time(dtime)
Exemplo n.º 2
0
 def __init__(self, data_dir):
   self.hrrr = NOAAFetch(HRRR(), base='{0}/hrrr'.format(data_dir))
   self.rap = NOAAFetch(RAP(), base='{0}/rap'.format(data_dir))
   self.nam = NOAAFetch(NAM(), base='{0}/nam'.format(data_dir))