Skip to content
Snippets Groups Projects
Commit 0d953cb8 authored by POLCHER Jan's avatar POLCHER Jan :bicyclist_tone4:
Browse files

Some clean-up of the code and supression of the call to the plot routines in...

Some clean-up of the code and supression of the call to the plot routines in the main. That is replced by Anthony's code.
parent a0d7b266
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ import RPPtools as RPP
import configparser
config=configparser.ConfigParser()
config.read("run.def")
EarthRadius=config.getfloat("OverAll", "EarthRadius")
EarthRadius=config.getfloat("OverAll", "EarthRadius", fallback=6370000.0)
#
import getargs
log_master, log_world = getargs.getLogger(__name__)
......@@ -58,8 +58,6 @@ def corners(lon, lat) :
def gather(x, index) :
y=[]
for ia in index :
# print("XXXX shape of ia :", ia.shape, ia.dtype)
# print("XXXX ia :", ia)
y.append(list(x[ia[0,i],ia[1,i]] for i in range(ia.shape[1]) ))
return y
#
......
......@@ -26,11 +26,11 @@ MPI.COMM_WORLD.Barrier()
import routing_interface
#
import configparser
config = configparser.ConfigParser({'Documentation':'false', 'nbxmax':'63', 'ROUTING_RIVERS':'50'})
config = configparser.ConfigParser()
config.read("run.def")
gendoc = config.get("OverAll", "Documentation")
nbxmax = config.getint("OverAll", "nbxmax")
largest_pos = config.getint("OverAll", "ROUTING_RIVERS")
gendoc = config.get("OverAll", "Documentation", fallback='false')
nbxmax = config.getint("OverAll", "nbxmax", fallback=63)
largest_pos = config.getint("OverAll", "ROUTING_RIVERS", fallback=50)
#
undef_int = 999999999.9
# Order of magnitude for the area precision in m^2.
......
......@@ -10,7 +10,7 @@ import RPPtools as RPP
import sys
#
import configparser
config=configparser.ConfigParser({"WEST_EAST":"-180., 180", "SOUTH_NORTH":"-90., 90."})
config=configparser.ConfigParser()
config.read("run.def")
#
import getargs
......@@ -19,7 +19,7 @@ INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error
INFO_ALL, DEBUG_ALL = log_world.info, log_world.debug
#
#
EarthRadius=config.getfloat("OverAll", "EarthRadius")
EarthRadius=config.getfloat("OverAll", "EarthRadius", fallback=6370000.0)
rose=[[-1,-1],[-1,0],[-1,+1],[0,+1],[+1,+1],[+1,0],[+1,-1],[0,-1]]
epsilon=0.00001
#
......@@ -410,8 +410,8 @@ class ModelGrid :
class GlobalGrid :
def __init__(self) :
lonrange=np.array(config.get("OverAll", "WEST_EAST").split(","),dtype=float)
latrange=np.array(config.get("OverAll", "SOUTH_NORTH").split(","),dtype=float)
lonrange=np.array(config.get("OverAll", "WEST_EAST", fallback="-180., 180.").split(","),dtype=float)
latrange=np.array(config.get("OverAll", "SOUTH_NORTH", fallback="-90., 90.").split(","),dtype=float)
self.source=config.get("OverAll", "ModelGridFile")
INFO("Opening : "+self.source)
......
......@@ -15,10 +15,10 @@ from spherical_geometry import vector
# Configuration
#
import configparser
config=configparser.ConfigParser({'SaveWeights':'true'})
config=configparser.ConfigParser()
config.read("run.def")
saveweights=config.get("OverAll", "SaveWeights")
EarthRadius=config.getfloat("OverAll", "EarthRadius")
saveweights=config.get("OverAll", "SaveWeights", fallback="true")
EarthRadius=config.getfloat("OverAll", "EarthRadius", fallback=6370000.0)
#
# Logging in MPI : https://groups.google.com/forum/#!topic/mpi4py/SaNzc8bdj6U
#
......
......@@ -15,14 +15,12 @@ import time
# Gert the information from the configuration file.
#
import configparser
config=configparser.ConfigParser({"DiagLon":"0.0, 0.0", "DiagLat":"0.0, 0.0"})
config=configparser.ConfigParser()
config.read("run.def")
nbasmax=config.getint("OverAll", "nbasmax")
numop=config.getint("OverAll", "numop", fallback=100)
OutGraphFile=config.get("OverAll","GraphFile")
DumpHydroSuper=config.getboolean("OverAll","DumpHydroSuper",fallback=False)
lonint=np.array(config.get("OverAll", "DiagLon").split(","),dtype=float)
latint=np.array(config.get("OverAll", "DiagLat").split(","),dtype=float)
wfile=config.get("OverAll","WeightFile",fallback="Weights.nc")
#
import ModelGrid as MG
......@@ -89,23 +87,11 @@ comm.Barrier()
del w
gc.collect()
if rank ==0 :
if lonint[0] != lonint[1] and latint[0] != latint[1] :
DP.MAPPLOT("MapHydroGrid", lonint, latint, hoverlap, hoverlap.hierarchy_bx, modelgrid.polyll, title="Distance to ocean")
hsuper = IF.HydroSuper(nbvmax, hydrodata, hoverlap, nbasmax)
#
# Plot the hydrological supermesh
#
if rank == 0 :
if lonint[0] != lonint[1] and latint[0] != latint[1] :
DP.SUPERMESHPLOT("MapSuperGrid_Beforelinkup", lonint, latint, hoverlap, hsuper, modelgrid.polyll)
print("=================== LINKUP ====================")
INFO("=================== LINKUP ====================")
hsuper.linkup(hydrodata)
if rank ==0 :
if lonint[0] != lonint[1] and latint[0] != latint[1] :
DP.SUPERMESHPLOT("MapSuperGrid_Afterlinkup", lonint, latint, hoverlap, hsuper, modelgrid.polyll)
#
# Do some memory management and synchronize procs.
#
......@@ -114,7 +100,7 @@ comm.Barrier()
del hoverlap
gc.collect()
print("=================== Compute fetch ====================")
INFO("=================== Compute fetch ====================")
t = time.time()
hsuper.fetch(part)
comm.Barrier()
......@@ -123,7 +109,7 @@ print("Time for fetch: {:0.2f} s.".format(t1-t))
comm.Barrier()
if DumpHydroSuper :
print("Dumping HydroSuper")
INFO("Dumping HydroSuper")
hsuper.dumpnetcdf(OutGraphFile.replace(".nc","_HydroSuper.nc"), gg, modelgrid, part)
print("Rank : {0} - Basin_count Before Truncate : ".format(part.rank), hsuper.basin_count)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment