From 0afb984a6bf7eaeb4a509d8addbf2c0fb120f7da Mon Sep 17 00:00:00 2001 From: Jan Caron <caron@fz-juelich.de> Date: Tue, 30 Apr 2013 09:34:40 +0200 Subject: [PATCH] =?UTF-8?q?Found=20a=20way=20to=20use=20a=20src=20folder?= =?UTF-8?q?=20(PYRAMID=20as=20project,=20FZ-J=FClich=20as=20workspace)=20R?= =?UTF-8?q?emoved=20old=20scripts=20(AnalyticSolution=20and=20DataLoader)?= =?UTF-8?q?=20Added=20several=20template=20testcases?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/AnalyticSolutionRealDisc.py | 63 -------- scripts/AnalyticSolutionRealSpaceSlab.py | 191 ----------------------- scripts/AnalyticSolutionRealSphere.py | 72 --------- scripts/DataLoaderRealSpace.py | 105 ------------- scripts/compare_methods.py | 172 ++++++++++++++++++++ scripts/create_logo.py | 44 ++++++ scripts/create_samples.py | 172 ++++++++++++++++++++ scripts/get_jacobi.py | 172 ++++++++++++++++++++ scripts/main.py | 12 +- {pyramid => src/pyramid}/__init__.py | 0 {pyramid => src/pyramid}/analytic.py | 0 {pyramid => src/pyramid}/dataloader.py | 0 {pyramid => src/pyramid}/holoimage.py | 0 {pyramid => src/pyramid}/magcreator.py | 2 +- {pyramid => src/pyramid}/phasemap.py | 2 + test/test_analytic.py | 29 ++++ test/test_dataloader.py | 29 ++++ test/test_holoimage.py | 29 ++++ test/test_magcreator.py | 29 ++++ test/test_phasemap.py | 31 ++++ 20 files changed, 716 insertions(+), 438 deletions(-) delete mode 100644 scripts/AnalyticSolutionRealDisc.py delete mode 100644 scripts/AnalyticSolutionRealSpaceSlab.py delete mode 100644 scripts/AnalyticSolutionRealSphere.py delete mode 100644 scripts/DataLoaderRealSpace.py create mode 100644 scripts/compare_methods.py create mode 100644 scripts/create_logo.py create mode 100644 scripts/create_samples.py create mode 100644 scripts/get_jacobi.py rename {pyramid => src/pyramid}/__init__.py (100%) rename {pyramid => src/pyramid}/analytic.py (100%) rename {pyramid => src/pyramid}/dataloader.py (100%) rename {pyramid => src/pyramid}/holoimage.py (100%) rename {pyramid => src/pyramid}/magcreator.py (97%) rename {pyramid => src/pyramid}/phasemap.py (96%) create mode 100644 test/test_analytic.py create mode 100644 test/test_dataloader.py create mode 100644 test/test_holoimage.py create mode 100644 test/test_magcreator.py create mode 100644 test/test_phasemap.py diff --git a/scripts/AnalyticSolutionRealDisc.py b/scripts/AnalyticSolutionRealDisc.py deleted file mode 100644 index ad49807..0000000 --- a/scripts/AnalyticSolutionRealDisc.py +++ /dev/null @@ -1,63 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Created on Wed Mar 20 10:24:40 2013 - -@author: Jan -""" - -'''IMPORT''' -from pylab import * -import numpy as np -from numpy import pi -import matplotlib.pyplot as plt -from mpl_toolkits.mplot3d import Axes3D -#from matplotlib.ticker import FormatStrFormatter - -'''CONSTANTS''' -PHI_0 = 2067.83 # magnetic flux in T*nm² - -'''INPUT VARIABLES''' -b0 = 1.0 #in T -v0 = 0 -Vacc = 30000 -xDim, yDim = 160, 160 -res = 10 #in nm -beta = 300.0/360.0 * 2*pi -x0 = res*xDim*0.5 -y0 = res*yDim*0.5 -R = res*xDim*0.2 - -'''CREATE COORDINATE GRIDS''' -x = np.linspace(res/2,xDim*res-res/2,num=xDim) -y = np.linspace(res/2,yDim*res-res/2,num=yDim) -xx, yy = np.meshgrid(x,y) - -'''COMPUTATION MAGNETIC PHASE SHIFT (REAL SPACE) DISC''' - -coeff = - pi * res * b0 / ( 2 * PHI_0 ) - -def phiMag(x,y): - r = np.sqrt((x-x0) ** 2 + (y-y0) ** 2) - result = coeff * ((y-y0) * np.cos(beta) - (x-x0) * np.sin(beta)) - in_or_out = 1 * (r < R) + (R / r) ** 2 * (r > R) - result *= in_or_out - return result - -phaseMag = phiMag(xx, yy) - -def plot_phase(func, name): - fig = plt.figure() - ax = fig.add_subplot(111, aspect='equal') - plt.pcolormesh(func, cmap='Greys') - ticks = ax.get_xticks() * res - ax.set_xticklabels(ticks.astype(int)) - ticks = ax.get_yticks() * res - ax.set_yticklabels(ticks.astype(int)) - ax.set_title('Analytical Solution' + name) - ax.set_xlabel('x-axis [nm]') - ax.set_ylabel('y-axis [nm]') - plt.colorbar() - plt.show() - -plot_phase(phaseMag, ' Disc - Phase') -plot_phase(cos(16*phaseMag), ' Disc - Cos(Phase)') \ No newline at end of file diff --git a/scripts/AnalyticSolutionRealSpaceSlab.py b/scripts/AnalyticSolutionRealSpaceSlab.py deleted file mode 100644 index 775b695..0000000 --- a/scripts/AnalyticSolutionRealSpaceSlab.py +++ /dev/null @@ -1,191 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Created on Wed Mar 20 10:24:40 2013 - -@author: Jan -""" - -'''IMPORT''' -from pylab import * -import numpy as np -from numpy import pi -import matplotlib.pyplot as plt -from mpl_toolkits.mplot3d import Axes3D -#from matplotlib.ticker import FormatStrFormatter - -'''CONSTANTS''' -PHI_0 = 2067.83 # magnetic flux in T*nm² - -'''INPUT VARIABLES''' -b0 = 1.0 #in T -v0 = 0 -Vacc = 30000 -xDim, yDim = 160, 160 -res = 10 #in nm -beta = 300.0/360.0 * 2*pi -x0 = res*xDim*0.5 -y0 = res*yDim*0.5 -Lx = res*xDim*0.2 -Ly = res*yDim*0.4 - -'''CREATE COORDINATE GRIDS''' -x = np.linspace(res/2,xDim*res-res/2,num=xDim) -y = np.linspace(res/2,yDim*res-res/2,num=yDim) -#xx, yy = np.meshgrid(x,y) - -'''COMPUTATION MAGNETIC PHASE SHIFT (REAL SPACE) SLAB''' -def F0(x,y): - a = np.log( x**2 + y**2 ) - b = np.arctan( x / y ) # atan or atan2? - return x*a - 2*x + 2*y*b - -coeff = b0 * res / ( 4 * PHI_0 ) - -def phiMag(x,y): - return coeff * ( - np.cos(beta) * ( F0(x-x0-Lx/2,y-y0-Ly/2)-F0(x-x0+Lx/2,y-y0-Ly/2) - -F0(x-x0-Lx/2,y-y0+Ly/2)+F0(x-x0+Lx/2,y-y0+Ly/2) ) - + np.sin(beta) * ( F0(y-y0-Ly/2,x-x0-Lx/2)-F0(y-y0+Ly/2,x-x0-Lx/2) - -F0(y-y0-Ly/2,x-x0+Lx/2)+F0(y-y0+Ly/2,x-x0+Lx/2) ) ) - -def F0_Cos_1(x,y): - return coeff * np.cos(beta) * F0(x-x0-Lx/2,y-y0-Ly/2) - -def F0_Cos_2(x,y): - return coeff * np.cos(beta) * F0(x-x0+Lx/2,y-y0-Ly/2) - -def F0_Cos_3(x,y): - return coeff * np.cos(beta) * F0(x-x0-Lx/2,y-y0+Ly/2) - -def F0_Cos_4(x,y): - return coeff * np.cos(beta) * F0(x-x0+Lx/2,y-y0+Ly/2) - -def F0_Sin_1(x,y): - return coeff * np.sin(beta) * F0(y-y0-Ly/2,x-x0-Lx/2) - -def F0_Sin_2(x,y): - return coeff * np.sin(beta) * F0(y-y0+Ly/2,x-x0-Lx/2) - -def F0_Sin_3(x,y): - return coeff * np.sin(beta) * F0(y-y0-Ly/2,x-x0+Lx/2) - -def F0_Sin_4(x,y): - return coeff * np.sin(beta) * F0(y-y0+Ly/2,x-x0+Lx/2) - - -def phiMag1(x,y): - return coeff * ( - 0*np.cos(beta) + 1*( F0(x-x0-Lx/2,y-y0-Ly/2)-F0(x-x0+Lx/2,y-y0-Ly/2)) ) - -def phiMag2(x,y): - return coeff * ( - 0*np.cos(beta) + 1*(-F0(x-x0-Lx/2,y-y0+Ly/2)+F0(x-x0+Lx/2,y-y0+Ly/2) ) ) - -def phiMag3(x,y): - return coeff * ( + 0*np.sin(beta) + 1*( F0(y-y0-Ly/2,x-x0-Lx/2)-F0(y-y0+Ly/2,x-x0-Lx/2) ) ) - -def phiMag4(x,y): - return coeff * ( + 0*np.sin(beta) + 1*(-F0(y-y0-Ly/2,x-x0+Lx/2)+F0(y-y0+Ly/2,x-x0+Lx/2) ) ) - -def Test(x,y): - return ( abs(x-x0)<Lx/2 and abs(y-y0)<Ly/2 ) - -xx, yy = np.meshgrid(x,y) - -phaseMag = phiMag(xx, yy) - -phase_F0_Cos_1 = F0_Cos_1(xx, yy) -phase_F0_Cos_2 = F0_Cos_2(xx, yy) -phase_F0_Cos_3 = F0_Cos_3(xx, yy) -phase_F0_Cos_4 = F0_Cos_4(xx, yy) -phase_F0_Sin_1 = F0_Sin_1(xx, yy) -phase_F0_Sin_2 = F0_Sin_2(xx, yy) -phase_F0_Sin_3 = F0_Sin_3(xx, yy) -phase_F0_Sin_4 = F0_Sin_4(xx, yy) - -sinphase_F0_Cos_1 = np.sin(phase_F0_Cos_1) -sinphase_F0_Cos_2 = np.sin(phase_F0_Cos_2) -sinphase_F0_Cos_3 = np.sin(phase_F0_Cos_3) -sinphase_F0_Cos_4 = np.sin(phase_F0_Cos_4) -sinphase_F0_Sin_1 = np.sin(phase_F0_Sin_1) -sinphase_F0_Sin_2 = np.sin(phase_F0_Sin_2) -sinphase_F0_Sin_3 = np.sin(phase_F0_Sin_3) -sinphase_F0_Sin_4 = np.sin(phase_F0_Sin_4) - -phase_F0_Cos_Complete = (phase_F0_Cos_1 + phase_F0_Cos_2 - + phase_F0_Cos_3 + phase_F0_Cos_4) - -phase_F0_Sin_Complete = (phase_F0_Sin_1 + phase_F0_Sin_2 - + phase_F0_Sin_3 + phase_F0_Sin_4) - -sinphase_F0_Cos_Complete = (sinphase_F0_Cos_1 + sinphase_F0_Cos_2 - + sinphase_F0_Cos_3 + sinphase_F0_Cos_4) - -sinphase_F0_Sin_Complete = (sinphase_F0_Sin_1 + sinphase_F0_Sin_2 - + sinphase_F0_Sin_3 + sinphase_F0_Sin_4) - -phaseMag1 = phiMag1(xx, yy) -phaseMag2 = phiMag2(xx, yy) -phaseMag3 = phiMag3(xx, yy) -phaseMag4 = phiMag4(xx, yy) - - -def plot_phase(func, name): - fig = plt.figure() - ax = fig.add_subplot(111, aspect='equal') - plt.pcolormesh(func, cmap='jet') - ticks = ax.get_xticks() * res - ax.set_xticklabels(ticks.astype(int)) - ticks = ax.get_yticks() * res - ax.set_yticklabels(ticks.astype(int)) - ax.set_title('Analytical Solution' + name) - ax.set_xlabel('x-axis [nm]') - ax.set_ylabel('y-axis [nm]') - plt.colorbar() - plt.show() - - -'''PLOT''' - -fig = plt.figure() -ax = fig.add_subplot(111, aspect='equal') -plt.pcolormesh(np.cos(16*phaseMag), cmap='Greys') -ticks = ax.get_xticks()*res -ax.set_xticklabels(ticks.astype(int)) -ticks = ax.get_yticks()*res -ax.set_yticklabels(ticks.astype(int)) -ax.set_title('Analytical Solution') -ax.set_xlabel('x-axis [nm]') -ax.set_ylabel('y-axis [nm]') -plt.colorbar() -plt.show() - -'''PLOT F0s''' -plot_phase(phase_F0_Cos_Complete, 'F0_Cos_Complete') -plot_phase(phase_F0_Sin_Complete, 'F0_Sin_Complete') -plot_phase(sinphase_F0_Cos_Complete, 'Sin_F0_Cos_Complete') -plot_phase(sinphase_F0_Sin_Complete, 'Sin_F0_Sin_Complete') -#plot_phase(phase_F0_Cos_1, 'F0_Cos_1') -#plot_phase(phase_F0_Cos_2, 'F0_Cos_2') -#plot_phase(phase_F0_Cos_3, 'F0_Cos_3') -#plot_phase(phase_F0_Cos_4, 'F0_Cos_4') -#plot_phase(phase_F0_Sin_1, 'F0_Sin_1') -#plot_phase(phase_F0_Sin_2, 'F0_Sin_2') -#plot_phase(phase_F0_Sin_3, 'F0_Sin_3') -#plot_phase(phase_F0_Sin_4, 'F0_Sin_4') -#plot_phase(phase_F0_Cos_1-phase_F0_Cos_3, 'F0_Cos_1-3') -#plot_phase(phase_F0_Cos_2-phase_F0_Cos_4, 'F0_Cos_2-4') -#plot_phase(phase_F0_Sin_1-phase_F0_Sin_3, 'F0_Sin_1-3') -#plot_phase(phase_F0_Sin_2-phase_F0_Sin_4, 'F0_Sin_2-4') -#plot_phase(phase_F0_Cos_1-phase_F0_Cos_3 + phase_F0_Cos_2-phase_F0_Cos_4, -# 'F0_Cos_Complete') -#plot_phase(phase_F0_Sin_1-phase_F0_Sin_3 + phase_F0_Sin_2-phase_F0_Sin_4, -# 'F0_Sin_Complete') -# plot_phase(phase_F0_Sin_1-phase_F0_Sin_3 + phase_F0_Sin_2-phase_F0_Sin_4, -# 'F0_Sin_Complete') - - -x = np.linspace(-50,50,100) -y = np.linspace(-50,50,100) - -xx, yy = np.meshgrid(x,y) - -Arc2 = np.arctan2(yy,xx) -Arc = np.arctan(yy/xx) \ No newline at end of file diff --git a/scripts/AnalyticSolutionRealSphere.py b/scripts/AnalyticSolutionRealSphere.py deleted file mode 100644 index 1b0899c..0000000 --- a/scripts/AnalyticSolutionRealSphere.py +++ /dev/null @@ -1,72 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Created on Wed Mar 20 10:24:40 2013 - -@author: Jan -""" - - -'''PROBLEM: Sphere is 3D, current model is just 2D''' - - - -'''IMPORT''' -from pylab import * -import numpy as np -from numpy import pi -import matplotlib.pyplot as plt -from mpl_toolkits.mplot3d import Axes3D -#from matplotlib.ticker import FormatStrFormatter - -'''CONSTANTS''' -PHI_0 = 2067.83 # magnetic flux in T*nm² - -'''INPUT VARIABLES''' -b0 = 1.0 #in T -v0 = 0 -Vacc = 30000 -xDim, yDim = 160, 160 -res = 10 #in nm -beta = 300.0/360.0 * 2*pi -x0 = res*xDim*0.5 -y0 = res*yDim*0.5 -R = res*xDim*0.2 - -'''CREATE COORDINATE GRIDS''' -x = np.linspace(res/2,xDim*res-res/2,num=xDim) -y = np.linspace(res/2,yDim*res-res/2,num=yDim) -xx, yy = np.meshgrid(x,y) - -'''COMPUTATION MAGNETIC PHASE SHIFT (REAL SPACE) DISC''' -def F0(x,y): - a = np.log( x**2 + y**2 ) - b = np.arctan2( x, y ) # atan or atan2? - return x*a - 2*x + 2*y*b - -coeff = - 2/3 * pi * R**3 * b0 / PHI_0 * res/R - -def phiMag(x,y): - r = np.sqrt((x-x0) ** 2 + (y-y0) ** 2) - result = coeff / r**2 * ((y-y0) * np.cos(beta) - (x-x0) * np.sin(beta)) - in_or_out = 1 * (r > R) + (1 - (1-(r/R)**2)**(3/2)) * (r < R) - result *= in_or_out - return result - -phaseMag = phiMag(xx, yy) - -def plot_phase(func, name): - fig = plt.figure() - ax = fig.add_subplot(111, aspect='equal') - plt.pcolormesh(func, cmap='Greys') - ticks = ax.get_xticks() * res - ax.set_xticklabels(ticks.astype(int)) - ticks = ax.get_yticks() * res - ax.set_yticklabels(ticks.astype(int)) - ax.set_title('Analytical Solution' + name) - ax.set_xlabel('x-axis [nm]') - ax.set_ylabel('y-axis [nm]') - plt.colorbar() - plt.show() - -plot_phase(phaseMag, ' Sphere - Phase') -plot_phase(cos(16*phaseMag), ' Sphere - Cos(Phase)') \ No newline at end of file diff --git a/scripts/DataLoaderRealSpace.py b/scripts/DataLoaderRealSpace.py deleted file mode 100644 index ee68a3d..0000000 --- a/scripts/DataLoaderRealSpace.py +++ /dev/null @@ -1,105 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Created on Wed Mar 20 10:24:40 2013 - -@author: Jan -""" - -'''IMPORT''' -import numpy as np -from numpy import pi, e -import matplotlib.pyplot as plt -import math as ma - -'''CONSTANTS''' -PHI_0 = 2067.83 - -'''INPUT VARIABLES''' -b0 = 1.0 -v0 = 0 -Vacc = 30000 -scale=1E-7 -padFactor = 2 -filename = 'output.txt' - -'''READ DATA''' -data = np.genfromtxt(filename, skip_header=2) -xDim, yDim, zDim = np.genfromtxt(filename, dtype=int, skip_header=1, skip_footer=len(data[:,0])) -res = (data[1,0] - data[0,0]) / scale -xLen, yLen, zLen = [data[-1,i]/scale+res/2 for i in range(3)] -xMag, yMag, zMag = [data[:,i].reshape(zDim,yDim,xDim).mean(0)*zLen for i in range(3,6)] -#Reshape in Python and Igor is different, Python fills rows first, Igor columns! -#TODO interpolation (redefine xDim,yDim,zDim) thickness ramp - -'''COMPUTATION MAGNETIC PHASE SHIFT (REAL SPACE) SLAB''' -# def F0(x,y): -# a = np.log( x**2 + y**2 ) -# b = np.arctan( x / y ) -# return x*a - 2*x + 2*y*b -# -# coeff = b0 * res / ( 4 * PHI_0 ) -# -# def phiMag(x,y): -# return coeff * ( - np.cos(beta) * ( F0(x-x0-Lx/2,y-y0-Ly/2) -# -F0(x-x0+Lx/2,y-y0-Ly/2) -# -F0(x-x0-Lx/2,y-y0+Ly/2) -# +F0(x-x0+Lx/2,y-y0+Ly/2) ) -# + np.sin(beta) * ( F0(y-y0-Ly/2,x-x0-Lx/2) -# -F0(y-y0+Ly/2,x-x0-Lx/2) -# -F0(y-y0-Ly/2,x-x0+Lx/2) -# +F0(y-y0+Ly/2,x-x0+Lx/2) ) ) -# -# return phiMag(xx, yy) - - - - - - -def F(n,m): - a = np.log( res**2/4 * ( (2*n-1)**2 + (2*m-1)**2 ) ) - b = np.arctan( (2*n-1) / (2*m-1) ) - return res * ( (n-1/2)*a - (2*n-1) + (2*m-1)*b ) - -coeff = b0 / ( 4 * PHI_0 ) - -beta = np.arctan2(yMag, xMag) - -absMag = np.sqrt(xMag**2 + yMag**2) - -def phi_ij(i,j,p,q): - return absMag[j,i] * ( - np.cos(beta[j,i]) * (F(p-i,q-j)-F(p-i+1,q-j) - -F(p-i,q-j+1)+F(p-i+1,q-j+1)) - + np.sin(beta[j,i]) * (F(q-j,p-i)-F(q-j+1,p-i) - -F(q-j,p-i+1)+F(q-j+1,p-i+1)) ) - -phaseMag = np.zeros((yDim,xDim)) - - - -for q in range(yDim): - for p in range(xDim): - for j in range(yDim): - for i in range(xDim): - phaseMag[q,p] += phi_ij(i,j,p,q) - -phaseMag *= coeff - -#TODO Electrostatic Component - -'''PLOT''' -fig = plt.figure() -ax = fig.add_subplot(111, aspect='equal') -plt.pcolormesh(phaseMag, cmap='gray') - -ticks = ax.get_xticks()*res -ax.set_xticklabels(ticks.astype(int)) - -ticks = ax.get_yticks()*res -ax.set_yticklabels(ticks.astype(int)) - -ax.set_title('Real Space Approach') -ax.set_xlabel('x-axis [nm]') -ax.set_ylabel('y-axis [nm]') -plt.colorbar() -plt.show() \ No newline at end of file diff --git a/scripts/compare_methods.py b/scripts/compare_methods.py new file mode 100644 index 0000000..cd8a8cd --- /dev/null +++ b/scripts/compare_methods.py @@ -0,0 +1,172 @@ +# -*- coding: utf-8 -*- +""" +Created on Wed Apr 03 11:15:38 2013 + +@author: Jan +""" + +import numpy as np +import matplotlib.pyplot as plt +import pyramid.magcreator as mc +import pyramid.dataloader as dl +import pyramid.phasemap as pm +import pyramid.holoimage as hi +import pyramid.analytic as an +import time +import pdb, traceback, sys +from numpy import pi + + +def phase_from_mag(): + '''Calculate and display the phase map from a given magnetization. + Arguments: + None + Returns: + None + + ''' + + '''INPUT''' + # TODO: Input via GUI + filename = '../output/output.txt' + b_0 = 10.0 # in T + v_0 = 0 # TODO: units? + v_acc = 30000 # in V + padding = 20 + density = 100 + + dim = (50, 50) # in px (y,x) + res = 1.0 # in nm + beta = pi/4 + + plot_mag_distr = True + + # Slab: + shape_fun = mc.slab + center = (24, 24) # in px (y,x) index starts with 0! + width = (25, 25) # in px (y,x) + params = (center, width) +# # Disc: +# shape_fun = mc.disc +# center = (4, 4) # in px (y,x) +# radius = 2.5 +# params = (center, radius) +# # Filament: +# shape_fun = mc.filament +# pos = 5 +# x_or_y = 'y' +# params = (pos, x_or_y) +# # Alternating Filaments: +# shape_fun = mc.alternating_filaments +# spacing = 5 +# x_or_y = 'y' +# params = (spacing, x_or_y) +# # Single Pixel: +# shape_fun = mc.single_pixel +# pixel = (5, 5) +# params = pixel + +# '''CREATE LOGO''' +# mc.create_logo(128, res, beta, filename, plot_mag_distr) +# mag_data = dl.MagDataLLG(filename) +# phase= pm.real_space_slab(mag_data, b_0) +# holo = hi.holo_image(phase, mag_data.res, density) +# hi.display_holo(holo, '') + + '''CREATE MAGNETIC DISTRIBUTION''' + mc.create_hom_mag(dim, res, beta, shape_fun, params, + filename, plot_mag_distr) + + '''LOAD MAGNETIC DISTRIBUTION''' + mag_data = dl.MagDataLLG(filename) + + + # TODO: get it to work: + phase_el = pm.phase_elec(mag_data, v_0=1, v_acc=200000) + + + phi_cos_real_slab = np.zeros((2*dim[0]-1, 2*dim[1]-1)) + pm.real_space_slab(mag_data, b_0, pixel_map=phi_cos_real_slab) + pm.display_phase(phi_cos_real_slab, res, 'Phase of one Pixel-Slab (Cos - Part)') + phi_cos_real_disc = np.zeros((2*dim[0]-1, 2*dim[1]-1)) + pm.real_space_disc(mag_data, b_0, pixel_map=phi_cos_real_disc) + pm.display_phase(phi_cos_real_disc, res, 'Phase of one Pixel-Disc (Cos - Part)') + phi_cos_diff = phi_cos_real_slab - phi_cos_real_disc + pm.display_phase(phi_cos_diff, mag_data.res, 'Difference: One Pixel Slab - Disc') + + + '''NUMERICAL SOLUTION''' + # numerical solution Fourier Space: + tic = time.clock() + phase_fft = pm.fourier_space(mag_data, b_0, padding) + toc = time.clock() + print 'Time for Fourier Space Approach: ' + str(toc - tic) + holo_fft = hi.holo_image(phase_fft, mag_data.res, density) + display_combined(phase_fft, mag_data.res, holo_fft, + 'Fourier Space Approach') + # numerical solution Real Space (Slab): + jacobi = np.zeros((2*dim[0]*dim[1], dim[0]*dim[1])) + tic = time.clock() + phase_real_slab = pm.real_space_slab(mag_data, b_0, jacobi=None) + toc = time.clock() + np.savetxt('../output/jacobi.npy', jacobi) + print 'Time for Real Space Approach (Slab): ' + str(toc - tic) + holo_real_slab = hi.holo_image(phase_real_slab, mag_data.res, density) + display_combined(phase_real_slab, mag_data.res, holo_real_slab, + 'Real Space Approach (Slab)') + # numerical solution Real Space (Disc): + tic = time.clock() + phase_real_disc = pm.real_space_disc(mag_data, b_0) + toc = time.clock() + print 'Time for Real Space Approach (Disc): ' + str(toc - tic) + holo_real_disc = hi.holo_image(phase_real_disc, mag_data.res, density) + display_combined(phase_real_disc, mag_data.res, holo_real_disc, + 'Real Space Approach (Disc)') + + '''ANALYTIC SOLUTION''' + # analytic solution slab: + phase = an.phasemap_slab(dim, res, beta, center, width, b_0) + holo = hi.holo_image(phase, res, density) + display_combined(phase, res, holo, 'Analytic Solution - Slab') +# # analytic solution disc: +# phase = an.phasemap_disc(dim, res, beta, center, radius, b_0) +# holo = hi.holo_image(phase, res, density) +# display_combined(phase, res, holo, 'Analytic Solution - Disc') +# # analytic solution sphere: +# phase = an.phasemap_sphere(dim, res, beta, center, radius, b_0) +# holo = hi.holo_image(phase, res, density) +# display_combined(phase, res, holo, 'Analytic Solution - Sphere') + + + '''DIFFERENCES''' + diff_fft_to_ana = phase_fft - phase + diff_real_slab_to_ana = phase_real_slab - phase + diff_real_disc_to_ana = phase_real_disc - phase + diff_slab_to_disc = phase_real_disc - phase_real_slab + pm.display_phase(diff_fft_to_ana, res, 'Difference: FFT - Analytic') + pm.display_phase(diff_real_slab_to_ana, res, 'Difference: Slab - Analytic') + pm.display_phase(diff_real_disc_to_ana, res, 'Difference: Disc - Analytic') + pm.display_phase(diff_slab_to_disc, res, 'Difference: Disc - Slab') + + # TODO: Delete +# import pdb; pdb.set_trace() + + +def display_combined(phase, res, holo, title): + fig = plt.figure(figsize=(14, 7)) + fig.suptitle(title, fontsize=20) + + holo_axis = fig.add_subplot(1,2,1, aspect='equal') + hi.display_holo(holo, 'Holography Image', holo_axis) + + phase_axis = fig.add_subplot(1,2,2, aspect='equal') + pm.display_phase(phase, res, 'Phasemap', phase_axis) + + +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 diff --git a/scripts/create_logo.py b/scripts/create_logo.py new file mode 100644 index 0000000..0b3c0e9 --- /dev/null +++ b/scripts/create_logo.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +""" +Created on Wed Apr 03 11:15:38 2013 + +@author: Jan +""" + +import pyramid.magcreator as mc +import pyramid.dataloader as dl +import pyramid.phasemap as pm +import pyramid.holoimage as hi +import pdb, traceback, sys +from numpy import pi + + +def create_logo(): + '''Calculate and display the phase map from a given magnetization. + Arguments: + None + Returns: + None + + ''' + + filename = '../output/logo_magnetization.txt' + b_0 = 1.0 # in T + res = 10.0 # in nm + beta = pi/2 + density = 10 + + mc.create_logo(128, res, beta, filename) + mag_data = dl.MagDataLLG(filename) + phase= pm.real_space_slab(mag_data, b_0) + holo = hi.holo_image(phase, mag_data.res, density) + hi.display_holo(holo, '') + + +if __name__ == "__main__": + try: + create_logo() + except: + type, value, tb = sys.exc_info() + traceback.print_exc() + pdb.post_mortem(tb) \ No newline at end of file diff --git a/scripts/create_samples.py b/scripts/create_samples.py new file mode 100644 index 0000000..cd8a8cd --- /dev/null +++ b/scripts/create_samples.py @@ -0,0 +1,172 @@ +# -*- coding: utf-8 -*- +""" +Created on Wed Apr 03 11:15:38 2013 + +@author: Jan +""" + +import numpy as np +import matplotlib.pyplot as plt +import pyramid.magcreator as mc +import pyramid.dataloader as dl +import pyramid.phasemap as pm +import pyramid.holoimage as hi +import pyramid.analytic as an +import time +import pdb, traceback, sys +from numpy import pi + + +def phase_from_mag(): + '''Calculate and display the phase map from a given magnetization. + Arguments: + None + Returns: + None + + ''' + + '''INPUT''' + # TODO: Input via GUI + filename = '../output/output.txt' + b_0 = 10.0 # in T + v_0 = 0 # TODO: units? + v_acc = 30000 # in V + padding = 20 + density = 100 + + dim = (50, 50) # in px (y,x) + res = 1.0 # in nm + beta = pi/4 + + plot_mag_distr = True + + # Slab: + shape_fun = mc.slab + center = (24, 24) # in px (y,x) index starts with 0! + width = (25, 25) # in px (y,x) + params = (center, width) +# # Disc: +# shape_fun = mc.disc +# center = (4, 4) # in px (y,x) +# radius = 2.5 +# params = (center, radius) +# # Filament: +# shape_fun = mc.filament +# pos = 5 +# x_or_y = 'y' +# params = (pos, x_or_y) +# # Alternating Filaments: +# shape_fun = mc.alternating_filaments +# spacing = 5 +# x_or_y = 'y' +# params = (spacing, x_or_y) +# # Single Pixel: +# shape_fun = mc.single_pixel +# pixel = (5, 5) +# params = pixel + +# '''CREATE LOGO''' +# mc.create_logo(128, res, beta, filename, plot_mag_distr) +# mag_data = dl.MagDataLLG(filename) +# phase= pm.real_space_slab(mag_data, b_0) +# holo = hi.holo_image(phase, mag_data.res, density) +# hi.display_holo(holo, '') + + '''CREATE MAGNETIC DISTRIBUTION''' + mc.create_hom_mag(dim, res, beta, shape_fun, params, + filename, plot_mag_distr) + + '''LOAD MAGNETIC DISTRIBUTION''' + mag_data = dl.MagDataLLG(filename) + + + # TODO: get it to work: + phase_el = pm.phase_elec(mag_data, v_0=1, v_acc=200000) + + + phi_cos_real_slab = np.zeros((2*dim[0]-1, 2*dim[1]-1)) + pm.real_space_slab(mag_data, b_0, pixel_map=phi_cos_real_slab) + pm.display_phase(phi_cos_real_slab, res, 'Phase of one Pixel-Slab (Cos - Part)') + phi_cos_real_disc = np.zeros((2*dim[0]-1, 2*dim[1]-1)) + pm.real_space_disc(mag_data, b_0, pixel_map=phi_cos_real_disc) + pm.display_phase(phi_cos_real_disc, res, 'Phase of one Pixel-Disc (Cos - Part)') + phi_cos_diff = phi_cos_real_slab - phi_cos_real_disc + pm.display_phase(phi_cos_diff, mag_data.res, 'Difference: One Pixel Slab - Disc') + + + '''NUMERICAL SOLUTION''' + # numerical solution Fourier Space: + tic = time.clock() + phase_fft = pm.fourier_space(mag_data, b_0, padding) + toc = time.clock() + print 'Time for Fourier Space Approach: ' + str(toc - tic) + holo_fft = hi.holo_image(phase_fft, mag_data.res, density) + display_combined(phase_fft, mag_data.res, holo_fft, + 'Fourier Space Approach') + # numerical solution Real Space (Slab): + jacobi = np.zeros((2*dim[0]*dim[1], dim[0]*dim[1])) + tic = time.clock() + phase_real_slab = pm.real_space_slab(mag_data, b_0, jacobi=None) + toc = time.clock() + np.savetxt('../output/jacobi.npy', jacobi) + print 'Time for Real Space Approach (Slab): ' + str(toc - tic) + holo_real_slab = hi.holo_image(phase_real_slab, mag_data.res, density) + display_combined(phase_real_slab, mag_data.res, holo_real_slab, + 'Real Space Approach (Slab)') + # numerical solution Real Space (Disc): + tic = time.clock() + phase_real_disc = pm.real_space_disc(mag_data, b_0) + toc = time.clock() + print 'Time for Real Space Approach (Disc): ' + str(toc - tic) + holo_real_disc = hi.holo_image(phase_real_disc, mag_data.res, density) + display_combined(phase_real_disc, mag_data.res, holo_real_disc, + 'Real Space Approach (Disc)') + + '''ANALYTIC SOLUTION''' + # analytic solution slab: + phase = an.phasemap_slab(dim, res, beta, center, width, b_0) + holo = hi.holo_image(phase, res, density) + display_combined(phase, res, holo, 'Analytic Solution - Slab') +# # analytic solution disc: +# phase = an.phasemap_disc(dim, res, beta, center, radius, b_0) +# holo = hi.holo_image(phase, res, density) +# display_combined(phase, res, holo, 'Analytic Solution - Disc') +# # analytic solution sphere: +# phase = an.phasemap_sphere(dim, res, beta, center, radius, b_0) +# holo = hi.holo_image(phase, res, density) +# display_combined(phase, res, holo, 'Analytic Solution - Sphere') + + + '''DIFFERENCES''' + diff_fft_to_ana = phase_fft - phase + diff_real_slab_to_ana = phase_real_slab - phase + diff_real_disc_to_ana = phase_real_disc - phase + diff_slab_to_disc = phase_real_disc - phase_real_slab + pm.display_phase(diff_fft_to_ana, res, 'Difference: FFT - Analytic') + pm.display_phase(diff_real_slab_to_ana, res, 'Difference: Slab - Analytic') + pm.display_phase(diff_real_disc_to_ana, res, 'Difference: Disc - Analytic') + pm.display_phase(diff_slab_to_disc, res, 'Difference: Disc - Slab') + + # TODO: Delete +# import pdb; pdb.set_trace() + + +def display_combined(phase, res, holo, title): + fig = plt.figure(figsize=(14, 7)) + fig.suptitle(title, fontsize=20) + + holo_axis = fig.add_subplot(1,2,1, aspect='equal') + hi.display_holo(holo, 'Holography Image', holo_axis) + + phase_axis = fig.add_subplot(1,2,2, aspect='equal') + pm.display_phase(phase, res, 'Phasemap', phase_axis) + + +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 diff --git a/scripts/get_jacobi.py b/scripts/get_jacobi.py new file mode 100644 index 0000000..d6b04c7 --- /dev/null +++ b/scripts/get_jacobi.py @@ -0,0 +1,172 @@ +# -*- coding: utf-8 -*- +""" +Created on Wed Apr 03 11:15:38 2013 + +@author: Jan +""" + +import numpy as np +import matplotlib.pyplot as plt +import pyramid.magcreator as mc +import pyramid.dataloader as dl +import pyramid.phasemap as pm +import pyramid.holoimage as hi +import pyramid.analytic as an +import time +import pdb, traceback, sys +from numpy import pi + + +def phase_from_mag(): + '''Calculate and display the phase map from a given magnetization. + Arguments: + None + Returns: + None + + ''' + + '''INPUT''' + # TODO: Input via GUI + filename = '../output/output.txt' + b_0 = 1.0 # in T + v_0 = 0 # TODO: units? + v_acc = 30000 # in V + padding = 20 + density = 100 + + dim = (50, 50) # in px (y,x) + res = 1.0 # in nm + beta = pi/4 + + plot_mag_distr = True + + # Slab: + shape_fun = mc.slab + center = (24, 24) # in px (y,x) index starts with 0! + width = (25, 25) # in px (y,x) + params = (center, width) +# # Disc: +# shape_fun = mc.disc +# center = (4, 4) # in px (y,x) +# radius = 2.5 +# params = (center, radius) +# # Filament: +# shape_fun = mc.filament +# pos = 5 +# x_or_y = 'y' +# params = (pos, x_or_y) +# # Alternating Filaments: +# shape_fun = mc.alternating_filaments +# spacing = 5 +# x_or_y = 'y' +# params = (spacing, x_or_y) +# # Single Pixel: +# shape_fun = mc.single_pixel +# pixel = (5, 5) +# params = pixel + +# '''CREATE LOGO''' +# mc.create_logo(128, res, beta, filename, plot_mag_distr) +# mag_data = dl.MagDataLLG(filename) +# phase= pm.real_space_slab(mag_data, b_0) +# holo = hi.holo_image(phase, mag_data.res, density) +# hi.display_holo(holo, '') + + '''CREATE MAGNETIC DISTRIBUTION''' + mc.create_hom_mag(dim, res, beta, shape_fun, params, + filename, plot_mag_distr) + + '''LOAD MAGNETIC DISTRIBUTION''' + mag_data = dl.MagDataLLG(filename) + + + # TODO: get it to work: + phase_el = pm.phase_elec(mag_data, v_0=1, v_acc=200000) + + + phi_cos_real_slab = np.zeros((2*dim[0]-1, 2*dim[1]-1)) + pm.real_space_slab(mag_data, b_0, pixel_map=phi_cos_real_slab) + pm.display_phase(phi_cos_real_slab, res, 'Phase of one Pixel-Slab (Cos - Part)') + phi_cos_real_disc = np.zeros((2*dim[0]-1, 2*dim[1]-1)) + pm.real_space_disc(mag_data, b_0, pixel_map=phi_cos_real_disc) + pm.display_phase(phi_cos_real_disc, res, 'Phase of one Pixel-Disc (Cos - Part)') + phi_cos_diff = phi_cos_real_slab - phi_cos_real_disc + pm.display_phase(phi_cos_diff, mag_data.res, 'Difference: One Pixel Slab - Disc') + + + '''NUMERICAL SOLUTION''' + # numerical solution Fourier Space: + tic = time.clock() + phase_fft = pm.fourier_space(mag_data, b_0, padding) + toc = time.clock() + print 'Time for Fourier Space Approach: ' + str(toc - tic) + holo_fft = hi.holo_image(phase_fft, mag_data.res, density) + display_combined(phase_fft, mag_data.res, holo_fft, + 'Fourier Space Approach') + # numerical solution Real Space (Slab): + jacobi = np.zeros((2*dim[0]*dim[1], dim[0]*dim[1])) + tic = time.clock() + phase_real_slab = pm.real_space_slab(mag_data, b_0, jacobi=None) + toc = time.clock() + np.savetxt('../output/jacobi.npy', jacobi) + print 'Time for Real Space Approach (Slab): ' + str(toc - tic) + holo_real_slab = hi.holo_image(phase_real_slab, mag_data.res, density) + display_combined(phase_real_slab, mag_data.res, holo_real_slab, + 'Real Space Approach (Slab)') + # numerical solution Real Space (Disc): + tic = time.clock() + phase_real_disc = pm.real_space_disc(mag_data, b_0) + toc = time.clock() + print 'Time for Real Space Approach (Disc): ' + str(toc - tic) + holo_real_disc = hi.holo_image(phase_real_disc, mag_data.res, density) + display_combined(phase_real_disc, mag_data.res, holo_real_disc, + 'Real Space Approach (Disc)') + + '''ANALYTIC SOLUTION''' + # analytic solution slab: + phase = an.phasemap_slab(dim, res, beta, center, width, b_0) + holo = hi.holo_image(phase, res, density) + display_combined(phase, res, holo, 'Analytic Solution - Slab') +# # analytic solution disc: +# phase = an.phasemap_disc(dim, res, beta, center, radius, b_0) +# holo = hi.holo_image(phase, res, density) +# display_combined(phase, res, holo, 'Analytic Solution - Disc') +# # analytic solution sphere: +# phase = an.phasemap_sphere(dim, res, beta, center, radius, b_0) +# holo = hi.holo_image(phase, res, density) +# display_combined(phase, res, holo, 'Analytic Solution - Sphere') + + + '''DIFFERENCES''' + diff_fft_to_ana = phase_fft - phase + diff_real_slab_to_ana = phase_real_slab - phase + diff_real_disc_to_ana = phase_real_disc - phase + diff_slab_to_disc = phase_real_disc - phase_real_slab + pm.display_phase(diff_fft_to_ana, res, 'Difference: FFT - Analytic') + pm.display_phase(diff_real_slab_to_ana, res, 'Difference: Slab - Analytic') + pm.display_phase(diff_real_disc_to_ana, res, 'Difference: Disc - Analytic') + pm.display_phase(diff_slab_to_disc, res, 'Difference: Disc - Slab') + + # TODO: Delete +# import pdb; pdb.set_trace() + + +def display_combined(phase, res, holo, title): + fig = plt.figure(figsize=(14, 7)) + fig.suptitle(title, fontsize=20) + + holo_axis = fig.add_subplot(1,2,1, aspect='equal') + hi.display_holo(holo, 'Holography Image', holo_axis) + + phase_axis = fig.add_subplot(1,2,2, aspect='equal') + pm.display_phase(phase, res, 'Phasemap', phase_axis) + + +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 diff --git a/scripts/main.py b/scripts/main.py index 104e85d..6ccadb5 100644 --- a/scripts/main.py +++ b/scripts/main.py @@ -28,15 +28,15 @@ def phase_from_mag(): '''INPUT''' # TODO: Input via GUI - filename = 'output.txt' - b_0 = 10.0 # in T + filename = '../output/output.txt' + b_0 = 1.0 # in T v_0 = 0 # TODO: units? v_acc = 30000 # in V padding = 20 - density = 100 + density = 10 dim = (50, 50) # in px (y,x) - res = 1.0 # in nm + res = 10.0 # in nm beta = pi/4 plot_mag_distr = True @@ -105,11 +105,11 @@ def phase_from_mag(): display_combined(phase_fft, mag_data.res, holo_fft, 'Fourier Space Approach') # numerical solution Real Space (Slab): -# jacobi = np.zeros((2*dim[0]*dim[1], dim[0]*dim[1])) + jacobi = np.zeros((2*dim[0]*dim[1], dim[0]*dim[1])) tic = time.clock() phase_real_slab = pm.real_space_slab(mag_data, b_0, jacobi=None) toc = time.clock() -# np.savetxt('jacobi.npy', jacobi) + np.savetxt('../output/jacobi.npy', jacobi) print 'Time for Real Space Approach (Slab): ' + str(toc - tic) holo_real_slab = hi.holo_image(phase_real_slab, mag_data.res, density) display_combined(phase_real_slab, mag_data.res, holo_real_slab, diff --git a/pyramid/__init__.py b/src/pyramid/__init__.py similarity index 100% rename from pyramid/__init__.py rename to src/pyramid/__init__.py diff --git a/pyramid/analytic.py b/src/pyramid/analytic.py similarity index 100% rename from pyramid/analytic.py rename to src/pyramid/analytic.py diff --git a/pyramid/dataloader.py b/src/pyramid/dataloader.py similarity index 100% rename from pyramid/dataloader.py rename to src/pyramid/dataloader.py diff --git a/pyramid/holoimage.py b/src/pyramid/holoimage.py similarity index 100% rename from pyramid/holoimage.py rename to src/pyramid/holoimage.py diff --git a/pyramid/magcreator.py b/src/pyramid/magcreator.py similarity index 97% rename from pyramid/magcreator.py rename to src/pyramid/magcreator.py index b4f84c9..ac00677 100644 --- a/pyramid/magcreator.py +++ b/src/pyramid/magcreator.py @@ -168,7 +168,7 @@ def create_logo(edge, res, beta = pi/2, filename='logo.txt', plot_mag_distr=Fals y_mag = np.array(np.ones(dim)) * np.sin(beta) * shape_mag z_mag = np.array(np.zeros(dim)) - if (True): + if (plot_mag_distr): fig = plt.figure() fig.add_subplot(111, aspect='equal') plt.quiver(x_mag, y_mag, pivot='middle', angles='xy', scale_units='xy', diff --git a/pyramid/phasemap.py b/src/pyramid/phasemap.py similarity index 96% rename from pyramid/phasemap.py rename to src/pyramid/phasemap.py index 9464545..96cdccb 100644 --- a/pyramid/phasemap.py +++ b/src/pyramid/phasemap.py @@ -71,6 +71,8 @@ def real_space_slab(mag_data, b_0=1, v_0=0, v_acc=30000, the phasemap as a 2 dimensional array ''' + # TODO: combine with disc and sphere approach, pixel field as function + # TODO: Expand docstring! # TODO: Delete diff --git a/test/test_analytic.py b/test/test_analytic.py new file mode 100644 index 0000000..b26bfd4 --- /dev/null +++ b/test/test_analytic.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +""" +Created on Wed Apr 24 07:10:28 2013 + +@author: Jan +""" +# py.test + +import unittest + + +class TestSuite(unittest.TestCase): + + def setUp(self): + pass + + def tearDown(self): + pass + + def test(self): + self.assertTrue(True) + + def test_almost(self): + self.assertAlmostEqual(0, 0.01, places=1) + + +if __name__ == '__main__': + suite = unittest.TestLoader().loadTestsFromTestCase(TestSuite) + unittest.TextTestRunner(verbosity=2).run(suite) \ No newline at end of file diff --git a/test/test_dataloader.py b/test/test_dataloader.py new file mode 100644 index 0000000..b26bfd4 --- /dev/null +++ b/test/test_dataloader.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +""" +Created on Wed Apr 24 07:10:28 2013 + +@author: Jan +""" +# py.test + +import unittest + + +class TestSuite(unittest.TestCase): + + def setUp(self): + pass + + def tearDown(self): + pass + + def test(self): + self.assertTrue(True) + + def test_almost(self): + self.assertAlmostEqual(0, 0.01, places=1) + + +if __name__ == '__main__': + suite = unittest.TestLoader().loadTestsFromTestCase(TestSuite) + unittest.TextTestRunner(verbosity=2).run(suite) \ No newline at end of file diff --git a/test/test_holoimage.py b/test/test_holoimage.py new file mode 100644 index 0000000..b26bfd4 --- /dev/null +++ b/test/test_holoimage.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +""" +Created on Wed Apr 24 07:10:28 2013 + +@author: Jan +""" +# py.test + +import unittest + + +class TestSuite(unittest.TestCase): + + def setUp(self): + pass + + def tearDown(self): + pass + + def test(self): + self.assertTrue(True) + + def test_almost(self): + self.assertAlmostEqual(0, 0.01, places=1) + + +if __name__ == '__main__': + suite = unittest.TestLoader().loadTestsFromTestCase(TestSuite) + unittest.TextTestRunner(verbosity=2).run(suite) \ No newline at end of file diff --git a/test/test_magcreator.py b/test/test_magcreator.py new file mode 100644 index 0000000..b26bfd4 --- /dev/null +++ b/test/test_magcreator.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +""" +Created on Wed Apr 24 07:10:28 2013 + +@author: Jan +""" +# py.test + +import unittest + + +class TestSuite(unittest.TestCase): + + def setUp(self): + pass + + def tearDown(self): + pass + + def test(self): + self.assertTrue(True) + + def test_almost(self): + self.assertAlmostEqual(0, 0.01, places=1) + + +if __name__ == '__main__': + suite = unittest.TestLoader().loadTestsFromTestCase(TestSuite) + unittest.TextTestRunner(verbosity=2).run(suite) \ No newline at end of file diff --git a/test/test_phasemap.py b/test/test_phasemap.py new file mode 100644 index 0000000..1c2af41 --- /dev/null +++ b/test/test_phasemap.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +""" +Created on Wed Apr 24 07:10:28 2013 + +@author: Jan +""" +# py.test + +import unittest +import numpy as np + + +class TestSuite(unittest.TestCase): + + def setUp(self): + pass + + def tearDown(self): + pass + + def test(self): + self.assertTrue(True) + + def test_almost(self): + self.assertAlmostEqual(0, 0.01, places=1) + np.testing.assert_array_almost_equal() + + +if __name__ == '__main__': + suite = unittest.TestLoader().loadTestsFromTestCase(TestSuite) + unittest.TextTestRunner(verbosity=2).run(suite) \ No newline at end of file -- GitLab