Exemplo n.º 1
0
def run():
    """Main RHEAS routine."""
    config_filename, dbname, db_update, verbose, logfile = parseArgs()
    if verbose:
        log_level = logging.DEBUG
    else:
        log_level = logging.INFO
    if logfile is None:
        logging.basicConfig(level=log_level, format='%(levelname)s: %(message)s')
    else:
        logging.basicConfig(filename=logfile, level=log_level, format='%(levelname)s: %(message)s')
    log = logging.getLogger(__name__)
    if dbname is None:
        dbname = "rheas"
    dbio.connect(dbname)
    # check if database update is requested
    if db_update:
        log.info("Updating database!")
        update(dbname, config_filename)
    else:
        options = config.loadFromFile(config_filename)
        # check what simulations have been requested
        if "nowcast" in options:
            nowcast.execute(dbname, options)
        if "forecast" in options:
            forecast.execute(dbname, options)
Exemplo n.º 2
0
 def testAssimilationVIC(self):
     """Test nowcast VIC simulation with data assimilation."""
     self.options['nowcast']['startdate'] = "2011-1-1"
     self.options['nowcast']['enddate'] = "2011-1-2"
     self.options['vic']['ensemble size'] = 3
     self.options['vic']['observations'] = "smos"
     nowcast.execute(self.dbname, self.options)
Exemplo n.º 3
0
 def testEnsembleDSSAT(self):
     """Test ensemble nowcast DSSAT simulation."""
     self.options['nowcast']['model'] = 'vic, dssat'
     self.options['vic']['ensemble size'] = 2
     self.options['nowcast']['startdate'] = "2011-2-21"
     self.options['nowcast']['enddate'] = "2011-4-30"
     nowcast.execute(self.dbname, self.options)
Exemplo n.º 4
0
 def testAssimilationVIC(self):
     """Test nowcast VIC simulation with data assimilation."""
     self.options['nowcast']['startdate'] = "2011-1-1"
     self.options['nowcast']['enddate'] = "2011-1-2"
     self.options['vic']['ensemble size'] = 3
     self.options['vic']['observations'] = "smos"
     nowcast.execute(self.dbname, self.options)
Exemplo n.º 5
0
def run():
    """Main RHEAS routine."""
    config_filename, dbname, db_update, verbose, logfile = parseArgs()
    if verbose:
        log_level = logging.DEBUG
    else:
        log_level = logging.INFO
    if logfile is None:
        logging.basicConfig(level=log_level,
                            format='%(levelname)s: %(message)s')
    else:
        logging.basicConfig(filename=logfile,
                            level=log_level,
                            format='%(levelname)s: %(message)s')
    log = logging.getLogger(__name__)
    if dbname is None:
        dbname = "rheas"
    dbio.connect(dbname)
    # check if database update is requested
    if db_update:
        log.info("Updating database!")
        update(dbname, config_filename)
    else:
        options = config.loadFromFile(config_filename)
        # check what simulations have been requested
        if "nowcast" in options:
            nowcast.execute(dbname, options)
        if "forecast" in options:
            forecast.execute(dbname, options)
Exemplo n.º 6
0
 def testEnsembleDSSAT(self):
     """Test ensemble nowcast DSSAT simulation."""
     self.options['nowcast']['model'] = 'vic, dssat'
     self.options['vic']['ensemble size'] = 2
     self.options['nowcast']['startdate'] = "2011-2-21"
     self.options['nowcast']['enddate'] = "2011-4-30"
     nowcast.execute(self.dbname, self.options)
Exemplo n.º 7
0
 def testDeterministicVIC(self):
     nowcast.execute(self.dbname, self.options)
     db = dbio.connect(self.dbname)
     cur = db.cursor()
     cur.execute("select * from information_schema.tables where table_name='runoff' and table_schema='basin'")
     assert bool(cur.rowcount) is True
     cur.close()
     db.close()
Exemplo n.º 8
0
 def testVICWithState(self):
     """Test saving and restarting VIC with state file."""
     statepath = tempfile.mkdtemp()
     self.options['vic']['save state'] = statepath
     nowcast.execute(self.dbname, self.options)
     self.options['vic'].pop('save state')
     self.options['vic']['initialize'] = True
     self.options['nowcast']['startdate'] = "2005-12-31"
     self.options['nowcast']['enddate'] = "2006-12-31"
     nowcast.execute(self.dbname, self.options)
Exemplo n.º 9
0
 def testDeterministicVIC(self):
     nowcast.execute(self.dbname, self.options)
     db = dbio.connect(self.dbname)
     cur = db.cursor()
     cur.execute(
         "select * from information_schema.tables where table_name='runoff' and table_schema='basin'"
     )
     assert bool(cur.rowcount) is True
     cur.close()
     db.close()
Exemplo n.º 10
0
 def testVICWithState(self):
     """Test saving and restarting VIC with state file."""
     statepath = tempfile.mkdtemp()
     self.options['vic']['save state'] = statepath
     nowcast.execute(self.dbname, self.options)
     self.options['vic'].pop('save state')
     self.options['vic']['initialize'] = True
     self.options['nowcast']['startdate'] = "2011-2-1"
     self.options['nowcast']['enddate'] = "2011-2-2"
     nowcast.execute(self.dbname, self.options)
