AbstractDrive#
- class micromagneticdata.AbstractDrive(callbacks=None)#
Drive class.
This class provides utility for the analysis of individual drives.
- Parameters:
callbacks (list of callables, optional) – List of callback functions that are applied to individual fields of the drive when accessing them.
Methods
__dir__Default dir() implementation.
__eq__Return self==value.
Magnetisation field of an individual step.
Iterator.
Concatenate multiple drives of the same type.
Representation string.
Register a callback to which a field is passed before being returned.
Export
micromagneticdata.Driveasxarray.DataArrayProperties
Return all registered callbacks.
Plot interface, Holoviews/hvplot based.
Drive information.
Inital magnetisation.
Number of steps.
Table object.
Independent variable name.
- __getitem__(item)#
Magnetisation field of an individual step.
- Returns:
Magnetisation field.
- Return type:
Examples
Getting the field of a particular step.
>>> import os >>> import micromagneticdata as md ... >>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample') >>> drive = md.Drive(name='rectangle', number=0, dirname=dirname) >>> drive[5] Field(...)
- __iter__()#
Iterator.
This iterator iterates through all magnetisation field in drive and yields
discretisedfield.Fieldobjects.- Returns:
Magnetisation field.
- Return type:
Examples
Iterating drive.
>>> import os >>> import micromagneticdata as md ... >>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample') >>> drive = md.Drive(name='rectangle', number=0, dirname=dirname) >>> list(drive) [...]
- abstract __lshift__(other)#
Concatenate multiple drives of the same type.
Multiple drives with the same independent variable (typically drives of the same type, e.g. TimeDriver) can be concatenated into one combined drive. The resulting object has one large table with scalar values and allows iterating over all magnetisation files of the individual drives.
- Parameters:
other (micromagneticdata.Drive, micromagneticdata.CombinedDrive) – The drive to append to the current object.
- Returns:
The concatenated drives.
- Return type:
Examples
Concatenating two drives
>>> import os >>> import micromagneticdata as md ... >>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample') >>> drive_0 = md.Drive(name='rectangle', number=0, dirname=dirname) >>> drive_1 = md.Drive(name='rectangle', number=1, dirname=dirname) >>> drive_0 << drive_1 CombinedDrive...
- abstract __repr__()#
Representation string.
- abstract register_callback(callback)#
Register a callback to which a field is passed before being returned.
- to_xarray(*args, **kwargs)#
Export
micromagneticdata.Driveasxarray.DataArrayThe method depends on
discretisedfield.Field.to_xarrayand derives the last four dimensionsx,y,z, andcompin the outputxarray.DataArrayfrom it. The arguments and named arguments to this method are passed on todiscretisedfield.Field.to_xarray.Depending on type of driver, the dimensions and coordinates of the output may change. If the number of stored steps in the
micromagneticdata.Driveare more than one, the output contains an extra dimension named aftermicromagneticdata.Drive.table.xwith proper coordinate values. For the case ofHysteresisDriver, the new dimension has four coordinates, namelyB_hysteresis,Bx_hysteresis,By_hysteresis, andBz_hysteresis. The first represents the norm of the hysteresis field, while the rest three represents the components along the respective axes. For amicromagneticdata.Drivewith a singlediscretisedfield.Field, the value of the singlediscretisedfield.Field.to_xarrayis returned.micromagneticdata.Drive.infois returned as the outputxarray.DataArrayattributes, besides the ones derived fromdiscretisedfield.Field.to_xarray.- Parameters:
args (any) – Arguments to
discretisedfield.Field.to_xarraykwargs (any) – Named arguments to
discretisedfield.Field.to_xarray
- Returns:
micromagneticdata.Driveasxarray.DataArray- Return type:
xarray.DataArray
Examples
Drive to DataArray
>>> import os >>> import micromagneticdata as md ... >>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample') >>> drive = md.Drive(name='rectangle', number=0, dirname=dirname) >>> xr_drive = drive.to_xarray(name='Mag') >>> xr_drive <xarray.DataArray 'Mag' (t: 25, x: 20, y: 10, z: 4, vdims: 3)>...
Magnetization in a cell over time for
TimeDriver
>>> xr_drive.isel(x=2, y=2, z=2) <xarray.DataArray 'Mag' (t: 25, vdims: 3)>...
- property callbacks#
Return all registered callbacks.
- property hv#
Plot interface, Holoviews/hvplot based.
This property provides access to the different plotting methods. It is also callable to quickly generate plots. It is based on
discretisedfield.plotting.Hv. For more details and the available methods refer to the documentation linked below.See also
__call__()scalar()vector()contour()Examples
Visualising a drive using
hv.
>>> import os >>> import micromagneticdata as md ... >>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample') >>> drive = md.Drive(name='rectangle', number=0, dirname=dirname) >>> drive.hv(kdims=['x', 'y']) :DynamicMap...
- abstract property info#
Drive information.
- property m0#
Inital magnetisation.
This property returns a
discretisedfield.Fieldobject for the initial magnetisation field.- Returns:
Initial magnetisation field.
- Return type:
Examples
Getting initial magnetisation field.
>>> import os >>> import micromagneticdata as md ... >>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample') >>> drive = md.Drive(name='rectangle', number=0, dirname=dirname) >>> drive.m0 Field(...)
- property n#
Number of steps.
This property returns the number of rows in the drive table.
- Returns:
Number of steps.
- Return type:
int
Examples
Getting the number of steps.
>>> import os >>> import micromagneticdata as md ... >>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample') >>> drive = md.Drive(name='rectangle', number=0, dirname=dirname) >>> drive.n 25
- abstract property table#
Table object.
This property returns an
ubermagtable.Tableobject. As an independent variablex, the column chosen viaxproperty is selected.- Returns:
Table object.
- Return type:
Examples
Getting table object.
>>> import os >>> import micromagneticdata as md ... >>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample') >>> drive = md.Drive(name='rectangle', number=0, dirname=dirname) >>> drive.table E...
- abstract property x#
Independent variable name.
- Parameters:
value (str) – Independent variable name.
- Returns:
Representation string.
- Return type:
str
- Raises:
ValueError – If the column name does not exist in table.
Examples
Getting and setting independent variable name.
>>> import os >>> import micromagneticdata as md ... >>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample') >>> drive = md.Data(name='hysteresis', dirname=dirname)[0] >>> drive.x 'B_hysteresis' >>> drive.x = 'Bx_hysteresis'