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
Creating data object.
>>> import os >>> import micromagneticdata as md ... >>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample') >>> data = md.Data(name='rectangle', dirname=dirname)
Methods
__dir__
Default dir() implementation.
__eq__
Return self==value.
Get drive with number
item
.Iterator.
Representation string.
Widget for selecting drive.
Properties
dirname
Descriptor allowing setting attributes only with values of a certain type.
Data information.
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:
Examples
Getting drive.
>>> import os >>> import micromagneticdata as md ... >>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample') >>> data = md.Data(name='rectangle', 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
Iterating data object.
>>> import os >>> import micromagneticdata as md ... >>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample') >>> data = md.Data(name='rectangle', dirname=dirname) >>> data.n 7 >>> len(list(data)) 7
- __repr__()#
Representation string.
- Returns:
Representation string.
- Return type:
str
Examples
Representation string.
>>> import os >>> import micromagneticdata as md ... >>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample') >>> data = md.Data(name='rectangle', 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
Selection widget.
>>> import os >>> import micromagneticdata as md ... >>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample') >>> data = md.Data(name='rectangle', 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
Getting information about data.
>>> import os >>> import micromagneticdata as md ... >>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample') >>> data = md.Data(name='rectangle', dirname=dirname) >>> data.info drive_number...
- property n#
Number of drives in data.
- Returns:
Number of drives.
- Return type:
int
Examples
Getting the number of drives.
>>> import os >>> import micromagneticdata as md ... >>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample') >>> data = md.Data(name='rectangle', dirname=dirname) >>> data.n 7