Skip to content
Snippets Groups Projects
Commit ca664902 authored by Jan Caron's avatar Jan Caron
Browse files

Changed cython folder to numcore subfolder

Changed setup.py
Implemented assertion to check if jacobi matrix is the same
parent 57c194d7
No related branches found
No related tags found
No related merge requests found
[.ShellClassInfo]
IconResource=C:\Users\Jan\Daten\FZ-Jlich\PYRAMID\pyramid.ico,0
IconResource=C:\Users\Jan\PhD Thesis\Pyramid\icon.ico,0
[ViewState]
Mode=
Vid=
......
# -*- coding: utf-8 -*-
"""Load magnetization data from LLG files."""
import numpy as np
class MagData:
'''An object storing magnetization data loaded from a LLG-file.'''
def __init__(self, x_mag, y_mag, z_mag, res): # TODO: electrostatic component!
'''Load magnetization in LLG-file format.
Arguments:
filename - the name of the file where the data are stored
Returns:
None
'''
assert np.shape(x_mag) == np.shape(y_mag) == np.shape(z_mag), 'Dimensions do not match!'
self.res = res
self.dim = np.shape(x_mag)
scale = 1.0E-9 / 1.0E-2 #from cm to nm
data = np.genfromtxt(filename, skip_header=2)
x_dim, y_dim, z_dim = np.genfromtxt(filename, dtype=int,
skip_header=1,
skip_footer=len(data[:, 0]))
res = (data[1, 0] - data[0, 0]) / scale
x_len, y_len, z_len = [data[-1, i]/scale+res/2 for i in range(3)]
x_mag, y_mag, z_mag = [data[:, i].reshape(z_dim, y_dim, x_dim)
for i in range(3,6)]
#Reshape in Python and Igor is different,
#Python fills rows first, Igor columns!
self.filename = filename
self.res = res
self.dim = (z_dim, y_dim, x_dim)
self.length = (z_len, y_len, x_len)
self.magnitude = (z_mag, y_mag, x_mag)
def __str__(self):
'''Return the filename of the loaded file.
Arguments:
None
Returns:
the name of the loaded file as a string
'''
return self.filename
\ No newline at end of file
File moved
File moved
File moved
File moved
File moved
# -*- coding: utf-8 -*-
"""
Created on Fri May 03 10:27:04 2013
......@@ -8,8 +7,18 @@ Created on Fri May 03 10:27:04 2013
#call with: python setup.py build_ext --inplace --compiler=mingw32
import glob
import numpy
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
from Cython.Distutils import build_ext
#setup(
# cmdclass = {'build_ext': build_ext},
# ext_modules = [Extension("multiply",
# sources=["multiply.pyx", "c_multiply.c"],
# include_dirs=[numpy.get_include()])],
#)
setup(
name = 'Pyramex',
......@@ -18,4 +27,4 @@ setup(
author = 'Jan Caron',
author_email = 'j.caron@fz-juelich.de',
ext_modules = cythonize(glob.glob('*.pyx'))
)
\ No newline at end of file
)
......@@ -129,7 +129,8 @@ def real_space(mag_data, method, b_0=1, jacobi=None):
phase = np.zeros((y_dim, x_dim))
# TODO: only iterate over pixels that have a magn. > threshold (first >0)
jacobi_fd = jacobi.copy()
if jacobi is not None:
jacobi_fd = jacobi.copy()
h = 0.0001
for j in range(y_dim):
......@@ -146,8 +147,9 @@ def real_space(mag_data, method, b_0=1, jacobi=None):
jacobi_diff = jacobi_fd - jacobi
assert (np.abs(jacobi_diff) < 1.0E-8).all(), 'jacobi matrix is not the same'
if jacobi is not None:
jacobi_diff = jacobi_fd - jacobi
assert (np.abs(jacobi_diff) < 1.0E-8).all(), 'jacobi matrix is not the same'
return phase
......
# -*- coding: utf-8 -*-
"""
Created on Mon May 13 13:05:40 2013
@author: Jan
"""
import random
import numpy as np
import matplotlib.pyplot as plt
import pyramid.magcreator as mc
import time
import pdb, traceback, sys
from numpy import pi
def phase_from_mag():
count = 10
dim = (128, 128)
random.seed(42)
for i in range(count):
x = random.rand
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
......@@ -18,8 +18,6 @@ setup(
description = 'PYthon based Reconstruction Algorithm for MagnetIc Distributions',
author = 'Jan Caron',
author_email = 'j.caron@fz-juelich.de',
package_dir = {'': 'src'},
packages = ['pyramid'],
ext_package = ['pyramex']
ext_modules = cythonize(glob.glob(os.path.join('pyramex','*.pyx')))
ext_modules = cythonize(glob.glob(os.path.join('pyramid','numcore','*.pyx')))
)
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