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
3a5c94dc
Commit
3a5c94dc
authored
Dec 16, 2020
by
POLCHER Jan
🚴🏾
Browse files
Corrects units in the routing-graph file and add versioning system.
parent
07e95055
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
9 deletions
+18
-9
GraphHydro.py
GraphHydro.py
+13
-8
RoutingPreProc.py
RoutingPreProc.py
+5
-1
No files found.
GraphHydro.py
View file @
3a5c94dc
...
...
@@ -7,6 +7,7 @@ sys.path.append(localdir+'/F90subroutines')
#
import
numpy
as
np
from
netCDF4
import
Dataset
import
datetime
#
import
getargs
config
=
getargs
.
SetupConfig
()
...
...
@@ -25,24 +26,28 @@ import RPPtools as RPP
#
# Add time constants and possibly other prameters to the graph file
#
def
addparameters
(
outnf
,
part
,
tcst
,
vtyp
,
NCFillValue
)
:
def
addparameters
(
outnf
,
version
,
part
,
tcst
,
vtyp
,
NCFillValue
)
:
if
part
.
rank
==
0
:
# Add global attributes to the netCDF file
outnf
.
setncattr
(
"RoutingPPVersion"
,
version
)
outnf
.
setncattr
(
"GenerationDate"
,
datetime
.
datetime
.
utcnow
().
isoformat
(
sep
=
" "
))
# Add routing parameters
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
.
units
=
"
10+3.
day/
k
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
.
units
=
"
10+3.
day/
k
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
.
units
=
"
10+3.
day/
k
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
.
units
=
"
10+3.
day/
k
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"
...
...
@@ -158,7 +163,7 @@ class HydroGraph :
#
#
#
def
dumpnetcdf
(
self
,
filename
,
globalgrid
,
procgrid
,
part
,
tcst
,
locations
)
:
def
dumpnetcdf
(
self
,
filename
,
version
,
globalgrid
,
procgrid
,
part
,
tcst
,
locations
)
:
#
NCFillValue
=
1.0e20
vtyp
=
np
.
float64
...
...
@@ -183,7 +188,7 @@ class HydroGraph :
#
NH
.
addcoordinates
(
outnf
,
globalgrid
,
procgrid
,
part
,
vtyp
,
NCFillValue
,
nbcorners
,
cornerind
)
NH
.
addenvironment
(
outnf
,
procgrid
,
part
,
vtyp
,
NCFillValue
,
self
.
nbpt
)
addparameters
(
outnf
,
part
,
tcst
,
vtyp
,
NCFillValue
)
addparameters
(
outnf
,
version
,
part
,
tcst
,
vtyp
,
NCFillValue
)
#
# land grid index -> to facilitate the analyses of the routing
#
...
...
@@ -235,7 +240,7 @@ class HydroGraph :
self
.
add_variable
(
outnf
,
procgrid
,
NCFillValue
,
part
,
(
'z'
,
'y'
,
'x'
),
"outlettype"
,
"Type of outlet"
,
"code"
,
self
.
route_type
[:,:],
vtyp
)
#
# topographic index
self
.
add_variable
(
outnf
,
procgrid
,
NCFillValue
,
part
,
(
'z'
,
'y'
,
'x'
),
"topoindex"
,
"Topographic index of the retention time"
,
"m"
,
self
.
topo_resid
[:,:],
vtyp
)
self
.
add_variable
(
outnf
,
procgrid
,
NCFillValue
,
part
,
(
'z'
,
'y'
,
'x'
),
"topoindex"
,
"Topographic index of the retention time"
,
"
k
m"
,
self
.
topo_resid
[:,:],
vtyp
)
#
# Inflow number
...
...
RoutingPreProc.py
View file @
3a5c94dc
...
...
@@ -12,6 +12,10 @@ from matplotlib.backends.backend_pdf import PdfPages
import
matplotlib.pyplot
as
plt
import
time
#
# Version of RoutingPP
#
Version
=
1.0
#
# Get the information from the configuration file.
#
ConfigFile
=
"run.def"
...
...
@@ -134,7 +138,7 @@ hgraph = GR.HydroGraph(nbasmax, hsuper, part, modelgrid)
INFO
(
"=================== Locate gauging stations and other structures ===================="
)
hgraph
.
position
(
modelgrid
,
loc
)
hgraph
.
dumpnetcdf
(
OutGraphFile
,
gg
,
modelgrid
,
part
,
hydrotcst
,
loc
)
hgraph
.
dumpnetcdf
(
OutGraphFile
,
Version
,
gg
,
modelgrid
,
part
,
hydrotcst
,
loc
)
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