Commit 3a5c94dc authored by POLCHER Jan's avatar POLCHER Jan 🚴🏾
Browse files

Corrects units in the routing-graph file and add versioning system.

parent 07e95055
......@@ -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/km"
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/km"
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/km"
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/km"
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", "km", self.topo_resid[:,:], vtyp)
#
# Inflow number
......
......@@ -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)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment