Skip to content
Snippets Groups Projects
Commit 49698608 authored by POLCHER Jan's avatar POLCHER Jan :bicyclist_tone4:
Browse files

Added the parameters to the GraphFile so that ORCHIDEE can read it.

parent 2eafc43d
No related branches found
No related tags found
No related merge requests found
......@@ -258,3 +258,31 @@ class HydroData :
self.floodplainsdesc=nf.variables["floodplains"].long_name
else:
self.floodplains = gather(np.zeros((jend-jstr,iend-istr)).astype(np.float32), index)
class HydroParameter :
# Class to set, compute and manage the time constants of the routing scheme.
def __init__(self, hydrogrid) :
if hydrogrid.hd >= 0.5 :
# Case of the Fekete/Vörösmarty hydrological data set
self.stream_tcst = 0.24
self.fast_tcst = 3.0
self.slow_tcst = 25.0
self.flood_tcst = 4.0
self.swamp_tcst = 0.2
elif hydrogrid.hd >= 0.016 :
# Case for MERIT
self.stream_tcst = 0.7
self.fast_tcst = 1.0
self.slow_tcst = 10.0
self.flood_tcst = 4.0
self.swamp_tcst = 0.2
elif hydrogrid.hd >= 0.008 :
# Case for HydroSEHDS
self.stream_tcst = 0.01
self.fast_tcst = 0.5
self.slow_tcst = 7.0
self.flood_tcst = 4.0
self.swamp_tcst = 0.2
else :
print("For the resolution ",hydrogrid.hd," deg. we do not yet have a parameter set.")
sys.exit
......@@ -176,6 +176,33 @@ def addenvironment(outnf, procgrid, part, vtyp, NCFillValue, nbpt) :
#
return
#
# Add time constants and possibly other prameters to the graph file
#
def addparameters(outnf, part, tcst, vtyp, NCFillValue) :
if part.rank == 0 :
outnf.createDimension('dimpara', 1)
stream = outnf.createVariable("StreamTimeCst", vtyp, ('dimpara'), fill_value=NCFillValue)
stream.title = "Time constant for the stream reservoir"
stream.units = "day/m"
stream[:] = tcst.stream_tcst
fast = outnf.createVariable("FastTimeCst", vtyp, ('dimpara'), fill_value=NCFillValue)
fast.title = "Time constant for the fast reservoir"
fast.units = "day/m"
fast[:] = tcst.fast_tcst
slow = outnf.createVariable("SlowTimeCst", vtyp, ('dimpara'), fill_value=NCFillValue)
slow.title = "Time constant for the slow reservoir"
slow.units = "day/m"
slow[:] = tcst.slow_tcst
flood = outnf.createVariable("FloodTimeCst", vtyp, ('dimpara'), fill_value=NCFillValue)
flood.title = "Time constant for the flood reservoir"
flood.units = "day/m"
flood[:] = tcst.flood_tcst
swamp = outnf.createVariable("SwampCst", vtyp, ('dimpara'), fill_value=NCFillValue)
swamp.title = "Fraction of the river transport that flows to the swamps"
swamp.units = "-"
swamp[:] = tcst.flood_tcst
return
#
#
#
def finalfetch(part, routing_area, basin_count, route_togrid, route_tobasin, fetch_in) :
......@@ -690,7 +717,7 @@ class HydroGraph :
#
#
#
def dumpnetcdf(self, filename, globalgrid, procgrid, part) :
def dumpnetcdf(self, filename, globalgrid, procgrid, part, tcst) :
#
NCFillValue=1.0e20
vtyp=np.float64
......@@ -711,6 +738,7 @@ class HydroGraph :
#
addcoordinates(outnf, globalgrid, procgrid, part, vtyp, NCFillValue, nbcorners, cornerind)
addenvironment(outnf, procgrid, part, vtyp, NCFillValue, self.nbpt)
addparameters(outnf, part, tcst, vtyp, NCFillValue)
#
# land grid index -> to facilitate the analyses of the routing
#
......
......@@ -74,6 +74,7 @@ INFO("nbasmax : {0}".format(nbasmax))
#
INFO("=================== HYDRODATA ====================")
hydrodata = HG.HydroData(hydrogrid.ncfile, hydrogrid.box, w.index, part, hydrogrid)
hydrotcst = HG.HydroParameter(hydrogrid)
INFO("=================== INITATMGRID ====================")
IF.initatmgrid(rank, nbcore, nbpt, modelgrid)
......@@ -122,6 +123,6 @@ print("Rank : {0} - Basin_count After Truncate : ".format(part.rank), hsuper.bas
INFO("=================== HydroGraph ====================")
hgraph = IF.HydroGraph(nbasmax, hsuper, part, modelgrid)
hgraph.dumpnetcdf(OutGraphFile, gg, modelgrid, part)
hgraph.dumpnetcdf(OutGraphFile, gg, modelgrid, part, hydrotcst)
IF.closeinterface(comm)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment