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
Open sidebar
IPSL
LMD
InTro
RoutingPP
Commits
50779cac
Commit
50779cac
authored
Feb 03, 2021
by
Lucia Rinchiuso
Browse files
Waiting process
parent
202c03ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
3 deletions
+46
-3
F90tools.py
F90tools.py
+22
-0
StationDiag.py
StationDiag.py
+24
-3
No files found.
F90tools.py
View file @
50779cac
...
...
@@ -2,6 +2,7 @@ import sys
import
os
import
inspect
import
importlib
from
multiprocessing
import
Pool
def
localdir
(
follow_symlinks
=
True
):
if
getattr
(
sys
,
'frozen'
,
False
):
# py2exe, PyInstaller, cx_Freeze
...
...
@@ -34,3 +35,24 @@ def compilef90(mod, mpi=None) :
mpimod
.
COMM_WORLD
.
Barrier
()
return
def
waitingAnimation
(
n
):
import
time
n
=
n
%
3
+
1
dots
=
n
*
'.'
+
(
3
-
n
)
*
' '
sys
.
stdout
.
write
(
'
\r
Waiting '
+
dots
)
sys
.
stdout
.
flush
()
time
.
sleep
(
0.5
)
return
n
def
waitingProcess
(
f
,
x
):
with
Pool
(
processes
=
1
)
as
pool
:
res
=
pool
.
apply_async
(
f
,
(
x
,))
waiting
,
n
=
True
,
0
while
waiting
:
try
:
waiting
=
not
res
.
successful
()
R
=
res
.
get
()
except
AssertionError
:
n
=
waitingAnimation
(
n
)
sys
.
stdout
.
write
(
'
\r
Loading complete
\n
'
)
return
R
StationDiag.py
View file @
50779cac
...
...
@@ -53,12 +53,33 @@ import Locations as LO
#
# Read all the gauging stations positoned in the routing graph
#
L
=
LO
.
PlacedLocations
(
GraphFile
)
def
fL
(
GraphFile
):
L
=
LO
.
PlacedLocations
(
GraphFile
)
return
L
print
(
'
\n
Starting loading locations'
)
L
=
F90T
.
waitingProcess
(
fL
,
GraphFile
)
#print('\n Starting loading locations')
#with Pool(processes=1) as pool:
# res = pool.apply_async(fL, (GraphFile,))
# waiting, n = True, 0
# while waiting:
# try:
# waiting = not res.successful()
# L = res.get()
# except AssertionError:
# n = F90T.waitingAnimation(n)
# sys.stdout.write('\r Loading complete\n')
#
# Read all the stations in the river gauge (GRDC) data base
#
A
=
AS
.
AllStations
()
A
.
fetchnetcdf
(
GRDCFile
,
metaonly
=
True
,
region
=
[
L
.
lonrange
,
L
.
latrange
])
def
fA
(
GRDCFile
):
A
=
AS
.
AllStations
()
A
.
fetchnetcdf
(
GRDCFile
,
metaonly
=
True
,
region
=
[
L
.
lonrange
,
L
.
latrange
])
return
A
print
(
'
\n
Starting loading GRDC file'
)
A
=
F90T
.
waitingProcess
(
fA
,
GRDCFile
)
#
# Find the IDs of all the stations and exclusions listed in stations.def
#
...
...
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