5. Visualization and evaluation#

This chapter provides documentation on how to visualize and evaluate data.

5.1. Sample and experimental setup visualization#

At the moment, samples and experimental setups can be inspected with

>>> sample.show()
>>> exp.show()

which will display a 3D view using the k3d package.

tetrax.core.sample.AbstractSample.show(self, show_node_labels=False, show_mag=True, comp='vec', scale=5, show_scaled_mag=True, show_grid=False, show_extrusion=True)#

Show the sample. Displays the mesh and, if available, the magnetization(s).


If true, shows the label associated to each node.


Show the magnetization (or magnetizations, in the case of antiferromagnetic samples).

comp{“vec”, “x”, “y”, “z”}

Determines which component will be plotted.


Determines the scale of the vector glyphs used to visualize the magnetization (default is 5).


Scale magnetization with spatially dependent saturation magnetization (default is True).


Show background grid (default is False).


Show full 3D mesh by extruding 1D or 2D mesh (default is True).

tetrax.core.experimental_setup.ExperimentalSetup.show(self, comp='vec', scale=5, show_antenna=True, show_grid=False, show_extrusion=True)#

Shows the experimental setup, including external fields and microwave antennna.

comp{“vec”, “x”, “y”, “z”}

If external field is nonzero, determines which component will be plotted.


Determines the scale of the vector glyphs used to visualize the magnetization (default is 5).


If available, show the microwave antenna (default is True).


Show grid lines in plot (default is False).


Show full 3D mesh by extruding 1D or 2D mesh (default is True).

5.2. Scalar- and vectorfield visualization#

It is also possible to plot scalar fields or vector fields defined on a given sample using the plot() method of a sample.

>>> vector_field = tx.vectorfields.helical(sample.xyz, 90, 1)
>>> sample.plot(vector_field)
tetrax.core.sample.AbstractSample.plot(self, fields, comp='vec', scale=5, labels=None)#

Plot a vector or scalar field which is defined on each node of the mesh. Multiple fields can be plotted at the same time.

fieldsnumpy.array or list(numpy.array)

Scalar field of shape (nx,), vector field of shape (nx,3) or list containing any choice of the aforementioned.

comp{“vec”, “x”, “y”, “z”}

If field is a vector field, this parameter determines which component will be plotted.


Determines the scale of the vector glyphs used to visualize a vectorfield (default is 5).

labelsstr or list(str)

Label(s) of the vectorfield(s) to be plotted. If labels is a list, it needs to have the same length as fields (default is None).

5.3. Mode visualization#

The calculated modes can be shown in the notebook using the show_mode(). The mode will be visualized as a vectorfield colored according to its magnitute, dark and bright colors represent low and high amplitudes, respectively. The mode can be visualized as the dynamic component only or as a mode on the top of the equilibrium magnetization.

The mode can be visualized with the following command:

>>> exp.show_mode(k=10,N=1,periods=10,on_equilibrium=True,animated=True,scale=10,fps=30,scale_mode=2)

This will show the animated mode movie of the mode N=1 for k=10 rad/µm wave vector, on the top of the equilibrium, for 10 periods with 30 frames per second. The magnetization vectorfield can be scaled by the scale parameter and the amplitude of the dynamic component with the scale_mode parameter.

Here is an example for a magnetostatic surface wave in a 50 nm permalloy film in the Damon-Eshbach geometry.


For details of the mode animation check the method:

tetrax.core.experimental_setup.ExperimentalSetup.show_mode(self, k=0, N=0, scale=1, on_equilibrium=True, animated=False, periods=1, frames_per_period=20, fps=12, scale_mode=1)#

If spatial mode profiles are available, show a desired mode.

The mode is visualized as vector field which can either only show the dynamic component or the full magnetization (mode on-top of equilibrium). Setting animated=True allows to animate the mode profiles by showing the oscillation over a desired number of periods (default is 1). The mode is automatically colored according to its magnitude.


At the moment, animation is implemented such that it will play until the end and cannot be stopped (except by interrupting the kernel). So be careful with setting a large number of oscillation periods.

kfloat, optional

Wave vector of desired mode in rad/µm (default is 0). This parameter will be ignored for confined samples.

Nint, optional

Mode/branch index of mode to be shown (default is 0).

scalefloat, optional

Scaling of the mode (default is 1).

on_equilibriumbool, optional

If true, show the mode on top of the equilibrium magnetization (default is True).

animatedbool, optional

Make a mode movie by showing the magnetic oscillation over one period in a loop.

periodsint, optional

Number of oscillation periods to animate (default is 1). Will be ignored if animated=False.

frames_per_periodint, optional

Number of frames to animate per period (default is 20). Will be ignored if animated=False.

fpsint, optional

Frames per second for animation (default is 12).

5.4. Average and data extraction#

In order to calculate the average of a given vector or scalar field on a sample, one can use the average() method of the respective sample.

tetrax.core.sample.AbstractSample.average(self, field)#

Calculate the average of a scalar of vector field within the given sample.

Extracting data of vector or scalar fields along a line or curve is possible with the scan_along_curve() method of the sample.

tetrax.core.sample.AbstractSample.scan_along_curve(self, field, curve, num_points=100, return_curve=False)#

Interpolate a given scalar or vector field along a specified curve.

fieldMeshScalar or MeshVector

Field to be interpolated.

curvendarray, shape (nx, 3) or tuple/list of shape (2, 3)

The points along the interpolation curve or the start and end points of the curve ((x1, y1, z1),(x2, y2, z2)).


The number of points to interpolate along the curve. Will only be considered if start and end points are given (default is 100).


Next to the interpolated values, also return the interpolation curve.

interp_valuesndarray, shape (num_points, m)

The interpolated values along the curve with m being the size of the second dimension of field.