Skip to content
Snippets Groups Projects
Commit faa17f80 authored by Fengshan Zheng's avatar Fengshan Zheng
Browse files

All tests passed in ForwardModelCharge

parent 9c6a7b23
No related branches found
No related tags found
1 merge request!11ForwardModelCharge updated
...@@ -4,23 +4,17 @@ ...@@ -4,23 +4,17 @@
# #
"""This module provides classes for storing vector and scalar 3D-field.""" """This module provides classes for storing vector and scalar 3D-field."""
import abc
import logging import logging
import os import os
import tempfile import tempfile
import abc
from numbers import Number from numbers import Number
import numpy as np import numpy as np
from PIL import Image
from matplotlib import patheffects
from matplotlib import pyplot as plt from matplotlib import pyplot as plt
from matplotlib.colors import ListedColormap from matplotlib.colors import ListedColormap
from matplotlib import patheffects
from PIL import Image
from scipy.ndimage.interpolation import zoom from scipy.ndimage.interpolation import zoom
from . import colors from . import colors
...@@ -94,17 +88,6 @@ class FieldData(object, metaclass=abc.ABCMeta): ...@@ -94,17 +88,6 @@ class FieldData(object, metaclass=abc.ABCMeta):
else: else:
return self.field 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): def __init__(self, a, field):
self._log.debug('Calling __init__') self._log.debug('Calling __init__')
self.a = a self.a = a
...@@ -1323,6 +1306,17 @@ class VectorData(FieldData): ...@@ -1323,6 +1306,17 @@ class VectorData(FieldData):
kwargs.setdefault('hideaxes', True) kwargs.setdefault('hideaxes', True)
return plottools.format_axis(axis, hideaxes=True, scalebar=False) 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 ScalarData(FieldData):
"""Class for storing scalar field data. """Class for storing scalar field data.
...@@ -1519,4 +1513,15 @@ class ScalarData(FieldData): ...@@ -1519,4 +1513,15 @@ class ScalarData(FieldData):
from .file_io.io_scalardata import save_scalardata from .file_io.io_scalardata import save_scalardata
save_scalardata(self, filename, **kwargs) 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!) # TODO: Histogram plots for magnetisation (see thesis!)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment