Skip to content

Commit e963b04

Browse files
committed
boat image
1 parent 8bd64b8 commit e963b04

File tree

4 files changed

+59
-11
lines changed

4 files changed

+59
-11
lines changed

MyCode/Bayes Filter/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
* Mesurement model
1414
* Main window
1515
* Key press plot
16+
* Main window handling class
17+
* B. F. calculations
18+
* draw boat
1619

1720
### Reference
1821

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from skylynx.utils import cli_args
2+
from utils import *
3+
import matplotlib.pyplot as plt
4+
import numpy as np
5+
import matplotlib.image as mpimg
6+
from matplotlib.offsetbox import TextArea, DrawingArea, OffsetImage, AnnotationBbox
7+
8+
9+
class BayesFilterBoat(object):
10+
11+
def __init__(self):
12+
pass
13+
14+
def hello(self, msg):
15+
print(msg)
16+
17+
18+
if __name__ == "__main__":
19+
20+
boat_bf = BayesFilterBoat()
21+
boat_bf.hello('sameera')

MyCode/Bayes Filter/test.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from utils import *
33
import matplotlib.pyplot as plt
44
import numpy as np
5+
import matplotlib.image as mpimg
6+
from matplotlib.offsetbox import TextArea, DrawingArea, OffsetImage, AnnotationBbox
57

68

79
def ax_set_settings(ax):
@@ -15,6 +17,15 @@ def ax_set_settings(ax):
1517

1618

1719
click_counter = 0
20+
simulation_scope = 10
21+
boat = mpimg.imread('/home/sameera/Downloads/sailboat.png')
22+
23+
24+
def draw_boat(ax, x=0):
25+
global boat
26+
imagebox = OffsetImage(boat, zoom=0.2)
27+
ab = AnnotationBbox(imagebox, (x, 0.8), frameon=False)
28+
ax.add_artist(ab)
1829

1930

2031
def get_color_label():
@@ -39,17 +50,33 @@ def onclick(event):
3950
ax.clear()
4051
data = np.random.random((10,))
4152
c, l = get_color_label()
42-
ax.scatter(data, data, c=c, label=l)
53+
p = [0.5, 0.5, 1]
54+
y = norm(p)
55+
y = np.concatenate((y, np.zeros(simulation_scope-len(p),)))
56+
x = np.arange(simulation_scope)
57+
58+
bar_plot(ax, x, y, color='tab:blue', label='Init')
59+
draw_boat(ax, 2)
4360
ax_set_settings(ax)
4461

4562
fig.canvas.draw()
4663
click_counter += 1
4764

48-
fig, axs = plt.subplots(1, 1, figsize=(14, 5))
65+
fig, axs = plt.subplots(1, 1, figsize=(8, 4))
66+
global simulation_scope
4967
ax = axs
5068

5169
cid = fig.canvas.mpl_connect('key_release_event', onclick)
52-
ax.plot(np.arange(0, 1, 0.1), c='tab:blue', label='Init')
70+
71+
# Initial p(x)
72+
p = [0.6, 0.5]
73+
y = np.array(p)
74+
y = np.concatenate((y, np.zeros(simulation_scope-len(p),)))
75+
x = np.arange(simulation_scope)
76+
77+
# ax.plot(np.arange(0, 1, 0.1), c='tab:blue', label='Init')
78+
bar_plot(ax, x, y, color='tab:blue', label='Init')
79+
draw_boat(ax)
5380
ax_set_settings(ax)
5481
plt.show()
5582

@@ -59,15 +86,12 @@ def task_2():
5986
"""
6087

6188
fig, axs = plt.subplots(1, 1, figsize=(8, 4))
62-
6389
simulation_scope = 10
6490

6591
# Initial p(x)
6692
p = [0.5, 0.5]
6793
y = np.array(p)
68-
6994
y = np.concatenate((y, np.zeros(simulation_scope-len(p),)))
70-
7195
x = np.arange(simulation_scope)
7296

7397
ax = axs

MyCode/Bayes Filter/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22

33

4-
def bar_plot(ax, x, y, color=None):
4+
def bar_plot(ax, x, y, color=None, label=''):
55
"""Bar Plot
66
77
Parameters
@@ -12,15 +12,15 @@ def bar_plot(ax, x, y, color=None):
1212
1313
"""
1414

15-
ax.set_axisbelow(True)
16-
ax.grid(ls='--')
17-
ax.bar(x, y, color=color, width=0.5)
15+
# ax.set_axisbelow(True)
16+
# ax.grid(ls='--')
17+
ax.bar(x, y, color=color, width=0.5, label=label)
1818
# plt.xlabel("File names")
1919
# plt.ylabel("Execution time (seconds)")
2020
# plt.title("Effects of Numba (loop of 1e6)")
2121
# plt.xticks(x_pos, x)
2222
# plt.savefig('stats.pdf')
23-
ax.set_ylim(0, 1)
23+
# ax.set_ylim(0, 1)
2424

2525

2626
def norm(x):

0 commit comments

Comments
 (0)