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)
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)
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)
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()
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)
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()
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)
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)
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)
def testEnsembleVIC(self): self.options['vic']['ensemble size'] = 2 nowcast.execute(self.dbname, self.options)
def testDeterministicDSSAT(self): self.options['nowcast']['model'] = 'vic, dssat' nowcast.execute(self.dbname, self.options)
def testDeterministicVIC(self): self.options['nowcast']['model'] = "vic" nowcast.execute(self.dbname, self.options)
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)
def testMultiplePrecipVIC(self): self.options['vic']['precip'] = 'chirps, trmm' nowcast.execute(self.dbname, self.options)
def testMultiplePrecipVIC(self): """Test VIC simulation with multiple precipitation datasets.""" self.options['vic']['precip'] = 'chirps, trmm' nowcast.execute(self.dbname, self.options)
def testEnsembleDSSAT(self): self.options['nowcast']['model'] = 'vic, dssat' self.options['vic']['ensemble size'] = 2 nowcast.execute(self.dbname, self.options)
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)
def testEnsembleVIC(self): """Test ensemble nowcast VIC simulation.""" self.options['vic']['ensemble size'] = 2 nowcast.execute(self.dbname, self.options)