Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • empyre/empyre
  • weber/empyre
  • wessels/empyre
  • bryan/empyre
4 results
Show changes
Showing
with 0 additions and 262 deletions
File deleted
File deleted
File deleted
LLGFileCreator: test_magdata/ref_mag_data
4 4 4
5.000000e-07 5.000000e-07 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 5.000000e-07 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 5.000000e-07 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 5.000000e-07 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 1.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 1.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 1.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 1.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 2.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 2.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 2.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 2.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 3.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 3.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 3.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 3.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 5.000000e-07 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 5.000000e-07 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 5.000000e-07 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 5.000000e-07 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 1.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 1.500000e-06 1.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
2.500000e-06 1.500000e-06 1.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
3.500000e-06 1.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 2.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 2.500000e-06 1.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
2.500000e-06 2.500000e-06 1.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
3.500000e-06 2.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 3.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 3.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 3.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 3.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 5.000000e-07 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 5.000000e-07 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 5.000000e-07 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 5.000000e-07 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 1.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 1.500000e-06 2.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
2.500000e-06 1.500000e-06 2.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
3.500000e-06 1.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 2.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 2.500000e-06 2.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
2.500000e-06 2.500000e-06 2.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
3.500000e-06 2.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 3.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 3.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 3.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 3.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 5.000000e-07 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 5.000000e-07 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 5.000000e-07 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 5.000000e-07 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 1.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 1.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 1.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 1.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 2.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 2.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 2.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 2.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 3.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 3.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 3.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 3.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
\ No newline at end of file
File deleted
File deleted
File deleted
# -*- coding: utf-8 -*-
"""Testcase for the forwardmodel module"""
import os
import unittest
import numpy as np
from numpy.testing import assert_allclose
from pyramid.dataset import DataSet
from pyramid.forwardmodel import ForwardModel
from pyramid.projector import SimpleProjector
from pyramid import load_phasemap
class TestCaseForwardModel(unittest.TestCase):
def setUp(self):
self.path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test_forwardmodel')
self.a = 10.
self.dim = (4, 5, 6)
self.mask = np.zeros(self.dim, dtype=bool)
self.mask[1:-1, 1:-1, 1:-1] = True
self.data = DataSet(self.a, self.dim, mask=self.mask)
self.projector = SimpleProjector(self.dim)
self.phasemap = load_phasemap(os.path.join(self.path, 'phasemap_ref.hdf5'))
self.data.append(self.phasemap, self.projector)
self.data.append(self.phasemap, self.projector)
self.fwd_model = ForwardModel(self.data)
def tearDown(self):
self.path = None
self.a = None
self.dim = None
self.mask = None
self.data = None
self.projector = None
self.phasemap = None
self.fwdmodel = None
def test_call(self):
n = self.fwd_model.n
result = self.fwd_model(np.ones(n))
hp = self.data.hook_points
assert_allclose(result[hp[0]:hp[1]], self.phasemap.phase.ravel(), atol=1E-7,
err_msg='Unexpected behavior in __call__()!')
assert_allclose(result[hp[1]:hp[2]], self.phasemap.phase.ravel(), atol=1E-7,
err_msg='Unexpected behavior in __call__()!')
def test_jac_dot(self):
n = self.fwd_model.n
vector = np.ones(n)
result = self.fwd_model(vector)
result_jac = self.fwd_model.jac_dot(None, vector)
assert_allclose(result, result_jac, atol=1E-7,
err_msg='Inconsistency between __call__() and jac_dot()!')
jac = np.array([self.fwd_model.jac_dot(None, np.eye(n)[:, i]) for i in range(n)]).T
hp = self.data.hook_points
assert_allclose(jac[hp[0]:hp[1], :], jac[hp[1]:hp[2], :], atol=1E-7,
err_msg='Unexpected behaviour in the the jacobi matrix!')
jac_ref = np.load(os.path.join(self.path, 'jac.npy'))
assert_allclose(jac, jac_ref, atol=1E-7,
err_msg='Unexpected behaviour in the the jacobi matrix!')
def test_jac_T_dot(self):
m = self.fwd_model.m
jac_T = np.array([self.fwd_model.jac_T_dot(None, np.eye(m)[:, i]) for i in range(m)]).T
jac_T_ref = np.load(os.path.join(self.path, 'jac.npy')).T
assert_allclose(jac_T, jac_T_ref, atol=1E-7,
err_msg='Unexpected behaviour in the the transposed jacobi matrix!')
if __name__ == '__main__':
import nose
nose.run(defaultTest=__name__)
File deleted
File deleted
# -*- coding: utf-8 -*-
"""Testcase for the magdata module."""
import os
import unittest
import numpy as np
from numpy.testing import assert_allclose
from pyramid.kernel import Kernel
class TestCaseKernel(unittest.TestCase):
def setUp(self):
self.path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test_kernel')
self.kernel = Kernel(1., dim_uv=(4, 4), b_0=1., geometry='disc')
def tearDown(self):
self.path = None
self.kernel = None
def test_kernel(self):
ref_u = np.load(os.path.join(self.path, 'ref_u.npy'))
ref_v = np.load(os.path.join(self.path, 'ref_v.npy'))
ref_u_fft = np.load(os.path.join(self.path, 'ref_u_fft.npy'))
ref_v_fft = np.load(os.path.join(self.path, 'ref_v_fft.npy'))
assert_allclose(self.kernel.u, ref_u, err_msg='Unexpected behavior in u')
assert_allclose(self.kernel.v, ref_v, err_msg='Unexpected behavior in v')
assert_allclose(self.kernel.u_fft, ref_u_fft, atol=1E-7,
err_msg='Unexpected behavior in u_fft')
assert_allclose(self.kernel.v_fft, ref_v_fft, atol=1E-7,
err_msg='Unexpected behavior in v_fft')
if __name__ == '__main__':
import nose
nose.run(defaultTest=__name__)
File deleted
File deleted
File deleted
File deleted
# -*- coding: utf-8 -*-
"""Testcase for the magcreator module."""
import os
import unittest
import numpy as np
from numpy import pi
from numpy.testing import assert_allclose
import pyramid.magcreator as mc
class TestCaseMagCreator(unittest.TestCase):
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test_magcreator')
def test_shape_slab(self):
test_slab = mc.shapes.slab((5, 6, 7), (2.5, 3.5, 4.5), (1, 3, 5))
assert_allclose(test_slab, np.load(os.path.join(self.path, 'ref_slab.npy')),
err_msg='Created slab does not match expectation!')
def test_shape_disc(self):
test_disc_z = mc.shapes.disc((5, 6, 7), (2.5, 3.5, 4.5), 2, 3, 'z')
test_disc_y = mc.shapes.disc((5, 6, 7), (2.5, 3.5, 4.5), 2, 3, 'y')
test_disc_x = mc.shapes.disc((5, 6, 7), (2.5, 3.5, 4.5), 2, 3, 'x')
assert_allclose(test_disc_z, np.load(os.path.join(self.path, 'ref_disc_z.npy')),
err_msg='Created disc in z-direction does not match expectation!')
assert_allclose(test_disc_y, np.load(os.path.join(self.path, 'ref_disc_y.npy')),
err_msg='Created disc in y-direction does not match expectation!')
assert_allclose(test_disc_x, np.load(os.path.join(self.path, 'ref_disc_x.npy')),
err_msg='Created disc in x-direction does not match expectation!')
def test_shape_ellipse(self):
test_ellipse_z = mc.shapes.ellipse((7, 8, 9), (3.5, 4.5, 5.5), (3, 5), 1, 'z')
test_ellipse_y = mc.shapes.ellipse((7, 8, 9), (3.5, 4.5, 5.5), (3, 5), 1, 'y')
test_ellipse_x = mc.shapes.ellipse((7, 8, 9), (3.5, 4.5, 5.5), (3, 5), 1, 'x')
assert_allclose(test_ellipse_z, np.load(os.path.join(self.path, 'ref_ellipse_z.npy')),
err_msg='Created ellipse does not match expectation (z)!')
assert_allclose(test_ellipse_y, np.load(os.path.join(self.path, 'ref_ellipse_y.npy')),
err_msg='Created ellipse does not match expectation (y)!')
assert_allclose(test_ellipse_x, np.load(os.path.join(self.path, 'ref_ellipse_x.npy')),
err_msg='Created ellipse does not match expectation (x)!')
def test_shape_sphere(self):
test_sphere = mc.shapes.sphere((5, 6, 7), (2.5, 3.5, 4.5), 2)
assert_allclose(test_sphere, np.load(os.path.join(self.path, 'ref_sphere.npy')),
err_msg='Created sphere does not match expectation!')
def test_shape_ellipsoid(self):
test_ellipsoid = mc.shapes.ellipsoid((7, 8, 9), (3.5, 4.5, 4.5), (3, 5, 7))
assert_allclose(test_ellipsoid, np.load(os.path.join(self.path, 'ref_ellipsoid.npy')),
err_msg='Created ellipsoid does not match expectation!')
def test_shape_filament(self):
test_filament_z = mc.shapes.filament((5, 6, 7), (2, 3), 'z')
test_filament_y = mc.shapes.filament((5, 6, 7), (2, 3), 'y')
test_filament_x = mc.shapes.filament((5, 6, 7), (2, 3), 'x')
assert_allclose(test_filament_z, np.load(os.path.join(self.path, 'ref_fil_z.npy')),
err_msg='Created filament in z-direction does not match expectation!')
assert_allclose(test_filament_y, np.load(os.path.join(self.path, 'ref_fil_y.npy')),
err_msg='Created filament in y-direction does not match expectation!')
assert_allclose(test_filament_x, np.load(os.path.join(self.path, 'ref_fil_x.npy')),
err_msg='Created filament in x-direction does not match expectation!')
def test_shape_pixel(self):
test_pixel = mc.shapes.pixel((5, 6, 7), (2, 3, 4))
assert_allclose(test_pixel, np.load(os.path.join(self.path, 'ref_pixel.npy')),
err_msg='Created pixel does not match expectation!')
def test_create_mag_dist_homog(self):
mag_shape = mc.shapes.disc((1, 10, 10), (0, 5, 5), 3, 1)
magnitude = mc.create_mag_dist_homog(mag_shape, pi / 4)
assert_allclose(magnitude, np.load(os.path.join(self.path, 'ref_mag_disc.npy')),
err_msg='Created homog. magnetic distribution does not match expectation')
def test_create_mag_dist_vortex(self):
mag_shape = mc.shapes.disc((1, 10, 10), (0, 5, 5), 3, 1)
magnitude = mc.create_mag_dist_vortex(mag_shape)
assert_allclose(magnitude, np.load(os.path.join(self.path, 'ref_mag_vort.npy')),
err_msg='Created vortex magnetic distribution does not match expectation')
if __name__ == '__main__':
import nose
nose.run(defaultTest=__name__)
File deleted
File deleted
File deleted
File deleted