Esempio n. 1
0
def download(username,
             password,
             folder,
             suscription_id=None,
             name=None,
             datetime_filter=None):
    noaa = noaaclass.connect(username, password)
    manager = DownloadManager(folder)
    suscriptions = noaa.subscribe.gvar_img.get(async=True,
                                               hours=2,
                                               append_files=True)
    compare = (lambda sus: sus['id'] == suscription_id
               if suscription_id else sus['name'] == name)
    suscription = filter(lambda s: compare(s), suscriptions)[0]
    orders = filter(lambda o: o['status'] == 'ready', suscription['orders'])
    http_files = map(lambda o: o['files']['http'], orders)
    ftp_files = map(lambda o: o['files']['ftp'], orders)
    files = zip(itertools.chain(*ftp_files), itertools.chain(*http_files))
    urls = filter(lambda filename: filename[0][-3:] == '.nc', files)
    if datetime_filter:
        get_datetime = lambda f: datetime.strptime(calibrator.short(f),
                                                   "%Y.%j.%H%M%S")
        urls = filter(lambda f: datetime_filter(get_datetime(f[0])), urls)
    urls = filter(lambda u: only_incompleted(u[0], folder), urls)
    map(manager.queue.put, urls)
    manager.start()
    manager.join()
    downloaded = map(
        lambda u: "%s/%s" % (folder, calibrator.short(u[1], 1, None)), urls)
    return downloaded
Esempio n. 2
0
def download(username, password, folder, suscription_id=None, name=None,
             datetime_filter=None):
    noaa = noaaclass.connect(username, password)
    manager = DownloadManager(folder)
    suscriptions = noaa.subscribe.gvar_img.get(async=True, hours = 2,
                                               append_files=True)
    compare = (lambda sus: sus['id'] == suscription_id if suscription_id else
               sus['name'] == name)
    suscription = filter(lambda s: compare(s), suscriptions)[0]
    orders = filter(lambda o: o['status'] == 'ready', suscription['orders'])
    http_files = map(lambda o: o['files']['http'], orders)
    ftp_files = map(lambda o: o['files']['ftp'], orders)
    files = zip(itertools.chain(*ftp_files), itertools.chain(*http_files))
    urls = filter(lambda filename: filename[0][-3:] == '.nc',
                  files)
    if datetime_filter:
        get_datetime = lambda f: datetime.strptime(calibrator.short(f),
                                                   "%Y.%j.%H%M%S")
        urls = filter(lambda f: datetime_filter(get_datetime(f[0])), urls)
    urls = filter(lambda u: only_incompleted(u[0], folder), urls)
    map(manager.queue.put, urls)
    manager.start()
    manager.join()
    downloaded = map(lambda u: "%s/%s" % (folder, calibrator.short(u[1], 1, None)),
                     urls)
    return downloaded
Esempio n. 3
0
 def setUp(self):
     self.noaa = noaaclass.connect('noaaclass.t', 'noaaclassadmin')
     self.init_subscribe_data()
     self.init_request_data()
     self.remove_all_in_server()
 def setUp(self):
     self.noaa = noaaclass.connect('noaaclass.t', 'noaaclassadmin')
 def test_login_failure(self):
     # Check if the connection fails with an unregistered user/pass.
     with self.assertRaisesRegexp(Exception,
                                  'unregistered: Invalid NOAA user '
                                  'or wrong password.'):
         noaaclass.connect('unregistered', 'nil')
Esempio n. 6
0
 def setUp(self):
     self.noaa = noaaclass.connect('noaaclass.t', 'noaaclassadmin')
     self.init_subscribe_data()
     self.init_request_data()
     self.remove_all_in_server()
Esempio n. 7
0
 def setUp(self):
     self.noaa = noaaclass.connect('noaaclass.t', 'noaaclassadmin')
Esempio n. 8
0
 def test_login_failure(self):
     # Check if the connection fails with an unregistered user/pass.
     with self.assertRaisesRegexp(
             Exception, 'unregistered: Invalid NOAA user '
             'or wrong password.'):
         noaaclass.connect('unregistered', 'nil')
import os

# The interval is allways a day to avoid the nights.
interval = timedelta(days=1)
# The nexts days and hours are in UTC format.
start = datetime(2014, 4, 1)
end = datetime(2014, 9, 30)
# denver before sunrise (5am in denver, 11am in gmt) #changed to 12 for san fran area
start_time = timedelta(hours=12, minutes=0, seconds=0)
# denver past sunset (10pm in denver, 4am in gmt) #changed to 5 for san fran area
end_time = timedelta(hours=5, minutes=0, seconds=0)

username = os.environ["NOAA_USERNAME"]
password = os.environ["NOAA_PASSWORD"]

noaa = noaaclass.connect(username, password)
data_template = {
    "id": "+",
    # 'north': 41., #colorado
    # 'south': 38.,
    # 'west': -106.,
    # 'east': -103.,
    "north": 39.0,  # san fran area
    "south": 36.0,
    "west": -124.0,
    "east": -121.0,
    "coverage": ["NH"],
    "schedule": ["R"],
    "satellite": ["G15"],
    "channel": range(1, 7),
    "format": "NetCDF",