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 1206 deletions
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
# -*- coding: utf-8 -*-
"""Testcase for the magdata module."""
import unittest
import numpy as np
from numpy import pi
from pyramid.magdata import MagData
# py.test
# TODO: define test constants somewhere
# TODO: proper error messages
# TODO: Docstring
class TestCaseMagData(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def test_init(self):
magnitude = (np.zeros((1, 1, 1), np.zeros(1, 1, 1), np.zeros(1, 1, 1)))
magnitude = (np.zeros((1, 1, 1), np.zeros(1, 1, 1), np.zeros(1, 1, 1)))
self.assertRaises(AssertionError, MagData, 10.0, )
self.assertEqual(self.mag_data.filename, self.filename)
def test_resolution(self):
self.assertEqual(self.mag_data.res, 10.0)
def test_dimensions(self):
self.assertEqual(self.mag_data.dim, (1, 3, 5))
def test_length(self):
self.assertEqual(self.mag_data.length, (10.0, 30.0, 50.0))
def test_magnitude(self):
test_shape = (1, 3, 5)
test_array = np.zeros(test_shape)
z_mag = self.mag_data.magnitude[0]
y_mag = self.mag_data.magnitude[1]
x_mag = self.mag_data.magnitude[2]
self.assertEqual(z_mag.shape, test_shape)
self.assertEqual(y_mag.shape, test_shape)
self.assertEqual(x_mag.shape, test_shape)
np.testing.assert_array_equal(z_mag, test_array, 'Testmessage')
test_array[:, 1, 1:4] = np.cos(pi/4)
np.testing.assert_array_almost_equal(y_mag, test_array, err_msg='y failure')
np.testing.assert_array_almost_equal(x_mag, test_array, err_msg='x failure')
def test_load_from_llg(self):
pass
def test_save_to_llg(self):
pass
def test_load_from_netcdf(self):
pass
def test_save_to_netcdf(self):
pass
def test_quiver_plot(self):
pass
def test_quiver_plot3d(self):
pass
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TestCaseMagData)
unittest.TextTestRunner(verbosity=2).run(suite)
LLGFileCreator2D: test_data
5 3 1
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
4.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 7.071068e-01 7.071068e-01 0.000000e+00
2.500000e-06 1.500000e-06 5.000000e-07 7.071068e-01 7.071068e-01 0.000000e+00
3.500000e-06 1.500000e-06 5.000000e-07 7.071068e-01 7.071068e-01 0.000000e+00
4.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
4.500000e-06 2.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
\ No newline at end of file
# -*- coding: utf-8 -*-
"""Testcase for the phasemap module."""
import unittest
from pyramid.phasemap import PhaseMap
class TestCasePhaseMap(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def test_template(self):
pass
def test_load_from_txt(self):
pass
def test_save_to_txt(self):
pass
def test_load_from_netcdf(self):
pass
def test_save_to_netcdf(self):
pass
def test_display(self):
pass
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TestCasePhaseMap)
unittest.TextTestRunner(verbosity=2).run(suite)
# -*- coding: utf-8 -*-
"""Testcase for the phasemapper module."""
import unittest
import pyramid.phasemapper as pm
class TestCasePhaseMapper(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def test_phase_mag_fourier(self):
pass
def test_phase_mag_real_slab(self):
pass
def test_phase_mag_real_disc(self):
pass
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TestCasePhaseMapper)
unittest.TextTestRunner(verbosity=2).run(suite)
# -*- coding: utf-8 -*-
"""Testcase for the projector module."""
import unittest
import numpy as np
from numpy import pi
import pyramid.projector as pj
import pyramid.magcreator as mc
from pyramid.magdata import MagData
class TestCaseProjector(unittest.TestCase):
def setUp(self):
self.mag_data = MagData.load_from_llg('test_projector/ref_mag_data.txt')
def tearDown(self):
self.mag_data = None
def test_simple_axis_projection(self):
z_proj_ref = (np.loadtxt('test_projector/ref_proj_z.txt'))
y_proj_ref = (np.loadtxt('test_projector/ref_proj_y.txt'))
x_proj_ref = (np.loadtxt('test_projector/ref_proj_x.txt'))
z_proj = pj.simple_axis_projection(self.mag_data, 'z')
y_proj = pj.simple_axis_projection(self.mag_data, 'y')
x_proj = pj.simple_axis_projection(self.mag_data, 'x')
np.testing.assert_equal(z_proj[0], z_proj_ref, 'Testmessage') # TODO: Real messages!
np.testing.assert_equal(z_proj[1], z_proj_ref, 'Testmessage')
np.testing.assert_equal(y_proj[0], y_proj_ref, 'Testmessage')
np.testing.assert_equal(y_proj[1], y_proj_ref, 'Testmessage')
np.testing.assert_equal(x_proj[0], x_proj_ref, 'Testmessage')
np.testing.assert_equal(x_proj[1], x_proj_ref, 'Testmessage')
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TestCaseProjector)
unittest.TextTestRunner(verbosity=2).run(suite)
LLGFileCreator: test_projector/ref_mag_data
7 6 5
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
4.500000e-06 5.000000e-07 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
5.500000e-06 5.000000e-07 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
6.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
4.500000e-06 1.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
5.500000e-06 1.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
6.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
4.500000e-06 2.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
5.500000e-06 2.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
6.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
4.500000e-06 3.500000e-06 5.000000e-07 1.000000e+00 1.000000e+00 1.000000e+00
5.500000e-06 3.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
6.500000e-06 3.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 4.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 4.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 4.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 4.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
4.500000e-06 4.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
5.500000e-06 4.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
6.500000e-06 4.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 5.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 5.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 5.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 5.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
4.500000e-06 5.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
5.500000e-06 5.500000e-06 5.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00
6.500000e-06 5.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
4.500000e-06 5.000000e-07 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.500000e-06 5.000000e-07 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
6.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 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 1.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 1.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
4.500000e-06 1.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.500000e-06 1.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
6.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 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 2.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 2.500000e-06 1.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
4.500000e-06 2.500000e-06 1.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
5.500000e-06 2.500000e-06 1.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
6.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 1.000000e+00 1.000000e+00 1.000000e+00
4.500000e-06 3.500000e-06 1.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
5.500000e-06 3.500000e-06 1.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
6.500000e-06 3.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 4.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 4.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 4.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 4.500000e-06 1.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
4.500000e-06 4.500000e-06 1.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
5.500000e-06 4.500000e-06 1.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
6.500000e-06 4.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 5.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 5.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 5.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 5.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
4.500000e-06 5.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.500000e-06 5.500000e-06 1.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
6.500000e-06 5.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
4.500000e-06 5.000000e-07 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.500000e-06 5.000000e-07 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
6.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 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 1.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 1.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
4.500000e-06 1.500000e-06 2.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
5.500000e-06 1.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
6.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 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 2.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 2.500000e-06 2.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
4.500000e-06 2.500000e-06 2.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
5.500000e-06 2.500000e-06 2.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
6.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 1.000000e+00 1.000000e+00 1.000000e+00
3.500000e-06 3.500000e-06 2.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
4.500000e-06 3.500000e-06 2.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
5.500000e-06 3.500000e-06 2.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
6.500000e-06 3.500000e-06 2.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
5.000000e-07 4.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 4.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 4.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 4.500000e-06 2.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
4.500000e-06 4.500000e-06 2.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
5.500000e-06 4.500000e-06 2.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
6.500000e-06 4.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 5.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 5.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 5.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 5.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
4.500000e-06 5.500000e-06 2.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
5.500000e-06 5.500000e-06 2.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
6.500000e-06 5.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
4.500000e-06 5.000000e-07 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.500000e-06 5.000000e-07 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
6.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
4.500000e-06 1.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.500000e-06 1.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
6.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 1.000000e+00 1.000000e+00 1.000000e+00
4.500000e-06 2.500000e-06 3.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
5.500000e-06 2.500000e-06 3.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
6.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 1.000000e+00 1.000000e+00 1.000000e+00
4.500000e-06 3.500000e-06 3.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
5.500000e-06 3.500000e-06 3.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
6.500000e-06 3.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 4.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 4.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 4.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 4.500000e-06 3.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
4.500000e-06 4.500000e-06 3.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
5.500000e-06 4.500000e-06 3.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
6.500000e-06 4.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 5.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 5.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 5.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 5.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
4.500000e-06 5.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.500000e-06 5.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
6.500000e-06 5.500000e-06 3.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 5.000000e-07 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 5.000000e-07 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 5.000000e-07 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 5.000000e-07 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
4.500000e-06 5.000000e-07 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.500000e-06 5.000000e-07 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
6.500000e-06 5.000000e-07 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 1.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 1.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 1.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 1.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
4.500000e-06 1.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.500000e-06 1.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
6.500000e-06 1.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 2.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 2.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 2.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 2.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
4.500000e-06 2.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.500000e-06 2.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
6.500000e-06 2.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 3.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 3.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 3.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 3.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
4.500000e-06 3.500000e-06 4.500000e-06 1.000000e+00 1.000000e+00 1.000000e+00
5.500000e-06 3.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
6.500000e-06 3.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 4.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 4.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 4.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 4.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
4.500000e-06 4.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.500000e-06 4.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
6.500000e-06 4.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.000000e-07 5.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
1.500000e-06 5.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
2.500000e-06 5.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
3.500000e-06 5.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
4.500000e-06 5.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
5.500000e-06 5.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
6.500000e-06 5.500000e-06 4.500000e-06 0.000000e+00 0.000000e+00 0.000000e+00
\ No newline at end of file
0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00
0.000000000000000000e+00 0.000000000000000000e+00 3.000000000000000000e+00 3.000000000000000000e+00 3.000000000000000000e+00 0.000000000000000000e+00
0.000000000000000000e+00 1.000000000000000000e+00 3.000000000000000000e+00 5.000000000000000000e+00 3.000000000000000000e+00 1.000000000000000000e+00
0.000000000000000000e+00 0.000000000000000000e+00 3.000000000000000000e+00 3.000000000000000000e+00 3.000000000000000000e+00 0.000000000000000000e+00
0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00
0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00
0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 3.000000000000000000e+00 3.000000000000000000e+00 3.000000000000000000e+00 0.000000000000000000e+00
0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 3.000000000000000000e+00 5.000000000000000000e+00 3.000000000000000000e+00 1.000000000000000000e+00
0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 3.000000000000000000e+00 3.000000000000000000e+00 3.000000000000000000e+00 0.000000000000000000e+00
0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00
0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00
0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00
0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 3.000000000000000000e+00 3.000000000000000000e+00 3.000000000000000000e+00 0.000000000000000000e+00
0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 3.000000000000000000e+00 5.000000000000000000e+00 3.000000000000000000e+00 1.000000000000000000e+00
0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 3.000000000000000000e+00 3.000000000000000000e+00 3.000000000000000000e+00 0.000000000000000000e+00
0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00
# -*- coding: utf-8 -*-
"""Testcase for the reconstructor module."""
import unittest
import pyramid.reconstructor as rc
class TestCaseReconstructor(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def test_template(self):
pass
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TestCaseReconstructor)
unittest.TextTestRunner(verbosity=2).run(suite)
# -*- coding: utf-8 -*-
"""Compare the different methods to create phase maps."""
import time
import pdb, traceback, sys
import numpy as np
from numpy import pi
import matplotlib.pyplot as plt
import pyramid.magcreator as mc
import pyramid.projector as pj
import pyramid.phasemapper as pm
import pyramid.analytic as an
from pyramid.magdata import MagData
from pyramid.phasemap import PhaseMap
import shelve
def phase_from_mag():
'''Calculate and display the phase map from a given magnetization.
Arguments:
None
Returns:
None
'''
# Create / Open databank:
data_shelve = shelve.open('../output/method_errors_shelve')
'''FOURIER PADDING->RMS|DURATION'''
# Parameters:
b_0 = 1 # in T
res = 10.0 # in nm
dim = (1, 128, 128)
phi = -pi/4
padding_list = [0, 0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4,5, 6,7, 8,9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
geometry = 'disc'
# Create magnetic shape:
if geometry == 'slab':
center = (0, dim[1]/2-0.5, dim[2]/2-0.5) # in px (z, y, x) index starts with 0!
width = (1, dim[1]/2, dim[2]/2) # in px (z, y, x)
mag_shape = mc.Shapes.slab(dim, center, width)
phase_ana = an.phase_mag_slab(dim, res, phi, center, width, b_0)
elif geometry == 'disc':
center = (0, dim[1]/2-0.5, dim[2]/2-0.5) # in px (z, y, x) index starts with 0!
radius = dim[1]/4 # in px
height = 1 # in px
mag_shape = mc.Shapes.disc(dim, center, radius, height)
phase_ana = an.phase_mag_disc(dim, res, phi, center, radius, b_0)
# Project the magnetization data:
mag_data = MagData(res, mc.create_mag_dist(mag_shape, phi))
projection = pj.simple_axis_projection(mag_data)
# Create data:
data = np.zeros((3, len(padding_list)))
data[0, :] = padding_list
for (i, padding) in enumerate(padding_list):
print 'padding =', padding_list[i]
# Key:
key = ', '.join(['Padding->RMS|duration', 'Fourier', 'padding={}'.format(padding_list[i]),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry={}'.format(geometry)])
if data_shelve.has_key(key):
data[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_fourier(res, projection, b_0, padding_list[i])
data[2, i] = time.time() - start_time
phase_diff = phase_ana - phase_num
PhaseMap(res, phase_diff).display()
data[1, i] = np.std(phase_diff)
data_shelve[key] = data[:, i]
# Plot duration against padding:
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.set_yscale('log')
axis.plot(data[0], data[1])
axis.set_title('Fourier Space Approach: Variation of the Padding')
axis.set_xlabel('padding')
axis.set_ylabel('RMS')
# Plot RMS against padding:
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.plot(data[0], data[2])
axis.set_title('Fourier Space Approach: Variation of the Padding')
axis.set_xlabel('padding')
axis.set_ylabel('duration [s]')
'''VARY DIMENSIONS FOR ALL APPROACHES'''
b_0 = 1 # in T
phi = -pi/4
dim_list = [(1, 4, 4), (1, 8, 8), (1, 16, 16), (1, 32, 32), (1, 64, 64), (1, 128, 128)]
res_list = [64., 32., 16., 8., 4., 2., 1.] # in nm
data_sl_p_fourier0 = np.zeros((3, len(res_list)))
data_sl_w_fourier0 = np.zeros((3, len(res_list)))
data_disc_fourier0 = np.zeros((3, len(res_list)))
data_sl_p_fourier1 = np.zeros((3, len(res_list)))
data_sl_w_fourier1 = np.zeros((3, len(res_list)))
data_disc_fourier1 = np.zeros((3, len(res_list)))
data_sl_p_fourier20 = np.zeros((3, len(res_list)))
data_sl_w_fourier20 = np.zeros((3, len(res_list)))
data_disc_fourier20 = np.zeros((3, len(res_list)))
data_sl_p_real_s = np.zeros((3, len(res_list)))
data_sl_w_real_s = np.zeros((3, len(res_list)))
data_disc_real_s = np.zeros((3, len(res_list)))
data_sl_p_real_d= np.zeros((3, len(res_list)))
data_sl_w_real_d = np.zeros((3, len(res_list)))
data_disc_real_d = np.zeros((3, len(res_list)))
data_slab_perfect[0, :] = res_list
data_slab_worst[0, :] = res_list
data_disc[0, :] = res_list
'''FOURIER UNPADDED'''
for i, (dim, res) in enumerate(zip(dim_list, res_list)):
print 'dim =', str(dim)
# ANALYTIC SOLUTIONS:
# Slab (perfectly aligned):
center = (0, dim[1]/2.-0.5, dim[2]/2.-0.5) # in px (z, y, x) index starts with 0!
width = (1, dim[1], dim[2]) # in px (z, y, x)
mag_shape_slab_perfect = mc.Shapes.slab(dim, center, width)
phase_ana_slab_perfect = an.phase_mag_slab(dim, res, phi, center, width, b_0)
mag_data_slab_perfect = MagData(res, mc.create_mag_dist(mag_shape_slab_perfect, phi))
projection_slab_perfect = pj.simple_axis_projection(mag_data_slab_perfect)
# Slab (worst case):
center = (0, dim[1]/2, dim[2]/2) # in px (z, y, x) index starts with 0!
width = (1, dim[1], dim[2]) # in px (z, y, x)
mag_shape_slab_worst = mc.Shapes.slab(dim, center, width)
phase_ana_slab_worst = an.phase_mag_slab(dim, res, phi, center, width, b_0)
mag_data_slab_worst = MagData(res, mc.create_mag_dist(mag_shape_slab_worst, phi))
projection_slab_worst = pj.simple_axis_projection(mag_data_slab_worst)
# Disc:
center = (0, dim[1]/2.-0.5, dim[2]/2.-0.5) # in px (z, y, x) index starts with 0!
radius = dim[1]/2 # in px
height = 1 # in px
mag_shape_disc = mc.Shapes.disc(dim, center, radius, height)
phase_ana_disc = an.phase_mag_disc(dim, res, phi, center, radius, height, b_0)
mag_data_disc = MagData(res, mc.create_mag_dist(mag_shape_disc, phi))
projection_disc = pj.simple_axis_projection(mag_data_disc)
# NUMERICAL SOLUTIONS:
# Slab (perfectly aligned):
key = ', '.join(['Resolution->RMS|duration', 'Fourier', 'padding=0',
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=slab_perfect'])
if data_shelve.has_key(key):
data_slab_perfect[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_fourier(res, projection_slab_perfect, b_0, 0)
data_slab_perfect[2, i] = time.time() - start_time
phase_diff = phase_ana_slab_perfect - phase_num
data_slab_perfect[1, i] = np.std(phase_diff)
data_shelve[key] = data_slab_perfect[:, i]
# Slab (worst case):
key = ', '.join(['Resolution->RMS|duration', 'Fourier', 'padding=0',
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=slab_worst'])
if data_shelve.has_key(key):
data_slab_worst[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_fourier(res, projection_slab_worst, b_0, 0)
data_slab_worst[2, i] = time.time() - start_time
phase_diff = phase_ana_slab_worst - phase_num
data_slab_worst[1, i] = np.std(phase_diff)
data_shelve[key] = data_slab_worst[:, i]
# Disc:
key = ', '.join(['Resolution->RMS|duration', 'Fourier', 'padding=0',
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=disc'])
if data_shelve.has_key(key):
data_disc[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_fourier(res, projection_disc, b_0, 0)
data_disc[2, i] = time.time() - start_time
phase_diff = phase_ana_disc - phase_num
data_disc[1, i] = np.std(phase_diff)
data_shelve[key] = data_disc[:, i]
# Plot duration against res:
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.set_yscale('log')
axis.plot(data_slab_perfect[0], data_slab_perfect[1],
data_slab_worst[0], data_slab_worst[1],
data_disc[0], data_disc[1])
axis.set_title('Variation of the resolution (Fourier without padding)')
axis.set_xlabel('res [nm]')
axis.set_ylabel('RMS')
# Plot RMS against res:
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.plot(data_slab_perfect[0], data_slab_perfect[1],
data_slab_worst[0], data_slab_worst[1],
data_disc[0], data_disc[1])
axis.set_title('Variation of the resolution (Fourier without padding)')
axis.set_xlabel('res [nm]')
axis.set_ylabel('duration [s]')
data_shelve.close()
if __name__ == "__main__":
try:
phase_from_mag()
except:
type, value, tb = sys.exc_info()
traceback.print_exc()
pdb.post_mortem(tb)
\ No newline at end of file
# -*- coding: utf-8 -*-
"""Compare the different methods to create phase maps."""
import time
import pdb, traceback, sys
import numpy as np
from numpy import pi
import matplotlib.pyplot as plt
import pyramid.magcreator as mc
import pyramid.projector as pj
import pyramid.phasemapper as pm
import pyramid.analytic as an
from pyramid.magdata import MagData
import shelve
def compare_method_errors_res():
'''Calculate and display the phase map from a given magnetization.
Arguments:
None
Returns:
None
'''
# Create / Open databank:
data_shelve = shelve.open('../output/method_errors_shelve')
'''VARY DIMENSIONS FOR ALL APPROACHES'''
b_0 = 1 # in T
phi = -pi/4
dim_list = [(1, 4, 4), (1, 8, 8), (1, 16, 16), (1, 32, 32), (1, 64, 64),
(1, 128, 128), (1, 256, 256), (1, 512, 512)]
res_list = [64., 32., 16., 8., 4., 2., 1., 0.5, 0.25] # in nm
'''CREATE DATA ARRAYS'''
data_sl_p_fourier0 = np.zeros((3, len(res_list)))
data_sl_w_fourier0 = np.zeros((3, len(res_list)))
data_disc_fourier0 = np.zeros((3, len(res_list)))
data_sl_p_fourier1 = np.zeros((3, len(res_list)))
data_sl_w_fourier1 = np.zeros((3, len(res_list)))
data_disc_fourier1 = np.zeros((3, len(res_list)))
data_sl_p_fourier20 = np.zeros((3, len(res_list)))
data_sl_w_fourier20 = np.zeros((3, len(res_list)))
data_disc_fourier20 = np.zeros((3, len(res_list)))
data_sl_p_real_s = np.zeros((3, len(res_list)))
data_sl_w_real_s = np.zeros((3, len(res_list)))
data_disc_real_s = np.zeros((3, len(res_list)))
data_sl_p_real_d= np.zeros((3, len(res_list)))
data_sl_w_real_d = np.zeros((3, len(res_list)))
data_disc_real_d = np.zeros((3, len(res_list)))
'''CREATE DATA ARRAYS'''
data_sl_p_fourier0[0, :] = res_list
data_sl_w_fourier0[0, :] = res_list
data_disc_fourier0[0, :] = res_list
data_vort_fourier0[0, :] = res_list
data_sl_p_fourier1[0, :] = res_list
data_sl_w_fourier1[0, :] = res_list
data_disc_fourier1[0, :] = res_list
data_vort_fourier1[0, :] = res_list
data_sl_p_fourier20[0, :] = res_list
data_sl_w_fourier20[0, :] = res_list
data_disc_fourier20[0, :] = res_list
data_vort_fourier20[0, :] = res_list
data_sl_p_real_s[0, :] = res_list
data_sl_w_real_s[0, :] = res_list
data_disc_real_s[0, :] = res_list
data_vort_real_s[0, :] = res_list
data_sl_p_real_d[0, :]= res_list
data_sl_w_real_d[0, :] = res_list
data_disc_real_d[0, :] = res_list
data_vort_real_d[0, :] = res_list
for i, (dim, res) in enumerate(zip(dim_list, res_list)):
print 'i =', i, ' dim =', str(dim)
'''ANALYTIC SOLUTIONS'''
# Slab (perfectly aligned):
center = (0, dim[1]/2.-0.5, dim[2]/2.-0.5) # in px (z, y, x) index starts with 0!
width = (1, dim[1]/2, dim[2]/2) # in px (z, y, x)
mag_shape_sl_p = mc.Shapes.slab(dim, center, width)
phase_ana_sl_p = an.phase_mag_slab(dim, res, phi, center, width, b_0)
mag_data_sl_p = MagData(res, mc.create_mag_dist(mag_shape_sl_p, phi))
projection_sl_p = pj.simple_axis_projection(mag_data_sl_p)
# Slab (worst case):
center = (0, dim[1]/2, dim[2]/2) # in px (z, y, x) index starts with 0!
width = (1, dim[1]/2, dim[2]/2) # in px (z, y, x)
mag_shape_sl_w = mc.Shapes.slab(dim, center, width)
phase_ana_sl_w = an.phase_mag_slab(dim, res, phi, center, width, b_0)
mag_data_sl_w = MagData(res, mc.create_mag_dist(mag_shape_sl_w, phi))
projection_sl_w = pj.simple_axis_projection(mag_data_sl_w)
# Disc:
center = (0, dim[1]/2.-0.5, dim[2]/2.-0.5) # in px (z, y, x) index starts with 0!
radius = dim[1]/4 # in px
height = 1 # in px
mag_shape_disc = mc.Shapes.disc(dim, center, radius, height)
phase_ana_disc = an.phase_mag_disc(dim, res, phi, center, radius, height, b_0)
mag_data_disc = MagData(res, mc.create_mag_dist(mag_shape_disc, phi))
projection_disc = pj.simple_axis_projection(mag_data_disc)
# Vortex:
center_vortex = (center[1], center[2])
'''FOURIER UNPADDED'''
padding = 0
# Slab (perfectly aligned):
key = ', '.join(['Resolution->RMS|duration', 'Fourier', 'padding={}'.format(padding),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=sl_p'])
if data_shelve.has_key(key):
data_sl_p_fourier0[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_fourier(res, projection_sl_p, b_0, padding)
data_sl_p_fourier0[2, i] = time.time() - start_time
phase_diff = phase_ana_sl_p - phase_num
data_sl_p_fourier0[1, i] = np.std(phase_diff)
data_shelve[key] = data_sl_p_fourier0[:, i]
# Slab (worst case):
key = ', '.join(['Resolution->RMS|duration', 'Fourier', 'padding={}'.format(padding),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=sl_w'])
if data_shelve.has_key(key):
data_sl_w_fourier0[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_fourier(res, projection_sl_w, b_0, padding)
data_sl_w_fourier0[2, i] = time.time() - start_time
phase_diff = phase_ana_sl_w - phase_num
data_sl_w_fourier0[1, i] = np.std(phase_diff)
data_shelve[key] = data_sl_w_fourier0[:, i]
# Disc:
key = ', '.join(['Resolution->RMS|duration', 'Fourier', 'padding={}'.format(padding),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=disc'])
if data_shelve.has_key(key):
data_disc_fourier0[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_fourier(res, projection_disc, b_0, padding)
data_disc_fourier0[2, i] = time.time() - start_time
phase_diff = phase_ana_disc - phase_num
data_disc_fourier0[1, i] = np.std(phase_diff)
data_shelve[key] = data_disc_fourier0[:, i]
'''FOURIER PADDED ONCE'''
padding = 1
# Slab (perfectly aligned):
key = ', '.join(['Resolution->RMS|duration', 'Fourier', 'padding={}'.format(padding),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=sl_p'])
if data_shelve.has_key(key):
data_sl_p_fourier1[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_fourier(res, projection_sl_p, b_0, padding)
data_sl_p_fourier1[2, i] = time.time() - start_time
phase_diff = phase_ana_sl_p - phase_num
data_sl_p_fourier1[1, i] = np.std(phase_diff)
data_shelve[key] = data_sl_p_fourier1[:, i]
# Slab (worst case):
key = ', '.join(['Resolution->RMS|duration', 'Fourier', 'padding={}'.format(padding),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=sl_w'])
if data_shelve.has_key(key):
data_sl_w_fourier1[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_fourier(res, projection_sl_w, b_0, padding)
data_sl_w_fourier1[2, i] = time.time() - start_time
phase_diff = phase_ana_sl_w - phase_num
data_sl_w_fourier1[1, i] = np.std(phase_diff)
data_shelve[key] = data_sl_w_fourier1[:, i]
# Disc:
key = ', '.join(['Resolution->RMS|duration', 'Fourier', 'padding={}'.format(padding),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=disc'])
if data_shelve.has_key(key):
data_disc_fourier1[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_fourier(res, projection_disc, b_0, padding)
data_disc_fourier1[2, i] = time.time() - start_time
phase_diff = phase_ana_disc - phase_num
data_disc_fourier1[1, i] = np.std(phase_diff)
data_shelve[key] = data_disc_fourier1[:, i]
'''FOURIER PADDED 20'''
if dim[1] <= 128:
padding = 20
# Slab (perfectly aligned):
key = ', '.join(['Resolution->RMS|duration', 'Fourier', 'padding={}'.format(padding),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=sl_p'])
if data_shelve.has_key(key):
data_sl_p_fourier20[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_fourier(res, projection_sl_p, b_0, padding)
data_sl_p_fourier20[2, i] = time.time() - start_time
phase_diff = phase_ana_sl_p - phase_num
data_sl_p_fourier20[1, i] = np.std(phase_diff)
data_shelve[key] = data_sl_p_fourier20[:, i]
# Slab (worst case):
key = ', '.join(['Resolution->RMS|duration', 'Fourier', 'padding={}'.format(padding),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=sl_w'])
if data_shelve.has_key(key):
data_sl_w_fourier20[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_fourier(res, projection_sl_w, b_0, padding)
data_sl_w_fourier20[2, i] = time.time() - start_time
phase_diff = phase_ana_sl_w - phase_num
data_sl_w_fourier20[1, i] = np.std(phase_diff)
data_shelve[key] = data_sl_w_fourier20[:, i]
# Disc:
key = ', '.join(['Resolution->RMS|duration', 'Fourier', 'padding={}'.format(padding),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=disc'])
if data_shelve.has_key(key):
data_disc_fourier20[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_fourier(res, projection_disc, b_0, padding)
data_disc_fourier20[2, i] = time.time() - start_time
phase_diff = phase_ana_disc - phase_num
data_disc_fourier20[1, i] = np.std(phase_diff)
data_shelve[key] = data_disc_fourier20[:, i]
'''REAL SLAB'''
method = 'slab'
# Slab (perfectly aligned):
key = ', '.join(['Resolution->RMS|duration', 'Real', 'method={}'.format(method),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=sl_p'])
if data_shelve.has_key(key):
data_sl_p_real_s[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_real(res, projection_sl_p, method, b_0)
data_sl_p_real_s[2, i] = time.time() - start_time
phase_diff = phase_ana_sl_p - phase_num
data_sl_p_real_s[1, i] = np.std(phase_diff)
data_shelve[key] = data_sl_p_real_s[:, i]
# Slab (worst case):
key = ', '.join(['Resolution->RMS|duration', 'Real', 'method={}'.format(method),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=sl_w'])
if data_shelve.has_key(key):
data_sl_w_real_s[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_real(res, projection_sl_w, method, b_0)
data_sl_w_real_s[2, i] = time.time() - start_time
phase_diff = phase_ana_sl_w - phase_num
data_sl_w_real_s[1, i] = np.std(phase_diff)
data_shelve[key] = data_sl_w_real_s[:, i]
# Disc:
key = ', '.join(['Resolution->RMS|duration', 'Real', 'method={}'.format(method),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=disc'])
if data_shelve.has_key(key):
data_disc_real_s[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_real(res, projection_disc, method, b_0)
data_disc_real_s[2, i] = time.time() - start_time
phase_diff = phase_ana_disc - phase_num
data_disc_real_s[1, i] = np.std(phase_diff)
data_shelve[key] = data_disc_real_s[:, i]
'''REAL DISC'''
method = 'disc'
# Slab (perfectly aligned):
key = ', '.join(['Resolution->RMS|duration', 'Real', 'method={}'.format(method),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=sl_p'])
if data_shelve.has_key(key):
data_sl_p_real_d[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_real(res, projection_sl_p, method, b_0)
data_sl_p_real_d[2, i] = time.time() - start_time
phase_diff = phase_ana_sl_p - phase_num
data_sl_p_real_d[1, i] = np.std(phase_diff)
data_shelve[key] = data_sl_p_real_d[:, i]
# Slab (worst case):
key = ', '.join(['Resolution->RMS|duration', 'Real', 'method={}'.format(method),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=sl_w'])
if data_shelve.has_key(key):
data_sl_w_real_d[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_real(res, projection_sl_w, method, b_0)
data_sl_w_real_d[2, i] = time.time() - start_time
phase_diff = phase_ana_sl_w - phase_num
data_sl_w_real_d[1, i] = np.std(phase_diff)
data_shelve[key] = data_sl_w_real_d[:, i]
# Disc:
key = ', '.join(['Resolution->RMS|duration', 'Real', 'method={}'.format(method),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=disc'])
if data_shelve.has_key(key):
data_disc_real_d[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_real(res, projection_disc, method, b_0)
data_disc_real_d[2, i] = time.time() - start_time
phase_diff = phase_ana_disc - phase_num
data_disc_real_d[1, i] = np.std(phase_diff)
data_shelve[key] = data_disc_real_d[:, i]
# Plot duration against res (perfect slab):
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.set_yscale('log')
axis.plot(data_sl_p_fourier0[0], data_sl_p_fourier0[1], 'b+',
data_sl_p_fourier1[0], data_sl_p_fourier1[1], 'bx',
data_sl_p_fourier20[0], data_sl_p_fourier20[1], 'b*',
data_sl_p_real_s[0], data_sl_p_real_s[1], 'rs',
data_sl_p_real_d[0], data_sl_p_real_d[1], 'ro')
axis.set_title('Variation of the resolution (perfectly adjusted slab)')
axis.set_xlabel('res [nm]')
axis.set_ylabel('RMS')
# Plot RMS against res (perfect slab):
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.set_yscale('log')
axis.plot(data_sl_p_fourier0[0], data_sl_p_fourier0[2], 'b+',
data_sl_p_fourier1[0], data_sl_p_fourier1[2], 'bx',
data_sl_p_fourier20[0], data_sl_p_fourier20[2], 'b*',
data_sl_p_real_s[0], data_sl_p_real_s[2], 'rs',
data_sl_p_real_d[0], data_sl_p_real_d[2], 'ro')
axis.set_title('Variation of the resolution (perfectly adjusted slab)')
axis.set_xlabel('res [nm]')
axis.set_ylabel('duration [s]')
# Plot duration against res (worst case slab):
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.set_yscale('log')
axis.plot(data_sl_w_fourier0[0], data_sl_w_fourier0[1], 'b+',
data_sl_w_fourier1[0], data_sl_w_fourier1[1], 'bx',
data_sl_w_fourier20[0], data_sl_w_fourier20[1], 'b*',
data_sl_w_real_s[0], data_sl_w_real_s[1], 'rs',
data_sl_w_real_d[0], data_sl_w_real_d[1], 'ro')
axis.set_title('Variation of the resolution (worst case slab)')
axis.set_xlabel('res [nm]')
axis.set_ylabel('RMS')
# Plot RMS against res (worst case slab):
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.set_yscale('log')
axis.plot(data_sl_w_fourier0[0], data_sl_w_fourier0[2], 'b+',
data_sl_w_fourier1[0], data_sl_w_fourier1[2], 'bx',
data_sl_w_fourier20[0], data_sl_w_fourier20[2], 'b*',
data_sl_w_real_s[0], data_sl_w_real_s[2], 'rs',
data_sl_w_real_d[0], data_sl_w_real_d[2], 'ro')
axis.set_title('Variation of the resolution (worst case slab)')
axis.set_xlabel('res [nm]')
axis.set_ylabel('duration [s]')
# Plot duration against res (disc<):
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.set_yscale('log')
axis.plot(data_disc_fourier0[0], data_disc_fourier0[1], 'b+',
data_disc_fourier1[0], data_disc_fourier1[1], 'bx',
data_disc_fourier20[0], data_disc_fourier20[1], 'b*',
data_disc_real_s[0], data_disc_real_s[1], 'rs',
data_disc_real_d[0], data_disc_real_d[1], 'ro')
axis.set_title('Variation of the resolution (disc)')
axis.set_xlabel('res [nm]')
axis.set_ylabel('RMS')
# Plot RMS against res (disc):
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.set_yscale('log')
axis.plot(data_disc_fourier0[0], data_disc_fourier0[2], 'b+',
data_disc_fourier1[0], data_disc_fourier1[2], 'bx',
data_disc_fourier20[0], data_disc_fourier20[2], 'b*',
data_disc_real_s[0], data_disc_real_s[2], 'rs',
data_disc_real_d[0], data_disc_real_d[2], 'ro')
axis.set_title('Variation of the resolution (disc)')
axis.set_xlabel('res [nm]')
axis.set_ylabel('duration [s]')
data_shelve.close()
if __name__ == "__main__":
try:
compare_method_errors_res()
except:
type, value, tb = sys.exc_info()
traceback.print_exc()
pdb.post_mortem(tb)
\ No newline at end of file
# -*- coding: utf-8 -*-
"""Compare the different methods to create phase maps."""
import time
import pdb, traceback, sys
import numpy as np
from numpy import pi
import pyramid.magcreator as mc
import pyramid.projector as pj
import pyramid.phasemapper as pm
import pyramid.holoimage as hi
import pyramid.analytic as an
from pyramid.magdata import MagData
from pyramid.phasemap import PhaseMap
def compare_methods():
'''Calculate and display the phase map from a given magnetization.
Arguments:
None
Returns:
None
'''
# Input parameters:
b_0 = 1 # in T
res = 10.0 # in nm
phi = pi/4
padding = 20
density = 10
dim = (1, 128, 128) # in px (z, y, x)
# Create magnetic shape:
geometry = 'slab'
if geometry == 'slab':
center = (0, dim[1]/2., dim[2]/2.) # in px (z, y, x) index starts with 0!
width = (1, dim[1]/2.-0.5, dim[2]/2.-0.5) # in px (z, y, x)
mag_shape = mc.Shapes.slab(dim, center, width)
phase_ana = an.phase_mag_slab(dim, res, phi, center, width, b_0)
elif geometry == 'disc':
center = (0, dim[1]/2.-0.5, dim[2]/2.-0.5) # in px (z, y, x) index starts with 0!
radius = dim[1]/4 # in px
height = 1 # in px
mag_shape = mc.Shapes.disc(dim, center, radius, height)
phase_ana = an.phase_mag_disc(dim, res, phi, center, radius, height, b_0)
elif geometry == 'sphere':
center = (50, 50, 50) # in px (z, y, x) index starts with 0!
radius = 25 # in px
mag_shape = mc.Shapes.sphere(dim, center, radius)
phase_ana = an.phase_mag_sphere(dim, res, phi, center, radius, b_0)
# Project the magnetization data:
mag_data = MagData(res, mc.create_mag_dist(mag_shape, phi))
mag_data.quiver_plot(ax_slice=int(center[0]))
projection = pj.simple_axis_projection(mag_data)
# Construct phase maps:
phase_map_ana = PhaseMap(res, phase_ana)
start_time = time.time()
phase_map_fft = PhaseMap(res, pm.phase_mag_fourier(res, projection, b_0, padding))
print 'Time for Fourier space approach: ', time.time() - start_time
start_time = time.time()
phase_map_slab = PhaseMap(res, pm.phase_mag_real(res, projection, 'slab', b_0))
print 'Time for real space approach (Slab):', time.time() - start_time
start_time = time.time()
phase_map_disc = PhaseMap(res, pm.phase_mag_real(res, projection, 'disc', b_0))
print 'Time for real space approach (Disc):', time.time() - start_time
# Display the combinated plots with phasemap and holography image:
hi.display_combined(phase_map_ana, density, 'Analytic Solution')
hi.display_combined(phase_map_fft, density, 'Fourier Space')
hi.display_combined(phase_map_slab, density, 'Real Space (Slab)')
hi.display_combined(phase_map_disc, density, 'Real Space (Disc)')
# Plot differences to the analytic solution:
phase_map_diff_fft = PhaseMap(res, phase_map_ana.phase-phase_map_fft.phase)
phase_map_diff_slab = PhaseMap(res, phase_map_ana.phase-phase_map_slab.phase)
phase_map_diff_disc = PhaseMap(res, phase_map_ana.phase-phase_map_disc.phase)
RMS_fft = np.std(phase_map_diff_fft.phase)
RMS_slab = np.std(phase_map_diff_slab.phase)
RMS_disc = np.std(phase_map_diff_disc.phase)
phase_map_diff_fft.display('Fourier Space (RMS = {:3.2e})'.format(RMS_fft))
phase_map_diff_slab.display('Real Space (Slab) (RMS = {:3.2e})'.format(RMS_slab))
phase_map_diff_disc.display('Real Space (Disc) (RMS = {:3.2e})'.format(RMS_disc))
if __name__ == "__main__":
try:
compare_methods()
except:
type, value, tb = sys.exc_info()
traceback.print_exc()
pdb.post_mortem(tb)
\ No newline at end of file