FieldQuantity#

class FieldQuantity#

Bases: object

A functor representing a physical field quantity.

__init__(impl)#
property name: str#

Return instance’s name.

property unit: str#

Return the unit of the quantity.

Returns:

unit – The unit of the quantity, the default value is an empty string.

Return type:

str

property ncomp: int#

Return the number of components of the quantity.

In most cases this would be either 1 (scalar field) or 3 (vector fields).

Returns:

ncomp – The number of components of the quantity.

Return type:

int

property grid: Grid#

Return grid on which the quantity will be evaluated.

Returns:

grid – The grid on which the quantity will be evaluated.

Return type:

Grid

property shape#

Return the shape of the output numpy array of this quantity.

Returns:

shape – The shape of the output numpy array of this quantity.

Return type:

tuple of ints

eval()#

Evaluate the quantity.

average()#

Evaluate the quantity and return the average of each component.

Return type:

float

get_rgb()#

Evaluate the vector field quantity and return its rgb representation as a numpy ndarray of the same shape (3, nz, ny, nx).

Note

The final color scheme is different from mumax³. In this case, the saturation does not depend on the z-component anymore, meaning the z=0 plane remains unchanged, but other colors will appear slightly less saturated. This ensures that the color sphere is continuous everywhere, particularly when crossing the xz- or yz-plane with a normalized length less than 1, where the colors will fade through gray.

property meshgrid#

Return a numpy meshgrid with the x, y, and z coordinate of each cell.

save_ovf(name='')#

Save the FieldQuantity as an OVF file.

Parameters:

name (str (default="")) – The name of the OVF file. If the name is empty (the default), the name of the FieldQuantity will be used appended with an integer of 6 digits.

Warning

The shape of the array in the OVF file is (nz, ny, nx, ncomp) and not (ncomp, nz, ny, nx) in order to have the correct metadata.

Warning

self.name returns a string with colons (:). To avoid issues on Windows, these colons are changed to underscores (_).

load_ovf(name='')#

Load an OVF file as a FieldQuantity.

Parameters:

name (str (default="")) – The name of the OVF file. If the name is empty (the default), it will look for the most recently saved file with this FieldQuantity name.