Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Docker-in-Docker (DinD) capabilities of public runners deactivated.
More info
Open sidebar
IPSL
LMD
InTro
RoutingPP
Commits
0d0799e6
Commit
0d0799e6
authored
Jan 18, 2022
by
Laure Baratgin
Browse files
make Basin_pts deal only with points in the core domain of processors
parent
dabb21bb
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
39 additions
and
44 deletions
+39
-44
Basin_pts.py
Basin_pts.py
+23
-33
GraphHydro.py
GraphHydro.py
+2
-0
Locations.py
Locations.py
+4
-3
RoutingPreProc.py
RoutingPreProc.py
+1
-1
Truncate.py
Truncate.py
+7
-7
tests/Iberia/run_MEDCORDEX.def
tests/Iberia/run_MEDCORDEX.def
+1
-0
tests/Mallorca/run_EuroSW.def
tests/Mallorca/run_EuroSW.def
+1
-0
No files found.
Basin_pts.py
View file @
0d0799e6
...
...
@@ -12,9 +12,9 @@ class PointsList :
#
# Convert basin_pts into a list
#
nbpt
=
basin_pts
.
shape
[
0
]
self
.
landcorelist
=
part
.
landcorelist
points_list
=
[]
for
i
in
range
(
nbpt
):
for
i
in
part
.
landcorelist
:
points_list_i
=
[]
for
j
in
range
(
nb_basin
[
i
]):
points_list_i
.
append
(
basin_pts
[
i
,
j
,
0
:
basin_sz
[
i
,
j
]].
tolist
())
...
...
@@ -23,27 +23,20 @@ class PointsList :
self
.
lon
=
lon
self
.
lat
=
lat
self
.
part
=
part
#if self.part.rank==14 :
#print("Proc 14")
#print('basin_count[0]',basin_count[0])
#print('nb_basin[0]',nb_basin[0] )
return
def
killbas
(
self
,
tokill
,
totakeover
,
numop
,
nbasmax
):
for
i
in
range
(
len
(
tokill
[:,
0
])
):
def
killbas
(
self
,
tokill
,
totakeover
,
numop
,
nbasmax
,
basin_id
):
for
k
,
i
in
enumerate
(
self
.
landcorelist
):
j
=
0
while
len
(
self
.
points_list
[
i
])
>
nbasmax
and
j
<
numop
and
tokill
[
i
,
j
]
!=
0
:
print
(
"proc"
,
self
.
part
.
rank
,
"maille"
,
i
)
print
(
"nbHTU :"
,
len
(
self
.
points_list
[
i
]))
#print("tokill", tokill)
while
len
(
self
.
points_list
[
k
])
>
nbasmax
and
j
<
numop
and
tokill
[
i
,
j
]
!=
0
:
#
print("proc",self.part.rank,"maille",i)
#
print("nbHTU :", len(self.points_list[
k
]))
#print("tokill", tokill
[i]
)
#print("totakeover", totakeover[i])
print
(
"HTU to kill : "
,
tokill
[
i
,
j
]
-
1
)
print
(
"to put in the HTU : "
,
totakeover
[
i
,
j
]
-
1
)
#print("pixels from the HTU to kill : ", self.points_list[i][tokill[i,j]-1])
#print("pixels from the HTU to takeover : ", self.points_list[i][totakeover[i,j]-1])
#print("new pixels list: ",self.points_list[i][totakeover[i,j]-1]+self.points_list[i][tokill[i,j]-1])
self
.
points_list
[
i
][
totakeover
[
i
,
j
]
-
1
]
=
self
.
points_list
[
i
][
totakeover
[
i
,
j
]
-
1
]
+
self
.
points_list
[
i
][
tokill
[
i
,
j
]
-
1
]
del
self
.
points_list
[
i
][
tokill
[
i
,
j
]
-
1
]
#print("HTU to kill : ", tokill[i,j]-1)
#print("to put in the HTU : ", totakeover[i,j]-1)
self
.
points_list
[
k
][
totakeover
[
i
,
j
]
-
1
]
=
self
.
points_list
[
k
][
totakeover
[
i
,
j
]
-
1
]
+
self
.
points_list
[
k
][
tokill
[
i
,
j
]
-
1
]
del
self
.
points_list
[
k
][
tokill
[
i
,
j
]
-
1
]
j
=
j
+
1
return
...
...
@@ -55,24 +48,21 @@ class PointsList :
lon
=
[]
lat
=
[]
HTU_index
=
[]
atm_pt_ref
=
self
.
landcorelist
[
atm_pt
]
for
HTU
in
range
(
len
(
self
.
points_list
[
atm_pt
])):
for
pt
in
range
(
len
(
self
.
points_list
[
atm_pt
][
HTU
])):
x
.
append
(
self
.
points_list
[
atm_pt
][
HTU
][
pt
][
0
]
-
1
)
y
.
append
(
self
.
points_list
[
atm_pt
][
HTU
][
pt
][
1
]
-
1
)
lon
.
append
(
self
.
lon
[
atm_pt
,
x
[
-
1
],
y
[
-
1
]])
lat
.
append
(
self
.
lat
[
atm_pt
,
x
[
-
1
],
y
[
-
1
]])
lon
.
append
(
self
.
lon
[
atm_pt
_ref
,
x
[
-
1
],
y
[
-
1
]])
lat
.
append
(
self
.
lat
[
atm_pt
_ref
,
x
[
-
1
],
y
[
-
1
]])
HTU_index
.
append
(
HTU
+
1
)
if
x
[
-
1
]
==
16
:
print
(
x
[
-
1
],
y
[
-
1
],
HTU_index
[
-
1
])
grid
=
np
.
zeros
((
max
(
y
)
+
1
,
max
(
x
)
+
1
))
lon_plot
=
np
.
zeros
(
max
(
x
)
+
1
)
lat_plot
=
np
.
zeros
(
max
(
y
)
+
1
)
grid
=
np
.
zeros
((
max
(
y
)
+
1
-
min
(
y
),
max
(
x
)
+
1
-
min
(
x
)))
lon_plot
=
np
.
zeros
(
max
(
x
)
+
1
-
min
(
x
))
lat_plot
=
np
.
zeros
(
max
(
y
)
+
1
-
min
(
y
))
for
k
in
range
(
len
(
x
)):
grid
[
y
[
k
],
x
[
k
]]
=
HTU_index
[
k
]
lon_plot
[
x
[
k
]]
=
lon
[
k
]
lat_plot
[
y
[
k
]]
=
lat
[
k
]
grid
=
grid
[
min
(
y
):
max
(
y
)
+
1
,
min
(
x
):
max
(
x
)
+
1
]
print
(
grid
)
grid
[
y
[
k
]
-
min
(
y
),
x
[
k
]
-
min
(
x
)]
=
HTU_index
[
k
]
lon_plot
[
x
[
k
]
-
min
(
x
)]
=
lon
[
k
]
lat_plot
[
y
[
k
]
-
min
(
y
)]
=
lat
[
k
]
#X,Y=np.meshgrid(range(min(x),max(x)+1),range(min(y),max(y)+1))
X2
,
Y2
=
np
.
meshgrid
(
np
.
linspace
(
min
(
lon_plot
),
max
(
lon_plot
),
len
(
lon_plot
)),
np
.
linspace
(
max
(
lat_plot
),
min
(
lat_plot
),
len
(
lat_plot
)))
cmap
=
plt
.
get_cmap
(
'jet'
,
max
(
HTU_index
))
...
...
@@ -81,8 +71,8 @@ class PointsList :
ax
.
coastlines
(
resolution
=
'10m'
)
#fig=plt.pcolormesh(X,Y,grid,cmap=cmap, vmin=1)
fig
=
plt
.
pcolormesh
(
X2
,
Y2
,
grid
,
shading
=
'auto'
,
vmin
=
1
,
cmap
=
cmap
,
transform
=
ccrs
.
PlateCarree
())
for
i
in
range
(
len
(
polyll
[
atm_pt
])
-
1
):
plt
.
plot
([
polyll
[
atm_pt
][
i
][
0
],
polyll
[
atm_pt
][
i
+
1
][
0
]],[
polyll
[
atm_pt
][
i
][
1
],
polyll
[
atm_pt
][
i
+
1
][
1
]],
color
=
"red"
)
for
i
in
range
(
len
(
polyll
[
atm_pt
_ref
])
-
1
):
plt
.
plot
([
polyll
[
atm_pt
_ref
][
i
][
0
],
polyll
[
atm_pt
_ref
][
i
+
1
][
0
]],[
polyll
[
atm_pt
_ref
][
i
][
1
],
polyll
[
atm_pt
_ref
][
i
+
1
][
1
]],
color
=
"red"
)
cbar
=
plt
.
colorbar
(
fig
)
cbar
.
set_label
(
'# of HTU'
)
ax
.
set_xlabel
(
'lon'
)
...
...
GraphHydro.py
View file @
0d0799e6
...
...
@@ -127,6 +127,7 @@ class HydroGraph :
if
self
.
lim_floodcri
<
1
:
self
.
lim_floodcri
=
elevation_precision
*
3.0
#
self
.
landcorelist
=
part
.
landcorelist
self
.
nbasmax
=
nbasmax
self
.
nbpt
=
hydrosuper
.
basin_count
.
shape
[
0
]
nwbas
=
hydrosuper
.
basin_topoind
.
shape
[
1
]
...
...
@@ -179,6 +180,7 @@ class HydroGraph :
ij_list
,
x_list
,
y_list
=
np
.
where
(
cost
==
cost
.
min
())
ib_list
=
[]
for
ij
,
x
,
y
in
zip
(
ij_list
,
x_list
,
y_list
):
ij
=
self
.
landcorelist
.
index
(
ij
)
ib_list
.
append
(
find_in_sublists
(
points_list
.
points_list
[
ij
],[
x
,
y
]))
print
(
"GRDC number : "
,
lid
,
" found in HTUs: "
,
ib_list
)
ij
=
ij_list
[
np
.
argmin
(
self
.
routing_fetch
[
ij_list
,
ib_list
]
/
1.e+6
-
locations
.
upstream
[
i
])]
...
...
Locations.py
View file @
0d0799e6
...
...
@@ -43,9 +43,9 @@ class Locations :
points_file
=
config
.
get
(
"OverAll"
,
"PointsFile"
,
fallback
=
None
)
if
points_file
!=
None
:
self
.
gnbloc
+=
self
.
addgrdcstations
(
points_file
,
bbox
)
self
.
gnbloc
+=
self
.
adddams
(
points_file
,
bbox
)
self
.
gnbloc
+=
self
.
addRESplants
(
points_file
,
bbox
)
self
.
gnbloc
+=
self
.
addRORplants
(
points_file
,
bbox
)
#
self.gnbloc += self.adddams(points_file, bbox)
#
self.gnbloc += self.addRESplants(points_file, bbox)
#
self.gnbloc += self.addRORplants(points_file, bbox)
#
self
.
ij
=
[
-
1
]
*
len
(
self
.
lid
)
self
.
ib
=
[
-
1
]
*
len
(
self
.
lid
)
...
...
@@ -113,6 +113,7 @@ class Locations :
#
g
.
close
()
return
nb
#
# Adds position of location in the HTU graph
#
def
addhtupos
(
self
,
i
,
ij
,
ib
)
:
...
...
RoutingPreProc.py
View file @
0d0799e6
...
...
@@ -151,7 +151,7 @@ print("Rank : {0} - Basin_count Before Truncate : ".format(part.rank), hsuper.ba
TR
(
hsuper
,
part
,
comm
,
modelgrid
,
numop
=
numop
)
print
(
"Rank : {0} - Basin_count After Truncate : "
.
format
(
part
.
rank
),
hsuper
.
basin_count
)
hsuper
.
get_floodcri
(
lim_floodcri
)
#hsuper.points_list.check_Truncate(
1
, modelgrid.polyll)
#hsuper.points_list.check_Truncate(
0
, modelgrid.polyll)
INFO
(
"=================== GraphHydro ===================="
)
hgraph
=
GR
.
HydroGraph
(
nbasmax
,
hsuper
,
part
,
modelgrid
,
hydrodata
.
elevation_precision
)
...
...
Truncate.py
View file @
0d0799e6
...
...
@@ -66,7 +66,7 @@ class trunc:
while
self
.
max_ops_num
==
numop
:
self
.
step1
(
hydrosuper
,
part
)
hydrosuper
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numops
)
hydrosuper
.
points_list
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numop
,
self
.
nbasmax
)
hydrosuper
.
points_list
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numop
,
self
.
nbasmax
,
self
.
basin_id
)
max_bas
=
part
.
domainmax
(
np
.
max
(
self
.
basin_count
))
if
part
.
rank
==
0
:
with
open
(
"check.out"
,
"a+"
)
as
foo
:
...
...
@@ -89,7 +89,7 @@ class trunc:
if
self
.
max_ops_num_core
==
self
.
numop
:
self
.
step2
(
hydrosuper
,
part
,
"core"
)
hydrosuper
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numops
)
hydrosuper
.
points_list
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numop
,
self
.
nbasmax
)
hydrosuper
.
points_list
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numop
,
self
.
nbasmax
,
self
.
basin_id
)
max_bas
=
part
.
domainmax
(
np
.
max
(
self
.
basin_count
))
if
part
.
rank
==
0
:
with
open
(
"check.out"
,
"a+"
)
as
foo
:
...
...
@@ -103,7 +103,7 @@ class trunc:
if
self
.
max_ops_num_halo
==
self
.
numop
:
self
.
step2
(
hydrosuper
,
part
,
"halo"
)
hydrosuper
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numops
)
hydrosuper
.
points_list
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numop
,
self
.
nbasmax
)
hydrosuper
.
points_list
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numop
,
self
.
nbasmax
,
self
.
basin_id
)
max_bas
=
part
.
domainmax
(
np
.
max
(
self
.
basin_count
))
if
part
.
rank
==
0
:
with
open
(
"check.out"
,
"a+"
)
as
foo
:
...
...
@@ -125,7 +125,7 @@ class trunc:
if
self
.
max_ops_num_core
==
self
.
numop
:
self
.
step3
(
hydrosuper
,
part
,
"core"
)
hydrosuper
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numops
)
hydrosuper
.
points_list
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numop
,
self
.
nbasmax
)
hydrosuper
.
points_list
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numop
,
self
.
nbasmax
,
self
.
basin_id
)
max_bas
=
part
.
domainmax
(
np
.
max
(
self
.
basin_count
))
if
part
.
rank
==
0
:
with
open
(
"check.out"
,
"a+"
)
as
foo
:
...
...
@@ -138,7 +138,7 @@ class trunc:
if
self
.
max_ops_num_halo
==
numop
:
self
.
step3
(
hydrosuper
,
part
,
"halo"
)
hydrosuper
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numops
)
hydrosuper
.
points_list
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numop
,
self
.
nbasmax
)
hydrosuper
.
points_list
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numop
,
self
.
nbasmax
,
self
.
basin_id
)
max_bas
=
part
.
domainmax
(
np
.
max
(
self
.
basin_count
))
if
part
.
rank
==
0
:
with
open
(
"check.out"
,
"a+"
)
as
foo
:
...
...
@@ -157,7 +157,7 @@ class trunc:
while
(
self
.
max_ops_num
==
numop
):
self
.
step4
(
hydrosuper
,
part
)
hydrosuper
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numops
)
hydrosuper
.
points_list
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numop
,
self
.
nbasmax
)
hydrosuper
.
points_list
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numop
,
self
.
nbasmax
,
self
.
basin_id
)
max_bas
=
part
.
domainmax
(
np
.
max
(
self
.
basin_count
))
if
part
.
rank
==
0
:
with
open
(
"check.out"
,
"a+"
)
as
foo
:
...
...
@@ -176,7 +176,7 @@ class trunc:
foo
.
write
(
"Step5
\n
"
)
self
.
step5
(
hydrosuper
,
part
)
hydrosuper
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numops
)
hydrosuper
.
points_list
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numop
,
self
.
nbasmax
)
hydrosuper
.
points_list
.
killbas
(
self
.
tokill
,
self
.
totakeover
,
self
.
numop
,
self
.
nbasmax
,
self
.
basin_id
)
max_bas
=
part
.
domainmax
(
np
.
max
(
self
.
basin_count
))
if
part
.
rank
==
0
:
with
open
(
"check.out"
,
"a+"
)
as
foo
:
...
...
tests/Iberia/run_MEDCORDEX.def
View file @
0d0799e6
...
...
@@ -32,3 +32,4 @@ MaxDistErr = 25.0
MaxUpstrErr = 10.0
StructuresFile = Structures.txt
GRDCFile = ../../Stations/Station_Metadata.nc
PointsFile= /homedata/lbaratgin/codes/hydrofiles/Point2Graph/Test.nc
\ No newline at end of file
tests/Mallorca/run_EuroSW.def
View file @
0d0799e6
...
...
@@ -27,3 +27,4 @@ MaxDistErr = 25.0
# Maximum error in the upstream area in %
MaxUpstrErr = 25.0
StructuresFile = Structures.txt
PointsFile= /homedata/lbaratgin/codes/hydrofiles/Point2Graph/Test.nc
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment