-
Notifications
You must be signed in to change notification settings - Fork 11
/
replot.py
48 lines (40 loc) · 1.55 KB
/
replot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import glob
import os
from rivus.main import rivus
import sys
def replot(directory):
"""Recreate result figures for all pickled rivus results in directory
Args:
directory: a directory with 1 or multiple pickled rivus instances
Returns:
Nothing
"""
glob_pattern = os.path.join(directory, '*.pgz')
pickle_filenames = glob.glob(glob_pattern)
data_dir = os.path.join('data', os.path.basename(directory).split('-')[0])
# if directory = 'result/moosh' try to find a suitable building shapefile
# in 'data/moosh'
buildings = None
building_filename = os.path.join(data_dir, 'building')
if os.path.exists(building_filename+'.shp'):
buildings = (building_filename, False) # if True, color buildings
# if data/.../to_edge exists, paint it
shapefiles = None
to_edge_filename = os.path.join(data_dir, 'to_edge')
if os.path.exists(to_edge_filename+'.shp'):
shapefiles = [{'name': 'to_edge',
'color': rivus.to_rgb(192, 192, 192),
'shapefile': to_edge_filename,
'zorder': 1,
'linewidth': 0.1}]
for pf in pickle_filenames:
prob = rivus.load(pf)
figure_basename = os.path.splitext(pf)[0]
if buildings:
figure_basename += '_bld'
rivus.result_figures(prob, figure_basename,
buildings=buildings,
shapefiles=shapefiles)
if __name__ == '__main__':
for directory in sys.argv[1:]:
replot(directory)