-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_wave_gauges.py
More file actions
146 lines (134 loc) · 3.9 KB
/
plot_wave_gauges.py
File metadata and controls
146 lines (134 loc) · 3.9 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
import math
from fluidity_tools import stat_parser
import matplotlib
import argparse
import glob
import numpy
def main():
parser = argparse.ArgumentParser(
prog="plot wave gauges",
description="""Plot detectors for multilpe fluidity runs"""
)
parser.add_argument(
'-v',
'--verbose',
action='store_true',
help="Verbose output: mainly progress reports.",
default=False
)
parser.add_argument(
'-l',
'--labels',
help="What to call the Fluidity data",
required=True,
nargs='+'
)
parser.add_argument(
'-g',
'--greyscale',
help="Produce greyscale plots",
required=False,
action='store_true',
default=False
)
parser.add_argument(
'output_file',
metavar='output_file',
help='The output file stub. A new figure will be created for each detector.'
)
parser.add_argument(
'detector_files',
nargs="+",
metavar='detector_files',
help='The detector input file stubs to take into account checkpointed detectors'
)
args = parser.parse_args()
verbose = args.verbose
output_file = args.output_file
det_files = args.detector_files
labels = args.labels
grey = args.greyscale
if (grey):
colours = [
'k',
'0.75',
'0.5',
'k-.',
'k:',
'0.25',
]
else:
colours = [
'r',
'b',
'g',
'k',
'DarkBlue',
'Olive',
'DarkGoldenRod',
]
params = {
'legend.fontsize': 7,
'xtick.labelsize': 7,
'ytick.labelsize': 7,
'axes.labelsize' : 7,
'text.fontsize' : 7,
'figure.subplot.left' : 0.18,
'figure.subplot.top': 0.82,
'figure.subplot.right': 0.95,
'figure.subplot.bottom': 0.15,
'text.usetex' : True
}
plt.rcParams.update(params)
total_dets = 34
free_surfaces = []
times = []
d = 0
for dfile in det_files:
filelist = glob.glob( dfile+"*.detectors")
filelist.sort()
i = 0
for fl in filelist:
stat=stat_parser( fl )
d_no = 0
for det in range(1,total_dets+1):
det_str="WaveDetectors_%(#)02d" %{"#": det}
fs = stat['Fields']['FreeSurface'][det_str]
t = stat['ElapsedTime']['value']
t = t/60.0/60.0
if i == 0:
free_surfaces.append(fs)
times.append(t)
else:
index = 0
for tt in t:
if tt > times[d_no+d*ndets][-1]:
break
index += 1
free_surfaces[d_no+d*ndets] = numpy.append(free_surfaces[d_no+d*ndets],fs[index:-1])
times[d_no+d*ndets] = numpy.append(times[d_no+d*ndets],t[index:-1])
d_no += 1
i += 1
d += 1
i = 0
for det in range(1,total_dets+1):
fig_summary = plt.figure(figsize=(3.0,2.5),dpi=180)
fig_summary.figurePatch.set_alpha(0.5)
ax = fig_summary.add_subplot(111)
ax.axesPatch.set_alpha(1.0)
det_str="WaveDetectors_%(#)02d" %{"#": det}
d = 0
for dfile in det_files:
plt.plot(times[i+d*ndets],free_surfaces[i+d*ndets], colours[d], lw=1,label=labels[d])
d+=1
plt.xlabel("Time (hrs)")
ax.legend(loc='upper center', bbox_to_anchor=(0.5, 1.295),
ncol=2, fancybox=True, shadow=True)
plt.ylabel("Free Surface (m)")
plt.savefig(output_file+"det_"+str(det)+".pdf", dpi=90)
i+=1
if __name__ == "__main__":
main()