Skip to content

Commit 5b0b1de

Browse files
committed
Adding the notebooks
1 parent 660b9c6 commit 5b0b1de

File tree

6 files changed

+18965
-0
lines changed

6 files changed

+18965
-0
lines changed

colorMapNotebook.ipynb

Lines changed: 268 additions & 0 deletions
Large diffs are not rendered by default.

gen_fractal.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import matplotlib.pyplot as plt
2+
import scipy.fft as sfft
3+
import numpy as np
4+
import numpy.random as rnd
5+
rnd.seed()
6+
7+
def gen_fractal(N, D):
8+
D = 2.3
9+
beta = 2*(4. - D)
10+
ndim= int(N)
11+
N2 = int(ndim/2)
12+
13+
data = np.zeros((ndim, ndim, ndim), dtype=complex)
14+
fndim = float(ndim)
15+
16+
ix = 0
17+
while ix < N2:
18+
iy = 0
19+
while iy < ndim:
20+
iz = 0
21+
while iz < ndim:
22+
phi = rnd.uniform(0, 2.0*np.pi)
23+
fix = min(float(ix), float(ndim-ix))
24+
fiy = min(float(iy), float(ndim-iy))
25+
fiz = min(float(iz), float(ndim-iz))
26+
freq = np.sqrt(fix*fix + fiy*fiy + fiz*fiz)
27+
amp = np.sqrt(float(1.0/(freq/ndim)**beta))
28+
29+
data[ix,iy,iz] = complex(amp*np.cos(phi), amp*np.sin(phi))
30+
iz += 1
31+
iy += 1
32+
ix += 1
33+
ix = 0
34+
while ix < N2:
35+
iy = 0
36+
while iy < ndim:
37+
iz = 0
38+
while iz < ndim:
39+
data[(ndim-ix)%ndim,(ndim-iy)%ndim,(ndim-iz)%ndim] = np.conj(data[ix,iy,iz])
40+
iz += 1
41+
iy += 1
42+
ix += 1
43+
data[0,0,0]=complex(0.0,0.0)
44+
data[0,0,N2]=complex(abs(data[0,0,N2]),0.0)
45+
data[0,N2,0]=complex(abs(data[0,N2,0]),0.0)
46+
data[N2,0,0]=complex(abs(data[N2,0,0]),0.0)
47+
data[0,N2,N2]=complex(abs(data[0,N2,N2]),0.0)
48+
data[N2,0,N2]=complex(abs(data[N2,0,N2]),0.0)
49+
data[N2,N2,0]=complex(abs(data[N2,N2,0]),0.0)
50+
data[N2,N2,N2]=complex(abs(data[N2,N2,N2]),0.0)
51+
52+
ffdata= sfft.fftn(data)
53+
ffdata= sfft.fftshift(ffdata)
54+
55+
var=np.var(ffdata)
56+
ffdata=ffdata/np.sqrt(var)
57+
58+
fbmcube=np.sqrt(ffdata**2).astype('float64')
59+
60+
h = np.std(fbmcube.flatten())
61+
dens= np.exp(fbmcube/h)
62+
63+
(xind, yind, zind) = np.unravel_index(dens.argmax(), dens.shape)
64+
xroll = int(xind - N2)
65+
yroll = int(yind - N2)
66+
zroll = int(zind - N2)
67+
dens = np.roll(dens, -xroll, axis=0)
68+
dens = np.roll(dens, -yroll, axis=1)
69+
dens = np.roll(dens, -zroll, axis=2)
70+
71+
return dens

0 commit comments

Comments
 (0)