Modification des emplacements des figures + Retour à 3D carré + Ajout de v_eff sur time et vect

main
Gaël Pongnot 2 years ago
parent df79768e96
commit 5f17cae5f9
  1. 62
      MLI_vectorielle.py

@ -26,6 +26,7 @@ class TriPlot_TimeAxe(Axes):
self.v_max = v_max
self.phi = phi
self.v_ref = np.zeros(self.phasor.shape)
self.parameters = {}
return
def setup(self):
@ -49,6 +50,12 @@ class TriPlot_TimeAxe(Axes):
self.scatter(3*[self.phi*PI/180],
[self.v_max*np.cos((self.phi-i*120)*PI/180) for i in range(3)],
c=["C0", "C1", "C2"]))
self.timegraph_plot.append(
self.plot([0, 2*PI], 2*[self.v_max/np.sqrt(2)], c='C4', ls=':')[0]
)
self.timegraph_plot.append(
self.text(0, 0, r"$V_{eff}$", c="C4")
)
return
@ -62,6 +69,10 @@ class TriPlot_TimeAxe(Axes):
[self.v_max*np.cos((self.phi-i*120)*PI/180) for i in range(3)]]
).T
)
self.timegraph_plot[5].set_ydata(2*[self.v_max/np.sqrt(2)])
self.timegraph_plot[5].set_visible(self.parameters["v_eff"])
self.timegraph_plot[6].set_position((23/12*PI, 10+self.v_max/np.sqrt(2)))
self.timegraph_plot[6].set_visible(self.parameters["v_eff"])
return
def set_vmax(self, v_max):
@ -74,6 +85,7 @@ class TriPlot_TimeAxe(Axes):
return
def set_parameters(self, p):
self.parameters["v_eff"] = p.get("v_eff", False)
return
@ -153,6 +165,14 @@ class TriPlot_VectAxe(PolarAxes):
)
for i in range(3)
]
self.plot_list.append(
self.plot(
self.theta, self.v_max/np.sqrt(2)*np.ones(self.theta.shape),
c='C4', ls=':', visible=self.parameters.get("v_eff", False)
)[0]
)
return
def refresh(self):
@ -190,6 +210,8 @@ class TriPlot_VectAxe(PolarAxes):
PI*(1-np.sign(np.cos((self.phi-i*120)*PI/180)))/2, 0)
+ self.transData
)
self.plot_list[4].set_ydata(self.v_max/np.sqrt(2)*np.ones(self.theta.shape))
self.plot_list[4].set_visible(self.parameters.get("v_eff", False))
return
def set_vmax(self, v_max):
@ -203,6 +225,7 @@ class TriPlot_VectAxe(PolarAxes):
def set_parameters(self, p):
self.parameters["projection"] = p.get("projection", False)
self.parameters["v_eff"] = p.get("v_eff", False)
return
@ -237,10 +260,31 @@ class TriPlot_3DAxe(Axes3D):
self.set_ylim([-1.6*self.v_max, 1.6*self.v_max])
self.view_init(vertical_axis='y')
self.set_zlim([0, 2*PI])
self.set_zticks([i*PI/6 for i in range(13)])
self.set_zticklabels([str(30*i)+"°" for i in range(13)])
self.set_box_aspect((4,1,1))
self.set_zticks([i*PI/2 for i in range(5)])
self.set_zticklabels([str(90*i)+"°" for i in range(5)])
#self.set_box_aspect((4,1,1))
self.set_facecolor("#00000000")
self.set_title("Visualisation 3D")
self.set_xlabel("Partie réelle")
self.set_ylabel("Partie imaginaire")
self.set_zlabel("Angle")
# Début de code pour un plan "phi" dans l'espace 3D
# matplotlib ne gère pas les transformations 3D...
# X = [-self.v_max, self.v_max]
# Y = [-self.v_max, self.v_max]
# XX, YY = np.meshgrid(X, Y)
# Z = np.zeros((2,2))
# self.plot_list.append(
# self.plot_surface(XX, YY, Z, color="#ff000080")
# )
# self.plot_list[-1].set_transform(
# np.array([[0, 0, 0, 0],
# [0, 0, 0, 0],
# [0, 0, 0, self.phi*PI/180],
# [0, 0, 0, 1]])
# )
return
def set_vmax(self, v_max):
@ -257,12 +301,15 @@ class TriPlot_3DAxe(Axes3D):
return
def refresh(self):
for i, plot in enumerate(self.plot_list):
for i, plot in enumerate(self.plot_list[:3]):
plot.set_data_3d(
self.v_re[i,:],
self.v_im[i,:],
self.theta
)
return
class TriPlot:
@ -284,9 +331,9 @@ class TriPlot:
self.timeaxe = TriPlot_TimeAxe(self.v_max, self.phi,
self.fig, [0.1, 0.5, 0.4, 0.4])
self.vectaxe = TriPlot_VectAxe(self.v_max, self.phi,
self.fig, [0.5, 0.2, 0.5, 0.6])
self.fig, [0.5, 0.1, 0.4, 0.4])
self.axe3D = TriPlot_3DAxe(self.v_max, self.phi,
self.fig, [0.1, -0.15, 0.4, 0.8])
self.fig, [0.5, 0.6, 0.4, 0.4])
self.axes = [self.vectaxe, self.timeaxe, self.axe3D]
self.amp_slider = Slider(
ax=plt.axes([0.01, 0.1, 0.03, 0.8]),
@ -311,7 +358,7 @@ class TriPlot:
)
self.parameters_check = CheckButtons(
ax=plt.axes([0.9, 0.8, 0.1, 0.2]),
labels=["Projection"]
labels=["Projection", "Valeur efficace"]
)
self.sliders = [self.amp_slider, self.phi_slider]
@ -366,6 +413,7 @@ class TriPlot:
def set_parameters(self, p):
self.parameters["projection"] = p[0]
self.parameters["v_eff"] = p[1]
for axe in self.axes:
axe.set_parameters(self.parameters)
return

Loading…
Cancel
Save