Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
IPSL
LMD
InTro
RoutingPP
Commits
49698608
Commit
49698608
authored
Jul 09, 2020
by
POLCHER Jan
🚴🏾
Browse files
Added the parameters to the GraphFile so that ORCHIDEE can read it.
parent
2eafc43d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
2 deletions
+59
-2
HydroGrid.py
HydroGrid.py
+28
-0
Interface.py
Interface.py
+29
-1
RoutingPreProc.py
RoutingPreProc.py
+2
-1
No files found.
HydroGrid.py
View file @
49698608
...
...
@@ -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
Interface.py
View file @
49698608
...
...
@@ -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
#
...
...
RoutingPreProc.py
View file @
49698608
...
...
@@ -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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment