Newer
Older
def read(dirname):
"""Read the three dbf files in dirname and return speed, radius and
amplitude of outermost contour, radius and amplitude of maximum
speed contour, as Numpy arrays.
Select valid speed values.
extr_file = path.join(dirname, "extremum")
outer_file = path.join(dirname, "outermost_contour")
max_speed_file = path.join(dirname, "max_speed_contour")
with shapefile.Reader(extr_file) as extremum, shapefile.Reader(
outer_file
) as outerm_cont, shapefile.Reader(max_speed_file) as max_speed_cont:
rad_outer = []
rad_speed = []
amp_outer = []
amp_speed = []
for rec_extr, rec_outer, rec_max in zip(
extremum.iterRecords(),
outerm_cont.iterRecords(),
max_speed_cont.iterRecords(),
):
if rec_extr.speed != 1e4:
speed.append(rec_extr.speed)
rad_outer.append(rec_outer.r_eq_area)
amp_outer.append(rec_extr.ssh - rec_outer.ssh)
rad_speed.append(rec_max.r_eq_area)
amp_speed.append(rec_extr.ssh - rec_max.ssh)
return {
"speed": np.array(speed),
"rad_outer": np.array(rad_outer),
"rad_speed": np.array(rad_speed),
"amp_outer": np.abs(np.array(amp_outer)),
"amp_speed": np.abs(np.array(amp_speed)),
}
"""dict_list: list of dictionaries. label: list of labels, one label
for each dictionary.
jumble_matplotlib.fig_hist(
"speed, in m s-1", [d["speed"] for d in dict_list], label
)
jumble_matplotlib.fig_distr_funct(
"speed, when positive, in m s-1",
jumble_matplotlib.fig_distr_funct(
"speed, when negative, in m s-1",
[-d["speed"][d["speed"] < 0] for d in dict_list],
label,
)
jumble_matplotlib.fig_hist(
"equivalent radius of outermost contour, in km",
jumble_matplotlib.fig_distr_funct(
"equivalent radius of outermost contour, in km",
jumble_matplotlib.fig_hist(
"equivalent radius of max-speed contour, in km",
[d["rad_speed"] for d in dict_list],
label,
)
jumble_matplotlib.fig_distr_funct(
"equivalent radius of max-speed contour, in km",
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
[d["rad_speed"] for d in dict_list],
label,
)
jumble_matplotlib.fig_hist(
"amplitude of outermost contour, in m",
[d["amp_outer"] for d in dict_list],
label,
)
jumble_matplotlib.fig_distr_funct(
"amplitude of outermost contour, in m",
[d["amp_outer"] for d in dict_list],
label,
)
jumble_matplotlib.fig_hist(
"amplitude of max-speed contour, in m",
[d["amp_speed"] for d in dict_list],
label,
)
jumble_matplotlib.fig_distr_funct(
"amplitude of max-speed contour, in m",
[d["amp_speed"] for d in dict_list],
label,
)
if __name__ == "__main__":
sys.exit(
"Required argument: directory containing collection of "
"shapefiles"
)
plot_all([d])