Commit 814d9f7c authored by Anthony's avatar Anthony
Browse files

Change in GraphHydro to get both topoindex distribution

parent 7b806d25
......@@ -204,9 +204,7 @@ class HydroGraph :
#
#
#
def add_tstepdistrib(self, outnf, procgrid, NCFillValue, part, data, area, vtyp, nbbins, tcst, arrayorder = 'F') :
def add_tstepdistrib(self, outnf, procgrid, NCFillValue, part, data, area, vtyp, nbbins, tcst, arrayorder = 'F', addname = "") :
var = procgrid.landscatter(data.astype(vtyp), order=arrayorder)
gvar = part.gather(var, default=NCFillValue)
larea = procgrid.landscatter(area.astype(vtyp), order=arrayorder)
......@@ -219,33 +217,33 @@ class HydroGraph :
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 = outnf.createVariable("topobins"+addname, vtyp, ('nbbnds','nbbins'))
topobins.title = "Topographic index"
topobins.units = "km"
topobins[0,:] = bin_edges[:-1]
topobins[1,:] = bin_edges[1:]
topohist = outnf.createVariable("topocount", vtyp, ("nbbins",), fill_value=NCFillValue)
topohist = outnf.createVariable("topocount"+addname, vtyp, ("nbbins",), fill_value=NCFillValue)
topohist.title = "Counts of HTU by topoindex"
topohist.units = "counts"
topohist[:] = hist[:]
wtopohist = outnf.createVariable("wtopocount", vtyp, ("nbbins",), fill_value=NCFillValue)
wtopohist = outnf.createVariable("wtopocount"+addname, 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'))
tbins = outnf.createVariable("tstepbins"+addname, vtyp, ('nbbnds','nbbins'))
tbins.title = "Time bins"
tbins.units = "s"
tbins[0,:] = tbin_edges[:-1]
tbins[1,:] = tbin_edges[1:]
ncvar = outnf.createVariable("stabtstepcount", vtyp, ("nbbins",), fill_value=NCFillValue)
ncvar = outnf.createVariable("stabtstepcount"+addname, vtyp, ("nbbins",), fill_value=NCFillValue)
ncvar.title = "Stable timestep distribution"
ncvar.units = "count"
ncvar[:] = thist[:]
#
maxtstep = weighted_quantile(gvar[~np.isnan(gvar)]*tcst.stream_tcst, 0.50, sample_weight=garea[~np.isnan(gvar)])
mtstep = outnf.createVariable("MaxTimeStep", vtyp, ('dimpara'), fill_value=NCFillValue)
mtstep = outnf.createVariable("MaxTimeStep"+addname, vtyp, ('dimpara'), fill_value=NCFillValue)
mtstep.title = "The maximum time-step possible given the distribution of HTU properties"
mtstep.units = "s"
mtstep[:] = maxtstep
......@@ -357,8 +355,8 @@ class HydroGraph :
self.add_variable(outnf, procgrid, NCFillValue, part, ('z','y','x'), \
"topoindex_stream", "Topographic index of the retention time for stream res.", "km", self.topo_resid_stream[:,:], vtyp)
# Add another distribution ? Or replace the other ?
#self.add_tstepdistrib(outnf, procgrid, NCFillValue, part, self.topo_resid_stream[:,:], self.routing_area[:,:], \
# vtyp, nbbins, tcst)
self.add_tstepdistrib(outnf, procgrid, NCFillValue, part, self.topo_resid_stream[:,:], self.routing_area[:,:], \
vtyp, nbbins, tcst, addname = "stream")
#
# Geometric properties of HTU
......
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