-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_single_rose.py
52 lines (40 loc) · 1.53 KB
/
plot_single_rose.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
51
52
import math
import numpy as np
import pandas as pd
from rosely import WindRose
def plot_single_currentrose(t,depth_avg_us,depth_avg_vs, site_name):
wd =np.array(list(map(math.atan2,depth_avg_us, depth_avg_vs)))
ws = np.array(np.sqrt(depth_avg_us**2 + depth_avg_vs**2 ))
df = pd.DataFrame({'date':t,'ws':ws,'wd':wd*180/np.pi+180})
WR = WindRose(df)
WR.calc_stats(normed=True, bins=6)
fg = WR.plot(
colors='Jet',template='plotly_dark',
title='<b>current speeds and directions</b>',
output_type='return',range_r =[0, 40],
colors_reversed=False,
height=400,
width=400,
labels={"<b>speed":"current speed (m/s)</b>"},
# hovertemplate = 'Price: $%{y:.2f}'+'<br>Week: %{x}',
)
# update hovertemplate to add site names
for i in range(len(fg['data'])):
fg['data'][i].hovertemplate = "{}{}".format(f"site name: {site_name}<br>",fg['data'][i].hovertemplate)
fg.update_layout(
# title_text=f"depth averaged current speeds and directions",
legend=dict(
yanchor="middle",
xanchor="left",
x=1.1,
y=0.75,
orientation='v'),
margin=dict(
l=20,
r=0,
b=20,
t=80,
pad = 0
)
)
return fg