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