-
Notifications
You must be signed in to change notification settings - Fork 131
/
Copy pathexample_statistical_input.py
50 lines (43 loc) · 1.35 KB
/
example_statistical_input.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
49
50
import os
import click
import numpy as np
from matplotlib import pyplot as plt
from windrose import WindroseAxes
FILENAME_DEFAULT = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"amalia_directionally_averaged_speeds.txt",
)
@click.command()
@click.option("--filename", default=FILENAME_DEFAULT, help="Input filename")
def main(filename):
fig = plt.figure(figsize=(12, 8), dpi=80, facecolor="w", edgecolor="w")
ax = WindroseAxes(fig, [0.1, 0.1, 0.8, 0.8], facecolor="w")
fig.add_axes(ax)
windRose = np.loadtxt(filename)
indexes = np.where(windRose[:, 1] > 0.1)
windDirections = windRose[indexes[0], 0]
windSpeeds = windRose[indexes[0], 1]
# convert from mean wind speed to weibull scale factor
# windSpeeds = windRose[indexes[0], 1] * 2 / np.sqrt(np.pi)
windFrequencies = windRose[indexes[0], 2]
# size = len(windDirections)
ax.box(
windDirections,
windSpeeds,
frequency=windFrequencies,
mean_values=1,
bins=[15, 18, 20, 23, 25],
nsector=72,
)
# ax.box(
# windDirections,
# [[windSpeeds[i], 2] for i in range(len(windSpeeds))],
# frequency=windFrequencies,
# weibull_factors=1,
# bins=[15, 18, 20, 23, 25],
# nsector=72,
# )
ax.set_yticklabels([])
plt.show()
if __name__ == "__main__":
main()