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

The area weighted topoindex histogram is also computed.

parent 3378ab20
......@@ -163,16 +163,21 @@ class HydroGraph :
#
#
#
def add_tstepdistrib(self, outnf, procgrid, NCFillValue, part, data, vtyp, nbbins, tcst, arrayorder = 'F') :
def add_tstepdistrib(self, outnf, procgrid, NCFillValue, part, data, area, vtyp, nbbins, tcst, arrayorder = 'F') :
var = procgrid.landscatter(data.astype(vtyp), order=arrayorder)
gvar = part.gather(var, default=NCFillValue)
larea = procgrid.landscatter(area.astype(vtyp), order=arrayorder)
garea = part.gather(larea, default=NCFillValue)
if part.rank == 0:
gvar[gvar >= NCFillValue] = np.nan
#
hist, bin_edges = np.histogram(gvar[~np.isnan(gvar)], bins=nbbins, range=(0,min(10000, np.nanmax(gvar))))
whist, bin_edges = np.histogram(gvar[~np.isnan(gvar)], weights=garea[~np.isnan(gvar)], \
bins=nbbins, range=(0,min(10000, np.nanmax(gvar))))
#
topobins = outnf.createVariable("topobins", vtyp, ('nbbnds','nbbins'))
topobins.title = "Topographic index"
topobins.units = "km"
......@@ -182,6 +187,10 @@ class HydroGraph :
topohist.title = "Counts of HTU by topoindex"
topohist.units = "counts"
topohist[:] = hist[:]
wtopohist = outnf.createVariable("wtopocount", vtyp, ("nbbins",), fill_value=NCFillValue)
wtopohist.title = "Area weighted counts of HTU by topoindex"
wtopohist.units = "counts"
wtopohist[:] = whist[:]
#
thist, tbin_edges = np.histogram(gvar[~np.isnan(gvar)]*tcst.stream_tcst, bins=nbbins, range=(0,RPP.OneDay/8))
tbins = outnf.createVariable("tstepbins", vtyp, ('nbbnds','nbbins'))
......@@ -300,7 +309,8 @@ class HydroGraph :
# topographic index
self.add_variable(outnf, procgrid, NCFillValue, part, ('z','y','x'), \
"topoindex", "Topographic index of the retention time", "km", self.topo_resid[:,:], vtyp)
self.add_tstepdistrib(outnf, procgrid, NCFillValue, part, self.topo_resid[:,:], vtyp, nbbins, tcst)
self.add_tstepdistrib(outnf, procgrid, NCFillValue, part, self.topo_resid[:,:], self.routing_area[:,:], \
vtyp, nbbins, tcst)
#
# Inflow number
......
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