Drive#
- class micromagneticdata.Drive(name, number, dirname='.', x=None, use_cache=False, **kwargs)#
Drive class.
This class provides utility for the analysis of individual drives.
- Parameters:
name (str) – System’s name.
number (int) – Drive number.
dirname (str, optional) – Directory in which system’s data is saved. Defults to
'./'.x (str, optional) – Independent variable column name. Defaults to
Noneand depending on the driver used, one is found automatically.use_cache (bool, optional) – If
Truethe Drive object will read tabular data and the names and number of magnetisation files only once. Note: this prevents Drive to detect new data when looking at the output of a running simulation. If set toFalsethe data is read every time the user accesses it. Defaults toFalse.
- Raises:
IOError – If the drive directory cannot be found.
Examples
Getting drive object from data object.
>>> import os >>> import micromagneticdata as md ... >>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample') >>> drive = md.Data(name='rectangle', dirname=dirname)[0] >>> drive OOMMFDrive(...)
Getting drive objet directly.
>>> drive = md.Drive(name='rectangle', number=1, dirname=dirname) >>> drive Mumax3Drive(...)
Methods
__dir__Default dir() implementation.
__eq__Return self==value.
Magnetisation field of an individual step or subpart of the drive.
__iter__Iterator.
Concatenate multiple drives of the same type.
__repr__Representation string.
OVF to VTK conversion.
Register a callback to which a field is passed before being returned.
Widget for selecting individual steps.
to_xarrayExport
micromagneticdata.Driveasxarray.DataArrayProperties
MIF file.
callbacksReturn all registered callbacks.
dirnameDescriptor allowing setting attributes only with values of a certain type.
hvPlot interface, Holoviews/hvplot based.
Drive information.
m0Inital magnetisation.
nNumber of steps.
nameDescriptor allowing setting attributes only with values of a certain type.
numberDescriptor allowing setting attributes only with scalars (
numbers.Real).Table object.
Use caching for scalar data and the list of magnetisation files.
xIndependent variable name.
- __getitem__(item)#
Magnetisation field of an individual step or subpart of the drive.
If an
intis passed a single magnetisation field (discretisedfield.Field object) is returned. Additional callbacks (if registered) are applied to this field before it is returned.If a slice is passed a new drive object with the magnetisation steps defined via the slice is returned. Additional callbacks (if registered) are passed to the new drive object.
- Returns:
discretisedfield.Field – Magnetisation field if an int is passed.
micromagneticdata.Drive – Drive with selected data if a slice is passed.
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(...)
2. Selecting a part of the 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) >>> selection = drive[:8:2] >>> selection OOMMFDrive(…) >>> selection.n 4
- __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...
- static __new__(cls, name, number, dirname='.', x=None, use_cache=False, **kwargs)#
Create a new OOMMFDrive or Mumax3Drive depending on the directory structure.
If a subdirectory <name>.out exists a Mumax3Drive is created else an OOMMFDrive.
- ovf2vtk(dirname=None)#
OVF to VTK conversion.
This method iterates through all magnetisation fields in the drive and generates a VTK file for each of them.
- Parameters:
dirname (pathlib.Path) – Directory in which files are saved.
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) >>> drive.ovf2vtk()
- register_callback(callback)#
Register a callback to which a field is passed before being returned.
- slider(description='step', **kwargs)#
Widget for selecting individual steps.
This method is based on
ipywidgets.IntSlider, so any keyword argument accepted by it can be passed.- Parameters:
description (str, optional) – Widget description. Defaults to
'step'.- Returns:
Slider widget.
- Return type:
ipywidgets.IntSlider
Examples
Slider widget.
>>> 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.slider() IntSlider(...)
- abstract property calculator_script#
MIF file. This property returns a string with the content of MIF file.
- Returns:
MIF file content.
- Return type:
str
Examples
Getting MIF file.
>>> import os >>> import micromagneticdata as md ... >>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample') >>> drive = md.Drive(name='rectangle', number=6, dirname=dirname) >>> drive.calculator_script '# MIF 2...'
Getting mx3 file
TODO add mumax3 output to the pre-computed data
- property info#
Drive information.
This property returns a dictionary with information about the drive.
- Returns:
Drive information.
- Return type:
dict
Examples
Getting information about drive.
>>> import os >>> import micromagneticdata as md ... >>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample') >>> drive = md.Drive(name='rectangle', number=6, dirname=dirname) >>> drive.info {...}
- 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...
- property use_cache#
Use caching for scalar data and the list of magnetisation files.
The existing cache is cleared when set to
False.- Parameters:
use_cache (bool) – If
Truethe Drive object will read tabular data and the names and number of magnetisation files only once. Note: this prevents Drive to detect new data when looking at the output of a running simulation. If set toFalsethe data is read every time the user accesses it. Defaults toFalse.