Data#

class micromagneticdata.Data(name, dirname='./')#

Computational magnetism data class.

It requires the name of the system to be passed. If dirname was used when the system was driven, it can be passed here via dirname.

Parameters:
  • name (str) – System’s name.

  • dirname (str, optional) – Directory in which system’s data is saved. Defults to './'.

Raises:

IOError – If the system’s directory cannot be found.

Examples

  1. Creating data object.

>>> import os
>>> import micromagneticdata as md
...
>>> dirname = dirname=os.path.join(os.path.dirname(__file__),
...                                'tests', 'test_sample')
>>> data = md.Data(name='system_name', dirname=dirname)

Methods

__dir__

Default dir() implementation.

__eq__

Return self==value.

__getitem__

Get drive with number item.

__iter__

Iterator.

__repr__

Representation string.

selector

Widget for selecting drive.

Properties

dirname

Descriptor allowing setting attributes only with values of a certain type.

info

Data information.

n

Number of drives in data.

name

Descriptor allowing setting attributes only with values of a certain type.


__getitem__(item)#

Get drive with number item.

If a negative value is passed as item, the count starts from the end. For example, passing -1 would return the last drive.

Parameters:

item (int) – Drive number.

Returns:

Drive object.

Return type:

micromagneticdata.Drive

Examples

  1. Getting drive.

>>> import os
>>> import micromagneticdata as md
...
>>> dirname = dirname=os.path.join(os.path.dirname(__file__),
...                                'tests', 'test_sample')
>>> data = md.Data(name='system_name', dirname=dirname)
>>> data.n
7
>>> data[0]  # first (0th) drive
OOMMFDrive(...)
>>> data[1]  # second (1th) drive
Mumax3Drive(...)
>>> data[-1]  # last (6th) drive
OOMMFDrive(...)
__iter__()#

Iterator.

This method yields all drives found in data.

Yields:

micromagneticdata.Drive – Drive object.

Examples

  1. Iterating data object.

>>> import os
>>> import micromagneticdata as md
...
>>> dirname = dirname=os.path.join(os.path.dirname(__file__),
...                                'tests', 'test_sample')
>>> data = md.Data(name='system_name', dirname=dirname)
>>> data.n
7
>>> len(list(data))
7
__repr__()#

Representation string.

Returns:

Representation string.

Return type:

str

Examples

  1. Representation string.

>>> import os
>>> import micromagneticdata as md
...
>>> dirname = dirname=os.path.join(os.path.dirname(__file__),
...                                'tests', 'test_sample')
>>> data = md.Data(name='system_name', dirname=dirname)
>>> data
Data(...)
selector(description='drive', **kwargs)#

Widget for selecting drive.

This method is based on ipywidgets.BoundedIntText, so any keyword argument accepted by it can be passed.

Parameters:

description (str, optional) – Widget description. Defaults to 'drive'.

Returns:

Selection widget.

Return type:

ipywidgets.BoundedIntText

Examples

  1. Selection widget.

>>> import os
>>> import micromagneticdata as md
...
>>> dirname = dirname=os.path.join(os.path.dirname(__file__),
...                                'tests', 'test_sample')
>>> data = md.Data(name='system_name', dirname=dirname)
>>> data.selector()
BoundedIntText(...)
property info#

Data information.

This property returns pandas.DataFrame with information about different drives found. If columns of different drives mismatch, NaN is added as the value.

Returns:

Data information.

Return type:

pandas.DataFrame

Examples

  1. Getting information about data.

>>> import os
>>> import micromagneticdata as md
...
>>> dirname = dirname=os.path.join(os.path.dirname(__file__),
...                                'tests', 'test_sample')
>>> data = md.Data(name='system_name', dirname=dirname)
>>> data.info
   drive_number...
property n#

Number of drives in data.

Returns:

Number of drives.

Return type:

int

Examples

  1. Getting the number of drives.

>>> import os
>>> import micromagneticdata as md
...
>>> dirname = dirname=os.path.join(os.path.dirname(__file__),
...                                'tests', 'test_sample')
>>> data = md.Data(name='system_name', dirname=dirname)
>>> data.n
7