Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
geopat
geopat
Commits
a4d89fb2
Commit
a4d89fb2
authored
Jul 30, 2019
by
Dumoulin Nicolas
Browse files
shapefiles written in post-process step, useless here
parent
8e53a37c
Changes
1
Hide whitespace changes
Inline
Side-by-side
scenariosAleatoires/MCMC.py
View file @
a4d89fb2
...
...
@@ -145,27 +145,6 @@ class MCMC:
scenarios
.
retain
(
pareto_mask
)
return
scenarios
def
write_data
(
self
,
iter_nb
,
scenarios
):
print
(
' Writing modified patches of scenarios'
)
# Writing shapefiles
start_time
=
time
.
time
()
shp_dir
=
self
.
outputdir
+
'/patches_iter_{0:03d}'
.
format
(
iter_nb
)
os
.
makedirs
(
shp_dir
)
counter
=
0
for
index
,
scenario
in
tqdm
(
scenarios
.
cultgeopat
.
iterrows
(),
total
=
len
(
scenarios
.
cultgeopat
)):
#if scenarios.scores.loc[index,'full_reallocated']:
counter
+=
1
concat
=
pd
.
concat
([
self
.
patches
,
scenario
.
to_frame
(
"newcult"
)],
axis
=
1
)
concat
=
concat
[
concat
[
'init_cult'
]
!=
concat
[
'newcult'
]]
if
len
(
concat
)
>
0
:
for
c
in
[
'newcult'
,
'cultgeopat'
,
'init_cult'
]:
patutils
.
decode_cultgeopat
(
concat
,
c
)
concat
.
to_file
(
shp_dir
+
'/{:03d}_{}'
.
format
(
iter_nb
,
index
),
encoding
=
'utf-8'
)
elapsed_time
=
time
.
time
()
-
start_time
#print(' {} shapefiles (only scenario fully reallocated) written in {}'.format(counter, time.strftime("%M:%S", time.gmtime(elapsed_time))))
print
(
' {} shapefiles written in {}'
.
format
(
counter
,
time
.
strftime
(
"%M:%S"
,
time
.
gmtime
(
elapsed_time
))))
def
run
(
self
):
# Start with initial scenario
scenarios
=
ScenariosStack
(
self
.
indicators
,
self
.
reallocator
,
self
.
patches
)
...
...
@@ -182,9 +161,8 @@ class MCMC:
if
scenarios
.
allFullReallocated
():
print
(
'All scenarios are fully reallocated. Simulation finished.'
)
break
self
.
write_data
(
nb_iteration
,
scenarios
)
return
scenarios
if
__name__
==
'__main__'
:
mcmc
=
MCMC
(
'MCMC_config.yml'
)
scenario
=
mcmc
.
run
()
scenario
s
=
mcmc
.
run
()
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