diff --git a/pyramid/fielddata.py b/pyramid/fielddata.py index 76dd3e788e17c1f100316059f32211f126cb736c..22fc4be5298dbc53482a25874f6b27322644d8f1 100644 --- a/pyramid/fielddata.py +++ b/pyramid/fielddata.py @@ -4,23 +4,17 @@ # """This module provides classes for storing vector and scalar 3D-field.""" +import abc import logging - import os - import tempfile - -import abc from numbers import Number import numpy as np - +from PIL import Image +from matplotlib import patheffects from matplotlib import pyplot as plt from matplotlib.colors import ListedColormap -from matplotlib import patheffects - -from PIL import Image - from scipy.ndimage.interpolation import zoom from . import colors @@ -94,17 +88,6 @@ class FieldData(object, metaclass=abc.ABCMeta): else: return self.field - @property - def field_vec(self): - """Vector containing the vector field distribution.""" - return np.reshape(self.field, -1) - - @field_vec.setter - def field_vec(self, mag_vec): - assert np.size(mag_vec) == np.prod(self.shape), \ - 'Vector has to match field shape! {} {}'.format(mag_vec.shape, np.prod(self.shape)) - self.field = mag_vec.reshape((3,) + self.dim) - def __init__(self, a, field): self._log.debug('Calling __init__') self.a = a @@ -1323,6 +1306,17 @@ class VectorData(FieldData): kwargs.setdefault('hideaxes', True) return plottools.format_axis(axis, hideaxes=True, scalebar=False) + @property + def field_vec(self): + """Vector containing the vector field distribution.""" + return np.reshape(self.field, -1) + + @field_vec.setter + def field_vec(self, mag_vec): + assert np.size(mag_vec) == np.prod(self.shape), \ + 'Vector has to match field shape! {} {}'.format(mag_vec.shape, np.prod(self.shape)) + self.field = mag_vec.reshape((3,) + self.dim) + class ScalarData(FieldData): """Class for storing scalar field data. @@ -1519,4 +1513,15 @@ class ScalarData(FieldData): from .file_io.io_scalardata import save_scalardata save_scalardata(self, filename, **kwargs) + @property + def field_vec(self): + """Vector containing the scalar field distribution.""" + return np.reshape(self.field, -1) + + @field_vec.setter + def field_vec(self, c_vec): + assert np.size(c_vec) == np.prod(self.shape), \ + 'Vector has to match field shape! {} {}'.format(c_vec.shape, np.prod(self.shape)) + self.field = c_vec.reshape(self.dim) + # TODO: Histogram plots for magnetisation (see thesis!)