Exemplo n.º 11
0
def run():
    """Main RHEAS routine."""
    config_filename, dbname, db_update = parseArgs()
    if dbname is None:
        dbname = "rheas"
    dbio.connect(dbname)
    # check if database update is requested
    if db_update:
        print "Updating database!"
        update(dbname, config_filename)
    else:
        options = config.loadFromFile(config_filename)
        # check what simulations have been requested
        if "nowcast" in options:
            nowcast.execute(dbname, options)
        if "forecast" in options:
            forecast.execute(dbname, options)
Exemplo n.º 12
0
def run():
    """Main RHEAS routine."""
    config_filename, dbname, db_update = parseArgs()
    if dbname is None:
        dbname = "rheas"
    dbio.connect(dbname)
    # check if database update is requested
    if db_update:
        print "Updating database!"
        update(dbname, config_filename)
    else:
        options = config.loadFromFile(config_filename)
        # check what simulations have been requested
        if "nowcast" in options:
            nowcast.execute(dbname, options)
        if "forecast" in options:
            forecast.execute(dbname, options)
Exemplo n.º 13
0
def run():
    """Main RHEAS routine."""
    config_filename, dbname, db_update = parseArgs()
    if dbname is None:
        dbname = "rheas"
    try:
        pg.connect("dbname={0}".format(dbname))
    except:
        print("Cannot connect to database {0}. Please restart it by running \n {1}/pg_ctl -D {2}/postgres restart".format(
            dbname, rpath.bins, rpath.data))
        sys.exit()
    # check if database update is requested
    if db_update:
        print "Updating database!"
        update(dbname, config_filename)
    else:
        options = config.loadFromFile(config_filename)
        # check what simulations have been requested
        if "nowcast" in options:
            nowcast.execute(dbname, options)
        if "forecast" in options:
            forecast.execute(dbname, options)
Exemplo n.º 14
0
 def testEnsembleVIC(self):
     self.options['vic']['ensemble size'] = 2
     nowcast.execute(self.dbname, self.options)
Exemplo n.º 15
0
 def testDeterministicDSSAT(self):
     self.options['nowcast']['model'] = 'vic, dssat'
     nowcast.execute(self.dbname, self.options)
Exemplo n.º 16
0
 def testDeterministicVIC(self):
     self.options['nowcast']['model'] = "vic"
     nowcast.execute(self.dbname, self.options)
Exemplo n.º 17
0
 def testEnsembleVIC(self):
     self.options['vic']['ensemble size'] = 2
     nowcast.execute(self.dbname, self.options)
Exemplo n.º 18
0
 def testDeterministicDSSAT(self):
     """Test deterministic nowcast DSSAT simulation."""
     self.options['nowcast']['model'] = 'vic, dssat'
     self.options['nowcast']['startdate'] = "2011-1-21"
     self.options['nowcast']['enddate'] = "2011-4-30"
     nowcast.execute(self.dbname, self.options)
Exemplo n.º 19
0
 def testMultiplePrecipVIC(self):
     self.options['vic']['precip'] = 'chirps, trmm'
     nowcast.execute(self.dbname, self.options)
Exemplo n.º 20
0
 def testMultiplePrecipVIC(self):
     self.options['vic']['precip'] = 'chirps, trmm'
     nowcast.execute(self.dbname, self.options)
Exemplo n.º 21
0
 def testDeterministicDSSAT(self):
     """Test deterministic nowcast DSSAT simulation."""
     self.options['nowcast']['model'] = 'vic, dssat'
     self.options['nowcast']['startdate'] = "2011-1-21"
     self.options['nowcast']['enddate'] = "2011-4-30"
     nowcast.execute(self.dbname, self.options)
Exemplo n.º 22
0
 def testMultiplePrecipVIC(self):
     """Test VIC simulation with multiple precipitation datasets."""
     self.options['vic']['precip'] = 'chirps, trmm'
     nowcast.execute(self.dbname, self.options)
Exemplo n.º 23
0
 def testEnsembleDSSAT(self):
     self.options['nowcast']['model'] = 'vic, dssat'
     self.options['vic']['ensemble size'] = 2
     nowcast.execute(self.dbname, self.options)
Exemplo n.º 24
0
 def testAssimilationVIC(self):
     self.options['nowcast']['startdate'] = "2010-1-16"
     self.options['nowcast']['enddate'] = "2010-1-18"
     self.options['vic']['ensemble size'] = 3
     self.options['vic']['observations'] = "smos"
     nowcast.execute(self.dbname, self.options)
Exemplo n.º 25
0
 def testMultiplePrecipVIC(self):
     """Test VIC simulation with multiple precipitation datasets."""
     self.options['vic']['precip'] = 'chirps, trmm'
     nowcast.execute(self.dbname, self.options)
Exemplo n.º 26
0
 def testEnsembleVIC(self):
     """Test ensemble nowcast VIC simulation."""
     self.options['vic']['ensemble size'] = 2
     nowcast.execute(self.dbname, self.options)
Exemplo n.º 27
0
 def testEnsembleVIC(self):
     """Test ensemble nowcast VIC simulation."""
     self.options['vic']['ensemble size'] = 2
     nowcast.execute(self.dbname, self.options)