def testapirun_netcfd(self): startTime = 1 stopTime = 30 currentTime = 1 # set runid, clonemap and casename. Also define the ini file runId = "unittest" configfile = "wflow_sbm_nc.ini" wflow_cloneMap = "wflow_catchment.map" caseName = "wflow_sbm" myModel = wf.WflowModel(wflow_cloneMap, caseName, runId, configfile) # initialise the framework dynModelFw = wf.wf_DynamicFramework(myModel, 0, 0) # Load model config from files and check directory structure dynModelFw.createRunId(NoOverWrite=False, level=wf.logging.DEBUG) # Run the initial part of the model (reads parameters and sets initial values) dynModelFw._runInitial() # Runs initial part dynModelFw._runResume() # gets the state variables sump = 0.0 for ts in range(startTime, stopTime + 1): if ts < 10: dynModelFw.wf_setValues("P", 0.0) elif ts <= 15: dynModelFw.wf_setValues("P", 10.0) sump = sump + 10.0 else: dynModelFw.wf_setValues("P", 0.0) dynModelFw.wf_setValues("PET", 2.0) dynModelFw.wf_setValues("TEMP", 10.0) dynModelFw._runDynamic(ts, ts) # runs for all timesteps dynModelFw._runSuspend() # saves the state variables dynModelFw._wf_shutdown() # nore read the csv results acn check of they match the first run # Sum should be approx c 4.569673676 my_data = np.genfromtxt( os.path.join(caseName, runId, "wbsurf.csv"), delimiter=",", usecols=(0, 1, 2, 3, 4), ) print("Checking surface water budget ....") self.assertAlmostEqual(3.574188167654313e-09, my_data[:, 2].sum(), places=4) my_data = np.genfromtxt(os.path.join(caseName, runId, "wbsoil.csv"), delimiter=",") print("Checking soil water budget ....") self.assertAlmostEqual(0.0026834408363356488, my_data[:, 2].sum(), places=4) print("Checking precip sum ....") my_data = np.genfromtxt(os.path.join(caseName, runId, "P.csv"), delimiter=",") self.assertAlmostEqual(sump, my_data[:, 2].sum())
def testapirun_netcfd2(self): startTime = 1 stopTime = 30 currentTime = 1 # set runid, clonemap and casename. Also define the ini file runId = "unittest" configfile = "wflow_sbm_NC2.ini" wflow_cloneMap = 'wflow_catchment.map' caseName = "../../examples\wflow_rhine_sbm_nc" myModel = wf.WflowModel(wflow_cloneMap, caseName, runId, configfile) # initialise the framework dynModelFw = wf.wf_DynamicFramework(myModel, stopTime, startTime) # Load model config from files and check directory structure dynModelFw.createRunId(NoOverWrite=False, level=wf.logging.DEBUG) # Run the initial part of the model (reads parameters and sets initial values) dynModelFw._runInitial() # Runs initial part dynModelFw._runResume() # gets the state variables sump = 0.0 for ts in range(startTime, stopTime + 1): dynModelFw._runDynamic(ts, ts) # runs for all timesteps dynModelFw._runSuspend() # saves the state variables dynModelFw._wf_shutdown()
def testapirun_netcfd2(self): startTime = 1 stopTime = 30 currentTime = 1 # set runid, clonemap and casename. Also define the ini file runId = "unittest" configfile = "wflow_sbm_NC2.ini" wflow_cloneMap = "wflow_catchment.map" caseName = "../examples/wflow_rhine_sbm_nc" myModel = wf.WflowModel(wflow_cloneMap, caseName, runId, configfile) # initialise the framework dynModelFw = wf.wf_DynamicFramework(myModel, stopTime, startTime) # Load model config from files and check directory structure dynModelFw.createRunId(NoOverWrite=False, level=wf.logging.DEBUG) # Run the initial part of the model (reads parameters and sets initial values) dynModelFw._runInitial() # Runs initial part dynModelFw._runResume() # gets the state variables sump = 0.0 for ts in range(startTime, stopTime + 1): dynModelFw._runDynamic(ts, ts) # runs for all timesteps dynModelFw._runSuspend() # saves the state variables dynModelFw._wf_shutdown()
def testapirun_netcfd(self): startTime = 1 stopTime = 30 currentTime = 1 # set runid, clonemap and casename. Also define the ini file runId = "unittest" configfile = "wflow_sbm_dynveg.ini" wflow_cloneMap = 'wflow_catchment.map' caseName = "wflow_sbm" myModel = wf.WflowModel(wflow_cloneMap, caseName, runId, configfile) # initialise the framework dynModelFw = wf.wf_DynamicFramework(myModel, stopTime, startTime) # Load model config from files and check directory structure dynModelFw.createRunId(NoOverWrite=False, level=wf.logging.ERROR) # Run the initial part of the model (reads parameters and sets initial values) dynModelFw._runInitial() # Runs initial part dynModelFw._runResume() # gets the state variables sump = 0.0 for ts in range(startTime, stopTime): if ts < 10: dynModelFw.wf_setValues('P', 0.0) elif ts <= 15: dynModelFw.wf_setValues('P', 10.0) sump = sump + 10.0 else: dynModelFw.wf_setValues('P', 0.0) dynModelFw.wf_setValues('PET', 2.0) dynModelFw.wf_setValues('TEMP', 10.0) dynModelFw._runDynamic(ts, ts) # runs for all timesteps dynModelFw.logger.info("Doing step: " + str(ts)) dynModelFw._runSuspend() # saves the state variables dynModelFw._wf_shutdown() # nore read the csv results acn check of they match the first run # Sum should be approx c 4.569673676 my_data = wf.genfromtxt(os.path.join(caseName, runId, "wbsurf.csv"), delimiter=',', skip_header=1) print("Checking surface water budget ....") self.assertAlmostEquals(-1.003901559215592e-06, my_data[:, 2].sum(), places=4) my_data = wf.genfromtxt(os.path.join(caseName, runId, "wbsoil.csv"), delimiter=',') print("Checking soil water budget ....") self.assertAlmostEquals(0.0006305182757557759, my_data[:, 2].sum(), places=4) print("Checking precip sum ....") my_data = wf.genfromtxt(os.path.join(caseName, runId, "P.csv"), delimiter=',') self.assertAlmostEquals(sump, my_data[:, 2].sum())
def testapirun_netcfd(self): startTime = 1 stopTime = 30 currentTime = 1 # set runid, clonemap and casename. Also define the ini file runId = "unittest" configfile = "wflow_sbm_nc.ini" wflow_cloneMap = "wflow_catchment.map" caseName = "wflow_sbm" myModel = wf.WflowModel(wflow_cloneMap, caseName, runId, configfile) # initialise the framework dynModelFw = wf.wf_DynamicFramework(myModel, 0, 0) # Load model config from files and check directory structure dynModelFw.createRunId(NoOverWrite=False, level=wf.logging.DEBUG) # Run the initial part of the model (reads parameters and sets initial values) dynModelFw._runInitial() # Runs initial part dynModelFw._runResume() # gets the state variables sump = 0.0 for ts in range(startTime, stopTime + 1): if ts < 10: dynModelFw.wf_setValues("P", 0.0) elif ts <= 15: dynModelFw.wf_setValues("P", 10.0) sump = sump + 10.0 else: dynModelFw.wf_setValues("P", 0.0) dynModelFw.wf_setValues("PET", 2.0) dynModelFw.wf_setValues("TEMP", 10.0) dynModelFw._runDynamic(ts, ts) # runs for all timesteps dynModelFw._runSuspend() # saves the state variables dynModelFw._wf_shutdown() # nore read the csv results acn check of they match the first run # Sum should be approx c 4.569673676 my_data = np.genfromtxt( os.path.join(caseName, runId, "wbsurf.csv"), delimiter=",", usecols=(0, 1, 2, 3, 4), ) print("Checking surface water budget ....") self.assertAlmostEqual(3.574188167654313e-09, my_data[:, 2].sum(), places=4) my_data = np.genfromtxt( os.path.join(caseName, runId, "wbsoil.csv"), delimiter="," ) print("Checking soil water budget ....") self.assertAlmostEqual(1.3444056218487373e-11, my_data[:, 2].sum(), places=4) print("Checking precip sum ....") my_data = np.genfromtxt(os.path.join(caseName, runId, "P.csv"), delimiter=",") self.assertAlmostEqual(sump, my_data[:, 2].sum())
def testapirun(self): startTime = 1 stopTime = 30 currentTime = 1 # set runid, clonemap and casename. Also define the ini file runId = "unittestsbm" configfile = "wflow_sbm.ini" wflow_cloneMap = "wflow_catchment.map" caseName = "wflow_sbm" myModel = wf.WflowModel(wflow_cloneMap, caseName, runId, configfile) # initialise the framework dynModelFw = wf.wf_DynamicFramework(myModel, stopTime, startTime) # Load model config from files and check directory structure dynModelFw.createRunId(NoOverWrite=False, level=wf.logging.WARN) # Run the initial part of the model (reads parameters and sets initial values) dynModelFw._runInitial() # Runs initial part dynModelFw._runResume() # gets the state variables sump = 0.0 for ts in range(startTime, stopTime): if ts < 10: dynModelFw.wf_setValues("P", 0.0) elif ts <= 15: dynModelFw.wf_setValues("P", 5.0) sump = sump + 5.0 else: dynModelFw.wf_setValues("P", 0.0) dynModelFw.wf_setValues("PET", 3.0) dynModelFw.wf_setValues("TEMP", 10.0) dynModelFw._runDynamic(ts, ts) # runs for all timesteps dynModelFw.logger.info("Doing step: " + str(ts)) dynModelFw._runSuspend() # saves the state variables dynModelFw._wf_shutdown() # now read the csv results acn check of they match the first run # Sum should be approx c 4.569673676 my_data = np.genfromtxt( os.path.join(caseName, runId, "wbsurf.csv"), delimiter="," ) print("Checking surface water budget ....") self.assertAlmostEqual(-1.003901559215592e-06, my_data[:, 2].sum(), places=4) my_data = np.genfromtxt( os.path.join(caseName, runId, "wbsoil.csv"), delimiter="," ) print("Checking soil water budget ....") self.assertAlmostEqual(0.0006108780617068987, my_data[:, 2].sum(), places=4) print("Checking precip sum ....") my_data = np.genfromtxt(os.path.join(caseName, runId, "P.csv"), delimiter=",") self.assertAlmostEqual(sump, my_data[:, 2].sum())
def testapirun_netcfd(self): startTime = 1 stopTime = 30 currentTime = 1 # set runid, clonemap and casename. Also define the ini file runId = "unittest" configfile="wflow_sbm_nc.ini" wflow_cloneMap = 'wflow_catchment.map' caseName="wflow_sbm" myModel = wf.WflowModel(wflow_cloneMap, caseName,runId,configfile) # initialise the framework dynModelFw = wf.wf_DynamicFramework(myModel, stopTime,startTime) # Load model config from files and check directory structure dynModelFw.createRunId(NoOverWrite=False,level=wf.logging.DEBUG) # Run the initial part of the model (reads parameters and sets initial values) dynModelFw._runInitial() # Runs initial part dynModelFw._runResume() # gets the state variables sump = 0.0 for ts in range(startTime,stopTime + 1): if ts <10: dynModelFw.wf_setValues('P', 0.0) elif ts <= 15: dynModelFw.wf_setValues('P', 10.0) sump = sump + 10.0 else: dynModelFw.wf_setValues('P', 0.0) dynModelFw.wf_setValues('PET', 2.0) dynModelFw.wf_setValues('TEMP', 10.0) dynModelFw._runDynamic(ts,ts) # runs for all timesteps dynModelFw._runSuspend() # saves the state variables dynModelFw._wf_shutdown() # nore read the csv results acn check of they match the first run # Sum should be approx c 4.569673676 my_data = wf.genfromtxt(os.path.join(caseName,runId,"wbsurf.csv"), delimiter=',') print("Checking surface water budget ....") self.assertAlmostEquals(-2.4355218783966848e-06,my_data[:,2].sum()) my_data = wf.genfromtxt(os.path.join(caseName,runId,"wbsoil.csv"), delimiter=',') print("Checking soil water budget ....") self.assertAlmostEquals(0.00046876313034616146,my_data[:,2].sum()) print("Checking precip sum ....") my_data = wf.genfromtxt(os.path.join(caseName,runId,"P.csv"), delimiter=',') self.assertAlmostEquals(sump,my_data[:,2].sum())
def testapirunexample(self): startTime = 1 stopTime = 30 currentTime = 1 orgdir = os.getcwd() os.chdir("../examples/") # set runid, clonemap and casename. Also define the ini file runId = "unittestsbm" configfile = "wflow_sbm.ini" wflow_cloneMap = "wflow_subcatch.map" caseName = "wflow_rhine_sbm/" myModel = wf.WflowModel(wflow_cloneMap, caseName, runId, configfile) # initialise the framework dynModelFw = wf.wf_DynamicFramework(myModel, stopTime, startTime) # Load model config from files and check directory structure dynModelFw.createRunId(NoOverWrite=False, level=wf.logging.WARN) # Run the initial part of the model (reads parameters and sets initial values) dynModelFw._runInitial() # Runs initial part dynModelFw._runResume() # gets the state variables sump = 0.0 for ts in range(startTime, stopTime): dynModelFw._runDynamic(ts, ts) # runs for all timesteps dynModelFw.logger.info("Doing step: " + str(ts)) dynModelFw._runSuspend() # saves the state variables dynModelFw._wf_shutdown() # now read the csv results acn check of they match the first run # Sum should be approx c 4.569673676 my_data = np.genfromtxt(os.path.join(caseName, runId, "specrun.csv"), delimiter=",") os.chdir(orgdir) print("Checking specific runoff ....") self.assertAlmostEqual(46.76774859428406, my_data[:, 2].sum(), places=4)
def testapirunexample(self): startTime = 1 stopTime = 30 currentTime = 1 orgdir = os.getcwd() os.chdir("../examples/") # set runid, clonemap and casename. Also define the ini file runId = "unittestsbm" configfile = "wflow_sbm.ini" wflow_cloneMap = "wflow_subcatch.map" caseName = "wflow_rhine_sbm/" myModel = wf.WflowModel(wflow_cloneMap, caseName, runId, configfile) # initialise the framework dynModelFw = wf.wf_DynamicFramework(myModel, stopTime, startTime) # Load model config from files and check directory structure dynModelFw.createRunId(NoOverWrite=False, level=wf.logging.WARN) # Run the initial part of the model (reads parameters and sets initial values) dynModelFw._runInitial() # Runs initial part dynModelFw._runResume() # gets the state variables sump = 0.0 for ts in range(startTime, stopTime): dynModelFw._runDynamic(ts, ts) # runs for all timesteps dynModelFw.logger.info("Doing step: " + str(ts)) dynModelFw._runSuspend() # saves the state variables dynModelFw._wf_shutdown() # now read the csv results acn check of they match the first run # Sum should be approx c 4.569673676 my_data = np.genfromtxt( os.path.join(caseName, runId, "specrun.csv"), delimiter="," ) os.chdir(orgdir) print("Checking specific runoff ....") self.assertAlmostEqual(0.04551490924495738, my_data[:, 2].sum(), places=4)