From 3f53042e14c0bc47480bdef639ce4e723fe7438a Mon Sep 17 00:00:00 2001 From: Ross Knapman Date: Sat, 4 Mar 2023 20:43:15 +0100 Subject: [PATCH] User can now pass quiver arguments --- MicromagneticAnalysisTools/Animate.py | 20 ++++++++++++++++---- MicromagneticAnalysisTools/Plot.py | 20 ++++++++++++++++++-- setup.py | 2 +- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/MicromagneticAnalysisTools/Animate.py b/MicromagneticAnalysisTools/Animate.py index a717679..0cab5aa 100644 --- a/MicromagneticAnalysisTools/Animate.py +++ b/MicromagneticAnalysisTools/Animate.py @@ -122,11 +122,16 @@ def __init__(self, limits=None, length_units=None, step=1, - quiver_colour=[1., 1., 1.], start_file = None, end_file = None, rectangle_fracs = None, - out_name = None): + out_name = None, + quiver_colour = [1., 1., 1.], + quiver_scale = 1., + quiver_headwidth = 6, + quiver_headlength = 10, + quiver_headaxislength = 10, + quiver_linewidth = 5): self.plot_type = plot_type self.directory = directory self.fig = fig @@ -144,11 +149,16 @@ def __init__(self, self.limits = limits self.length_units = length_units self.step = step - self.quiver_colour = quiver_colour self.start_file = start_file self.end_file = end_file self.rectangle_fracs = rectangle_fracs self.out_name = out_name + self.quiver_colour = quiver_colour + self.quiver_scale = quiver_scale + self.quiver_headwidth = quiver_headwidth + self.quiver_headlength = quiver_headlength + self.quiver_headaxislength = quiver_headaxislength + self.quiver_linewidth = quiver_linewidth self.files_to_scan = Read.getFilesToScan(self.directory, self.start_file, self.end_file) assert len(self.files_to_scan) != 0 @@ -176,7 +186,9 @@ def __init__(self, ax=self.ax, z_index=self.z_index, component=self.component, plot_quiver=self.plot_quiver, plot_impurity=self.plot_impurity, plot_pinning=self.plot_pinning, show_component=self.show_component, interpolation=self.interpolation, limits=self.limits, length_units=self.length_units, step=self.step, - quiver_colour=self.quiver_colour) + quiver_colour=self.quiver_colour, quiver_scale=self.quiver_scale, quiver_headwidth=self.quiver_headwidth, + quiver_headlength=self.quiver_headlength, quiver_headaxislength=quiver_headaxislength, + quiver_linewidth=self.quiver_linewidth) if self.plot_quiver: if plot_type == 'quiveronly': diff --git a/MicromagneticAnalysisTools/Plot.py b/MicromagneticAnalysisTools/Plot.py index beb4f12..b6558da 100644 --- a/MicromagneticAnalysisTools/Plot.py +++ b/MicromagneticAnalysisTools/Plot.py @@ -160,6 +160,11 @@ class MagnetizationPlotter: max_skyrmion_density(float64, optional): The maximum skyrmion number density to be plotted (corresponds to vmax and -vmin in `imshow`). step (int, optional): For the quiver plot, how many cells should be skipped between points. quiver_colour (List[float64], optional): List of form `[R, G, B]` for colour of arrows. + quiver_scale (float64, optional): scale option for matplotlib.pyplot.quiver. + quiver_headwidth (float64, optional): headwidth option for matplotlib.pyplot.quiver. + quiver_headlength (float64, optional): headlength option for matplotlib.pyplot.quiver. + quiver_headaxislength (float64, optional): headaxislength option for matplotlib.pyplot.quiver. + quiver_headlinewidth (float64, optional): headlinewidth option for matplotlib.pyplot.quiver. """ @@ -179,7 +184,12 @@ def __init__(self, length_units=None, max_skyrmion_density=None, step=1, - quiver_colour=[0, 0, 0]): + quiver_colour=[0, 0, 0], + quiver_scale=3., + quiver_headwidth=10, + quiver_headlength=20, + quiver_headaxislength=20, + quiver_linewidth=5): self.plot_type = plot_type self.directory = directory self.plot_file = plot_file @@ -196,6 +206,11 @@ def __init__(self, self.max_skyrmion_density = max_skyrmion_density self.step = step self.quiver_colour = quiver_colour + self.quiver_scale = quiver_scale + self.quiver_headwidth = quiver_headwidth + self.quiver_headlength = quiver_headlength + self.quiver_headaxislength = quiver_headaxislength + self.quiver_linewidth = quiver_linewidth self.Lx, self.Ly = Read.sampleExtent(self.directory) self.m_array = df.Field.fromfile(self.directory + '/' + self.plot_file).array @@ -287,7 +302,8 @@ def _plot_quiver(self): colour_array = self._get_quiver_colour_array(magnetization_array) self.quiver_plot = self.ax.quiver(Y.T, X.T, magnetization_array[:, :, 0].T / in_plane_magnitude, magnetization_array[:, :, 1].T / in_plane_magnitude, color=colour_array, units='xy', scale_units='xy', pivot='mid', - headwidth=6, headlength=10, headaxislength=10, linewidth=5) + scale=self.quiver_scale, headwidth=self.quiver_headwidth, headlength=self.quiver_headlength, headaxislength=self.quiver_headaxislength, + linewidth=self.quiver_linewidth) def _plot_impurity(self): impurity_array = np.flip(getImpurityArray(self.directory, np.array([0, 1, 0, 0.2]), self.z_index)[ diff --git a/setup.py b/setup.py index 215a4d9..5cf126a 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name="MicromagneticAnalysisTools", - version="0.0.12", + version="0.0.13", description="A collection of tools to analyse data from MuMax3.", author="Ross Knapman", author_email="rjknapman@gmail.com",