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