Newer
Older
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
#!/usr/bin/env python3
import shapefile
import numpy as np
import matplotlib.pyplot as plt
def plot_distr_funct(X, xlabel):
plt.figure()
plt.hist(X, bins="auto")
plt.xlabel(xlabel)
plt.ylabel("number of occurrences")
X = np.array(X)
X.sort()
nx = np.size(X)
print(xlabel + ":")
print("minimum value:", X[0])
print("maximum value:", X[-1])
print("number of values:", nx, "\n")
plt.figure()
plt.plot(X, (1 + np.arange(nx)) / nx)
plt.xlabel(xlabel)
plt.ylabel("distribution function")
def get_var(end_filename):
with shapefile.Reader("extremum" + end_filename) as extremum, \
shapefile.Reader("outermost_contour" + end_filename) as outermost_cont:
speed = []
r_outer = []
for rec_extr, rec_outer in zip(extremum.iterRecords(),
outermost_cont.iterRecords()):
if rec_extr.speed != 1e4: speed.append(rec_extr.speed)
if rec_extr.valid == 1: r_outer.append(rec_outer.r_eq_area)
with shapefile.Reader("max_speed_contour" + end_filename) \
as max_speed_contour:
r_speed = []
for rec in max_speed_contour.iterRecords():
if rec.r_eq_area != - 100: r_speed.append(rec.r_eq_area)
return speed, r_outer, r_speed
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-e", "--end_filename",
help = "add character string after "
"extremum, outermost contour and max_speed_contour",
default = "")
args = parser.parse_args()
speed, r_outer, r_speed = get_var(args.end_filename)
plot_distr_funct(speed, "speed, in m s-1")
plt.axhline(0.5, linestyle = "--", color = "black")
plt.axvline(linestyle = "--", color = "black")
plot_distr_funct(r_outer, "equivalent radius of outermost contour, in km")
plot_distr_funct(r_speed, "equivalent radius of max-speed contour, in km")
plt.show()