To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 7279daa2 authored by mastc's avatar mastc 🎯
Browse files

Patch/plotting

parent 4516acd5
......@@ -28,6 +28,13 @@ class PlotGeneral:
self._fig_complex, self._ax_complex = plt.subplots()
self._ax_complex.loglog(abs(self.x_data), abs(self.y_data), marker="o")
self._fig_line, self._ax_line = plt.subplots()
self._ax_line.plot(self.x_data, self.y_data)
self._axes = [self._ax_line, self._ax_complex, self._ax_semilogy]
plt.style.use('ggplot')
"""
......@@ -51,19 +58,18 @@ class PlotGeneral:
@y_data.setter
def y_data(self, value):
self._y_data.value = value
print("e")
if len(self.x_data) == len(self.y_data):
self._update_data()
def _update_data(self) -> None:
self._ax_complex.lines[0].set_data(self.x_data, self.y_data)
self._ax_semilogy.lines[0].set_data(self.x_data, self.y_data)
self._ax_complex.relim()
self._ax_semilogy.relim()
self._ax_complex.autoscale_view()
self._ax_semilogy.autoscale_view()
self._fig_semilogy.canvas.draw()
self._fig_complex.canvas.draw()
for ax in self._axes:
ax.lines[0].set_data(self.x_data, self.y_data)
ax.relim()
ax.autoscale_view()
try:
ax.canvas.draw()
except AttributeError:
pass
@property
def x_label(self) -> str:
......@@ -71,8 +77,8 @@ class PlotGeneral:
@x_label.setter
def x_label(self, value):
self._ax_semilogy.set_xlabel(value)
self._ax_complex.set_xlabel(value)
for ax in self._axes:
ax.set_xlabel(value)
self._x_label.value = value
@property
......@@ -81,8 +87,8 @@ class PlotGeneral:
@y_label.setter
def y_label(self, value):
self._ax_semilogy.set_ylabel(value)
self._ax_complex.set_ylabel(value)
for ax in self._axes:
ax.set_ylabel(value)
self._y_label.value = value
@property
......@@ -91,8 +97,8 @@ class PlotGeneral:
@title.setter
def title(self, value):
self._ax_semilogy.set_title(value)
self._ax_complex.set_title(value)
for ax in self._axes:
ax.set_title(value)
self._title.value = value
def rescale(self, resolution=None):
......
......@@ -10,19 +10,22 @@ class PlotARF(PlotGeneral):
self.arf = ARF
self.wavetype = self.arf.field.wave_type
def plot_ARF(self, res=None) -> None:
def plot_ARF(self, wavelength=None, res=None) -> None:
"""
plots ARF with respect to time or position depending on the wavetype
"""
if res is not None:
self.rescale(res)
if res is None:
self.resolution = 1000
if wavelength is None:
wavelength = 0.015
self.title = "The radiation force over the position"
self.x_data = np.linspace(-1e-3, 1e-3, 1000)
self.x_label = "Position"
self.x_data = np.linspace(
-wavelength / 2.0, wavelength / 2.0, self.resolution)
self.x_label = "Position (m)"
self.y_label = "ARF (N)"
_ = []
for dpos in self.x_data:
self.arf.position = dpos
_.append(abs(self.arf.acoustic_radiation_force()))
_.append((self.arf.acoustic_radiation_force()))
self.y_data = _
self.figshow(self._fig_semilogy)
self.figshow(self._fig_line)
......@@ -57,4 +57,5 @@ class TestPlotARF(BaseTestComposite):
def test_plot_arf(self) -> None:
a = PlotAcoustofluidics(ARF=self.cls)
a.plot_ARF()
a.plot_ARF(res=1000, wavelength=0.0015)
print(self.cls.field.lambda_f)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment