magneticalc.API.API

# ``magneticalc`.`API`.`API``

class documentation

`class API:`

View In Hierarchy

API class.

Static Method | `export_hdf5` | Exports data to an HDF5 container.
Static Method | `export_wire` | Exports wire points to a TXT file.
Static Method | `import_hdf5` | Imports data from an HDF5 container.
Static Method | `import_wire` | Imports wire points from a TXT file.
Static Method | `_dict_to_hdf5_group` | Recursively transforms a dictionary into an HDF5 group (in-place).
Static Method | `_hdf5_group_to_dict` | Recursively transforms an HDF5 group into a dictionary (in-place).

@staticmethod
def export_hdf5(filename: `str`, data: `dict | MagnetiCalc_Data`):

Exports data to an HDF5 container.

Takes a dictionary and writes an HDF5 file using keys as keys, and items as groups if they are dictionaries or as datasets otherwise.

Parameters
filename: `str` | Filename
data: `dict | MagnetiCalc_Data` | Dictionary or MagnetiCalc_Data object

@staticmethod
def export_wire(filename: `str`, data: `list | np.ndarray`):

Exports wire points to a TXT file.

Parameters
filename: `str` | Filename
data: `list | np.ndarray` | NumPy array of 3D points

@staticmethod
def import_hdf5(filename: `str`) -> `MagnetiCalc_Data`:

Imports data from an HDF5 container.

Opens an HDF5 file and converts every group and subgroup into a dictionary where the keys are the group keys and the items are the datasets.

Parameters
filename: `str` | Filename

Returns
`MagnetiCalc_Data` | MagnetiCalc_Data object (can be accessed like a dictionary)

@staticmethod
def import_wire(filename: `str`) -> `np.ndarray`:

Imports wire points from a TXT file.

Parameters
filename: `str` | Filename

Returns
`np.ndarray` | NumPy array of 3D points

@staticmethod
def _dict_to_hdf5_group(hdf5_group: `h5py.Group`, dictionary: `dict`):

Recursively transforms a dictionary into an HDF5 group (in-place).

Parameters
hdf5_group: `h5py.Group` | HDF5 group
dictionary: `dict` | Dictionary

@staticmethod
def _hdf5_group_to_dict(hdf5_group: `h5py.Group`, dictionary: `dict`):

Recursively transforms an HDF5 group into a dictionary (in-place).

Parameters
hdf5_group: `h5py.Group` | HDF5 group
dictionary: `dict` | Dictionary