-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathInterferenceMap.py
More file actions
58 lines (49 loc) · 1.89 KB
/
Copy pathInterferenceMap.py
File metadata and controls
58 lines (49 loc) · 1.89 KB
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
import numpy as np
from PyQt5.QtWidgets import *
import matplotlib.pyplot as plt
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
from matplotlib.figure import Figure
from Array import Array
class FieldPlotWidget(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.setup_ui()
self.color = np.random.rand(3,)
def setup_ui(self):
layout = QVBoxLayout()
self.figure = Figure()
self.canvas = FigureCanvasQTAgg(self.figure)
self.ax_field = self.figure.add_subplot(111)
self.figure.tight_layout()
layout.addWidget(self.canvas)
self.setLayout(layout)
def update_plot(self, arrays:list[Array],extent = [-15, 15, 0, 10]):
if len(arrays) == 0:
#remove plot
self.ax_field.clear()
self.figure.clear()
self.canvas.draw()
return
x = np.linspace(-15, 15, 200)
y = np.linspace(0, 10, 200)
field = arrays[0].calculate_field(x,y)
for i, array in enumerate(arrays[1:], 1):
field += array.calculate_field(x,y)
# Normalize field to be above 0
# field = field - np.min(field)
self.ax_field.clear()
self.figure.clear()
self.ax = self.figure.add_subplot(111)
im = self.ax.imshow(field, extent=extent, aspect='equal',
cmap='jet', origin='lower')
self.figure.colorbar(im, ax=self.ax, orientation='vertical', fraction=0.046, pad=0.04,shrink=0.8)
self.ax.set_xlabel('x (m)')
self.ax.set_ylabel('y (m)')
self.ax.set_position([0.0, 0.1, 0.9, 0.8])
self.canvas.draw()
def plot_target_point(self,x,y):
if x > 6 or x < -6 or y > 10 or y < 0:
return
self.ax.plot(x, y, 'g*', markersize=15, label='Target Point')
self.ax.legend()
self.canvas.draw()