def setUp(self): self.dbname = "testdb" configfile = "{0}/tests/data.conf".format(rpath.data) conf = datasets.readDatasetList(configfile) bbox = map(lambda s: conf.getfloat("domain", s), ["minlon", "minlat", "maxlon", "maxlat"]) for name in ["chirps", "ncep", "smos", "trmm"]: mod = __import__("datasets.{0}".format(name), fromlist=[name]) t0 = datetime.strptime(conf.get(name, "startdate"), "%Y-%m-%d") t1 = datetime.strptime(conf.get(name, "enddate"), "%Y-%m-%d") mod.download(self.dbname, (t0, t1), bbox)
def setUp(self): self.dbname = "testdb" configfile = "{0}/tests/data.conf".format(rpath.data) conf = datasets.readDatasetList(configfile) bbox = map(lambda s: conf.getfloat('domain', s), ['minlon', 'minlat', 'maxlon', 'maxlat']) for name in ["chirps", "ncep", "smos", "trmm"]: mod = __import__("datasets.{0}".format(name), fromlist=[name]) t0 = datetime.strptime(conf.get(name, 'startdate'), "%Y-%m-%d") t1 = datetime.strptime(conf.get(name, 'enddate'), "%Y-%m-%d") mod.download(self.dbname, (t0, t1), bbox)
def update(dbname, configfile, bbox=None): """Fetch datasets and update database.""" conf = datasets.readDatasetList(configfile) try: bbox = map(lambda s: conf.getfloat('domain', s), [ 'minlon', 'minlat', 'maxlon', 'maxlat']) except: bbox = None for name in conf.sections(): if name != 'domain': try: mod = __import__("datasets.{0}".format(name), fromlist=[name]) except: mod = None if mod is None: # download generic datasets datasets.download(name, dbname, bbox) else: dt = mod.dates(dbname) mod.download(dbname, dt, bbox)
def update(dbname, configfile, bbox=None): """Fetch datasets and update database.""" conf = datasets.readDatasetList(configfile) try: bbox = map(lambda s: conf.getfloat('domain', s), [ 'minlon', 'minlat', 'maxlon', 'maxlat']) except: bbox = None for name in conf.sections(): if name != 'domain': try: mod = __import__("datasets.{0}".format(name), fromlist=[name]) except: mod = None if mod is None: # download generic datasets datasets.download(name, dbname, bbox) else: if conf.has_option(name, 'startdate'): t0 = datetime.strptime(conf.get(name, 'startdate'), "%Y-%m-%d") else: t0 = None if conf.has_option(name, 'enddate'): t1 = datetime.strptime(conf.get(name, 'enddate'), "%Y-%m-%d") else: t1 = None dt = mod.dates(dbname) if t0 is None: if dt is None: print("WARNING! Date information for {0} not found in the database or data.conf. Please add a startdate in the data.conf file.") else: if t1 is not None: dt = (dt[0], t1) else: if t1 is None: dt = (t0, dt[1]) else: dt = (t0, t1) if dt is not None: mod.download(dbname, dt, bbox)
def update(dbname, configfile): """Fetch datasets and update database.""" log = logging.getLogger(__name__) conf = datasets.readDatasetList(configfile) try: bbox = map(lambda s: conf.getfloat('domain', s), ['minlon', 'minlat', 'maxlon', 'maxlat']) except: bbox = None for name in conf.sections(): if name != 'domain': try: mod = __import__("datasets.{0}".format(name), fromlist=[name]) except: mod = None if conf.has_option(name, 'startdate'): t0 = datetime.strptime(conf.get(name, 'startdate'), "%Y-%m-%d") else: t0 = None if conf.has_option(name, 'enddate'): t1 = datetime.strptime(conf.get(name, 'enddate'), "%Y-%m-%d") else: t1 = datetime.today() if mod is None: # download generic datasets datasets.download(dbname, (t0, t1), bbox, conf, name) else: dt = mod.dates(dbname) if t0 is None: if dt is None: log.warning( "Date information for {0} not found in the database or data.conf. Please add a startdate in the data.conf file." .format(name)) else: dt = (dt[0], t1) else: dt = (t0, t1) if dt is not None: mod.download(dbname, dt, bbox)