Commit 1338f7fd authored by POLCHER Jan's avatar POLCHER Jan 🚴🏾
Browse files

Attempts to add up-stream error into the grouph file. But the methodology is...

Attempts to add up-stream error into the grouph file. But the methodology is not good enough. It uses too much memory. The merger between the procs needs to be optimized.
parent 0e973277
......@@ -114,7 +114,8 @@ class HydroGraph :
cost = np.tile(disterr,nbas).reshape((nbas,npt)).transpose()+upstrerr
if np.count_nonzero(~np.isnan(cost)) > 0 :
ij, ib = np.unravel_index(np.nanargmax(cost),cost.shape)
locations.addhtupos(i, ij, ib, np.nanmax(cost))
userr = (self.routing_fetch[ij,ib]/1.e+6-locations.upstream[i])/locations.upstream[i]*100
locations.addhtupos(i, ij, ib, np.nanmax(cost), userr)
else :
# Only report a missed station is there was a geographical solution on the domain.
if np.count_nonzero(~np.isnan(disterr)) > 0 :
......
......@@ -8,6 +8,7 @@ import codecs
#
import getargs
config = getargs.SetupConfig()
import RPPtools as RPP
#
log_master, log_world = getargs.getLogger(__name__)
INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error
......@@ -32,6 +33,7 @@ class Locations :
self.ij = [-1]*len(self.lid)
self.ib = [-1]*len(self.lid)
self.cost = [np.nan]*len(self.lid)
self.upstreamerr = [np.nan]*len(self.lid)
return
#
# Get the locations of infrastructures from an ASCII file
......@@ -85,10 +87,11 @@ class Locations :
#
# Adds position of location in the HTU graph
#
def addhtupos(self, i, ij, ib, cost) :
def addhtupos(self, i, ij, ib, cost, upstreamerr) :
self.ij[i] = ij
self.ib[i] = ib
self.cost[i] = cost
self.upstreamerr[i] = upstreamerr
return
#
# Function to keep only locations which could be placed in the HTU graph
......@@ -104,6 +107,7 @@ class Locations :
self.ij = np.array(self.ij)[l]
self.ib = np.array(self.ib)[l]
self.cost = np.array(self.cost)[l]
self.upstreamerr = np.array(self.upstreamerr)[l]
return
#
# Get all the unique locations identified in the HTU graph
......@@ -209,6 +213,7 @@ class Locations :
locationlist[2,i] = f[2][0]+1
locationlist[3,i] = f[1][0]+1
locationlist[4,i] = imon+1
#
else :
htumon = None
monnb = None
......@@ -218,9 +223,7 @@ class Locations :
#
gtypes = part.gathermergelist(list(self.lid), list(self.ltype), list(locationlist[0,:]))
gnames = part.gathermergelist(list(self.lid), list(self.lname), list(locationlist[0,:]))
if part.rank == 0:
for t in gnames :
print("XXXXX got type : ", t)
#
if part.rank == 0:
# Create new dimension
monmax = np.max(monnb)
......@@ -252,5 +255,10 @@ class Locations :
locnames.long_name = "Name of location"
for it,t in enumerate(gnames) :
locnames[it,:]=stringtoarr(t, strlen)
# # Create variable to save upstream error for the HTU to monitor
# uperrvar = outnf.createVariable("LocationUpstreamError", RPP.vtyp, loccoord, fill_value=RPP.FillValue)
# uperrvar.long_name = "Upstream error of monitored HTU"
# uperrvar.units= "%"
# uperrvar[:] = gupstrerr[:]
return
#
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