merge
This commit is contained in:
commit
784aab8312
@ -1,24 +0,0 @@
|
||||
-1.317409 0.112925 -0.113205
|
||||
-1.317410 4.629925 -0.113205
|
||||
9.907514 -0.112924 4.641385
|
||||
9.907513 4.404076 4.641385
|
||||
1.317409 -0.112925 0.113205
|
||||
-1.578486 -0.112924 4.641385
|
||||
4.425591 0.112925 -0.113205
|
||||
4.425590 4.629925 -0.113205
|
||||
7.060409 -0.112925 0.113205
|
||||
4.164514 -0.112924 4.641385
|
||||
10.168591 0.112925 -0.113205
|
||||
10.168590 4.629925 -0.113205
|
||||
1.317408 4.404075 0.113205
|
||||
2.977644 2.145576 2.150886
|
||||
1.529697 0.112926 4.414976
|
||||
-0.130539 2.371426 2.377295
|
||||
-1.578487 4.404076 4.641385
|
||||
1.529696 4.629926 4.414976
|
||||
7.060408 4.404075 0.113205
|
||||
8.720644 2.145576 2.150886
|
||||
7.272697 0.112926 4.414976
|
||||
5.612461 2.371426 2.377295
|
||||
4.164513 4.404076 4.641385
|
||||
7.272696 4.629926 4.414976
|
@ -1,42 +0,0 @@
|
||||
V -1.317409 0.112925 -0.113205
|
||||
O -1.443069 3.207070 1.358454
|
||||
O -2.891016 3.568431 3.622545
|
||||
V -1.317410 4.629925 -0.113205
|
||||
V 9.907514 -0.112924 4.641385
|
||||
O 11.481121 0.948570 0.905636
|
||||
O 10.033174 1.309931 3.169726
|
||||
V 9.907513 4.404076 4.641385
|
||||
V 1.317409 -0.112925 0.113205
|
||||
V -1.578486 -0.112924 4.641385
|
||||
V 4.425591 0.112925 -0.113205
|
||||
V 4.425590 4.629925 -0.113205
|
||||
V 7.060409 -0.112925 0.113205
|
||||
V 4.164514 -0.112924 4.641385
|
||||
V 10.168591 0.112925 -0.113205
|
||||
V 10.168590 4.629925 -0.113205
|
||||
O -0.004879 0.948570 0.905636
|
||||
O 4.299931 3.207070 1.358454
|
||||
O 2.851984 3.568431 3.622545
|
||||
O 1.399960 3.116730 1.313172
|
||||
O 2.895092 0.858230 0.950918
|
||||
O 1.447145 1.400271 3.215008
|
||||
O -0.047988 3.658771 3.577263
|
||||
V 1.317408 4.404075 0.113205
|
||||
V 2.977644 2.145576 2.150886
|
||||
V 1.529697 0.112926 4.414976
|
||||
V -0.130539 2.371426 2.377295
|
||||
V -1.578487 4.404076 4.641385
|
||||
V 1.529696 4.629926 4.414976
|
||||
O 5.738121 0.948570 0.905636
|
||||
O 8.594984 3.568431 3.622545
|
||||
O 4.290174 1.309931 3.169726
|
||||
O 7.142960 3.116730 1.313172
|
||||
O 8.638092 0.858230 0.950918
|
||||
O 7.190145 1.400271 3.215008
|
||||
O 5.695012 3.658771 3.577263
|
||||
V 7.060408 4.404075 0.113205
|
||||
V 8.720644 2.145576 2.150886
|
||||
V 7.272697 0.112926 4.414976
|
||||
V 5.612461 2.371426 2.377295
|
||||
V 4.164513 4.404076 4.641385
|
||||
V 7.272696 4.629926 4.414976
|
202
fft_1d.py
202
fft_1d.py
@ -1,202 +0,0 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import tqdm
|
||||
|
||||
import multiprocessing as mp
|
||||
|
||||
RESOLUTION = 0.01
|
||||
LENGTH = 500
|
||||
|
||||
|
||||
def generate_image_from_mask(mask: np.array):
|
||||
pos_mono = np.arange(0, mask.size * 2.89 * 2, 2.89)
|
||||
pos_mono[::2][mask] -= 0.27
|
||||
pos_mono[1::2][mask] += 0.27
|
||||
return pos_mono
|
||||
|
||||
|
||||
def pad_zero(img, length):
|
||||
pad = np.zeros(length)
|
||||
img = np.append(img, pad)
|
||||
img = np.append(pad, img)
|
||||
return img
|
||||
|
||||
|
||||
def image_from_pos(pos):
|
||||
length = np.max(pos) + RESOLUTION
|
||||
x = np.arange(0, length, RESOLUTION) # angstrom
|
||||
y = np.zeros_like(x)
|
||||
ind = np.searchsorted(x, pos)
|
||||
y[ind] = 1
|
||||
return y
|
||||
|
||||
|
||||
def beugung(y, resolution):
|
||||
fft = np.fft.fft(y)
|
||||
fft_clean = np.fft.fftshift(fft)
|
||||
fft_freq = np.fft.fftfreq(y.size, resolution)
|
||||
fft_freq_clean = np.fft.fftshift(fft_freq)
|
||||
return fft_freq_clean, np.abs(fft_clean) ** 2
|
||||
|
||||
|
||||
def gaussian_convol(img):
|
||||
sigma = 100 / RESOLUTION
|
||||
mu = img.size/2
|
||||
x = np.arange(0, img.size)
|
||||
gauss = 1/(sigma * np.sqrt(2 * np.pi)) * \
|
||||
np.exp(- (x - mu)**2 / (2 * sigma**2))
|
||||
|
||||
return img*gauss
|
||||
|
||||
|
||||
def analyisis(mask):
|
||||
pos_h = generate_image_from_mask(mask)
|
||||
img = image_from_pos(pos_h)
|
||||
img = gaussian_convol(img)
|
||||
padded = pad_zero(img, int(100 / RESOLUTION))
|
||||
freq, intens = beugung(padded, RESOLUTION)
|
||||
return freq, intens
|
||||
|
||||
|
||||
def get_peaks():
|
||||
orders = np.arange(1, 2, 1)
|
||||
orders = orders / 5.78
|
||||
return np.array(orders)
|
||||
|
||||
|
||||
def eval_peaks(freq, fft):
|
||||
orders = get_peaks()
|
||||
ind = np.searchsorted(freq, orders)
|
||||
return fft[ind]
|
||||
|
||||
|
||||
def basic_test():
|
||||
mask_h = np.zeros(LENGTH).astype(bool)
|
||||
mask_l = np.ones(LENGTH).astype(bool)
|
||||
|
||||
mask_mixed = np.zeros(LENGTH).astype(bool)
|
||||
ind = (np.random.rand(30) * (LENGTH - 1)).astype(int)
|
||||
mask_mixed[ind] = True
|
||||
|
||||
mask_ner = np.zeros(LENGTH).astype(bool)
|
||||
ind = (np.random.rand(1) * (LENGTH - 31)).astype(int)
|
||||
ind = np.arange(ind, ind+30).astype(int)
|
||||
mask_ner[ind] = True
|
||||
|
||||
fig, axs = plt.subplots(4, 1)
|
||||
for mask, ax in zip([mask_h, mask_l, mask_mixed, mask_ner], axs):
|
||||
freq, ffty = analyisis(mask)
|
||||
ax.plot(freq, ffty)
|
||||
for ax in axs:
|
||||
ax.plot([1.0 / 5.78, 1.0 / 2.62, 1.0 / 3.16], [0, 0, 0], "kx")
|
||||
ax.plot([2.0 / 5.78, 2.0 / 2.62, 2.0 / 3.16], [0, 0, 0], "rx")
|
||||
ax.plot([3.0 / 5.78, 3.0 / 2.62, 3.0 / 3.16], [0, 0, 0], "bx")
|
||||
ax.set_xlim(0, 3)
|
||||
plt.show()
|
||||
|
||||
|
||||
def norm(arr):
|
||||
return arr/np.sum(arr)
|
||||
|
||||
|
||||
def norm2(arr):
|
||||
return arr
|
||||
# return arr/np.max(arr)
|
||||
|
||||
|
||||
def next_mask(mask):
|
||||
prob = np.exp((np.roll(mask, 1)*1.0 + np.roll(mask, -1)) / .1)
|
||||
prob[mask] = 0.0
|
||||
prob = norm(prob)
|
||||
|
||||
ind = np.random.choice(LENGTH, p=prob)
|
||||
mask[ind] = True
|
||||
return mask
|
||||
|
||||
|
||||
def random_loop():
|
||||
mask = np.zeros(LENGTH).astype(bool)
|
||||
ind = np.arange(0, LENGTH)
|
||||
np.random.shuffle(ind)
|
||||
percentage = []
|
||||
peaks = []
|
||||
|
||||
masks = []
|
||||
for i in ind:
|
||||
mask[i] = True
|
||||
freq, fft = analyisis(mask)
|
||||
peak = eval_peaks(freq, fft)
|
||||
percentage.append(np.mean(mask))
|
||||
peaks.append(peak)
|
||||
masks.append(mask.copy())
|
||||
masks = np.array(masks)
|
||||
plt.figure()
|
||||
plt.imshow(masks)
|
||||
plt.plot([0, 500], [406, 406])
|
||||
print()
|
||||
percentage = np.array(percentage)
|
||||
peaks = np.array(peaks)
|
||||
return percentage, peaks
|
||||
|
||||
|
||||
def nearest_loop():
|
||||
mask = np.zeros(LENGTH).astype(bool)
|
||||
percentage = []
|
||||
peaks = []
|
||||
for i in range(LENGTH):
|
||||
mask = next_mask(mask)
|
||||
freq, fft = analyisis(mask)
|
||||
peak = eval_peaks(freq, fft)
|
||||
percentage.append(np.mean(mask))
|
||||
peaks.append(peak)
|
||||
percentage = np.array(percentage)
|
||||
peaks = np.array(peaks)
|
||||
return percentage, peaks
|
||||
|
||||
|
||||
def random_helper(seed):
|
||||
np.random.seed(seed)
|
||||
#percentage_near, peaks_near = nearest_loop()
|
||||
percentage_rand, peaks_rand = random_loop()
|
||||
print("done")
|
||||
return percentage_rand, peaks_rand
|
||||
# for i in range(peaks_near.shape[1]):
|
||||
# axs[2].plot(percentage_near, norm2(
|
||||
# peaks_near[:, i]), "-", label="near")
|
||||
|
||||
# for i in range(peaks_rand.shape[1]):
|
||||
# axs[2].plot(percentage_rand, norm2(
|
||||
# peaks_rand[:, i]), ":", label="rand")
|
||||
|
||||
|
||||
def random_increase():
|
||||
fig, axs = plt.subplots(3, 1)
|
||||
|
||||
results = []
|
||||
for i in np.arange(10):
|
||||
results.append(random_helper(i))
|
||||
|
||||
for percentage_rand, peaks_rand in results:
|
||||
for i in range(peaks_rand.shape[1]):
|
||||
axs[2].plot(percentage_rand, norm2(
|
||||
peaks_rand[:, i]), ":", label="rand")
|
||||
|
||||
for ax in [axs[0], axs[1]]:
|
||||
orders = get_peaks()
|
||||
ax.plot(orders, np.zeros_like(orders), "kx")
|
||||
ax.set_xlim(0, 3)
|
||||
|
||||
mask_l = np.ones(LENGTH).astype(bool)
|
||||
mask_h = np.zeros(LENGTH).astype(bool)
|
||||
freq, ffty = analyisis(mask_l)
|
||||
axs[0].plot(freq, ffty)
|
||||
freq, ffty = analyisis(mask_h)
|
||||
axs[1].plot(freq, ffty)
|
||||
plt.xlabel("percentage")
|
||||
plt.ylabel("peak intensity")
|
||||
plt.show()
|
||||
plt.legend()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
random_increase()
|
1293
imgs/erklaerbaer.svg
Normal file
1293
imgs/erklaerbaer.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 1023 KiB |
1592
imgs/erklaerbaer_overlay.svg
Normal file
1592
imgs/erklaerbaer_overlay.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 508 KiB |
189
imgs/ref_imgs.svg
Normal file
189
imgs/ref_imgs.svg
Normal file
@ -0,0 +1,189 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
sodipodi:docname="drawing.svg"
|
||||
id="svg5"
|
||||
version="1.1"
|
||||
viewBox="0 0 793.70081 1122.5197"
|
||||
height="297mm"
|
||||
width="210mm"
|
||||
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<sodipodi:namedview
|
||||
id="namedview7"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:document-units="mm"
|
||||
showgrid="false"
|
||||
inkscape:zoom="1.5009171"
|
||||
inkscape:cx="181.55566"
|
||||
inkscape:cy="270.83441"
|
||||
inkscape:window-width="1465"
|
||||
inkscape:window-height="991"
|
||||
inkscape:window-x="26"
|
||||
inkscape:window-y="23"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="layer1" />
|
||||
<defs
|
||||
id="defs2">
|
||||
<linearGradient
|
||||
id="linearGradient4172">
|
||||
<stop
|
||||
style="stop-color:#fbff8a;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop13310" />
|
||||
<stop
|
||||
style="stop-color:#ca9434;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop13312" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient4122">
|
||||
<stop
|
||||
style="stop-color:#8addff;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop4118" />
|
||||
<stop
|
||||
style="stop-color:#3434ca;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop4120" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient818">
|
||||
<stop
|
||||
style="stop-color:#8affd6;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop816" />
|
||||
<stop
|
||||
style="stop-color:#35ca34;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop814" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient818"
|
||||
id="radialGradient820"
|
||||
cx="195.77567"
|
||||
cy="355.37839"
|
||||
fx="195.77567"
|
||||
fy="355.37839"
|
||||
r="70.242348"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(0.26903483,0,0,0.26903483,83.255766,-124.82936)" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4122"
|
||||
id="radialGradient820-3"
|
||||
cx="195.77567"
|
||||
cy="355.37839"
|
||||
fx="195.77567"
|
||||
fy="355.37839"
|
||||
r="70.242348"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(0.26903483,0,0,0.26903483,106.60864,-189.32003)" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4172"
|
||||
id="radialGradient820-3-3"
|
||||
cx="195.77567"
|
||||
cy="355.37839"
|
||||
fx="195.77567"
|
||||
fy="355.37839"
|
||||
r="70.242348"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(0.26903483,0,0,0.26903483,129.96117,-253.81044)" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4172"
|
||||
id="radialGradient2487"
|
||||
cx="-32.774117"
|
||||
cy="-34.132778"
|
||||
fx="-32.774117"
|
||||
fy="-34.132778"
|
||||
r="100.5"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(0.17569547,0,0,0.17569547,216.77538,168.37304)" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4122"
|
||||
id="radialGradient2487-3"
|
||||
cx="-32.774117"
|
||||
cy="-34.132778"
|
||||
fx="-32.774117"
|
||||
fy="-34.132778"
|
||||
r="100.5"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(0.17569547,0,0,0.17569547,148.19015,167.56553)" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient818"
|
||||
id="radialGradient2487-35"
|
||||
cx="-32.774117"
|
||||
cy="-34.132778"
|
||||
fx="-32.774117"
|
||||
fy="-34.132778"
|
||||
r="100.5"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(0.17569547,0,0,0.17569547,78.19015,167.56553)" />
|
||||
</defs>
|
||||
<g
|
||||
inkscape:label="Reference"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<circle
|
||||
style="fill:url(#radialGradient820);fill-opacity:1;stroke-width:0.269035"
|
||||
id="path111"
|
||||
cx="144.27811"
|
||||
cy="-32.278835"
|
||||
r="18.897638"
|
||||
transform="rotate(70.094091)"
|
||||
inkscape:label="Ref_Green" />
|
||||
<circle
|
||||
style="fill:url(#radialGradient820-3);fill-opacity:1;stroke-width:0.269035"
|
||||
id="path111-5"
|
||||
cx="167.63091"
|
||||
cy="-96.769478"
|
||||
r="18.897638"
|
||||
transform="rotate(70.094091)"
|
||||
inkscape:label="Ref_Blue" />
|
||||
<circle
|
||||
style="fill:url(#radialGradient820-3-3);fill-opacity:1;stroke-width:0.269035"
|
||||
id="path111-5-2"
|
||||
cx="190.98372"
|
||||
cy="-161.26012"
|
||||
r="18.897638"
|
||||
transform="rotate(70.094091)"
|
||||
inkscape:label="Ref_Yellow" />
|
||||
<path
|
||||
id="path12070"
|
||||
style="fill:none;stroke:url(#radialGradient2487);stroke-width:2.65618;stroke-dasharray:none;stroke-opacity:1"
|
||||
inkscape:label="path12070"
|
||||
d="m 234.34493,168.37304 a 17.569547,17.569547 0 0 1 -17.56955,17.56955 17.569547,17.569547 0 0 1 -17.56955,-17.56955 17.569547,17.569547 0 0 1 17.56955,-17.56954 17.569547,17.569547 0 0 1 17.56955,17.56954 z m -8.78478,-13.17716 a 8.7847737,4.3925624 0 0 1 -8.78477,4.39257 8.7847737,4.3925624 0 0 1 -8.78478,-4.39257 8.7847737,4.3925624 0 0 1 8.78478,-4.39256 8.7847737,4.3925624 0 0 1 8.78477,4.39256 z m 5.5607,3.03332 a 15.215674,7.6080127 0 0 1 -5.29689,8.65252 15.215674,7.6080127 0 0 1 -18.09716,0 15.215674,7.6080127 0 0 1 -5.2969,-8.65252 m 31.91503,10.14384 a 17.569547,8.7849492 0 0 1 -8.78478,7.60799 17.569547,8.7849492 0 0 1 -17.56955,0 17.569547,8.7849492 0 0 1 -8.78477,-7.60799 m 31.91502,10.14385 a 15.215674,7.6080127 0 0 1 -14.34547,5.072 15.215674,7.6080127 0 0 1 -14.34548,-5.072 m 3.88269,-24.25834 a 17.569547,12.614541 53.4512 0 1 20.59668,6.60244 17.569547,12.614541 53.4512 0 1 0.3289,21.62655 m -23.03967,-1.8462 a 13.675933,17.569547 45.7116 0 1 -1.98167,-14.61228 13.675933,17.569547 45.7116 0 1 12.57688,-12.26829 13.675933,17.569547 45.7116 0 1 14.55855,2.34398 m -13.1908,29.82711 a 1.0615675,17.569547 2.00244 0 1 -0.61182,-8.81153 1.0615675,17.569547 2.00244 0 1 0.61391,-17.55882 1.0615675,17.569547 2.00244 0 1 1.22575,-8.74728" />
|
||||
<path
|
||||
id="path12070-5"
|
||||
style="fill:none;stroke:url(#radialGradient2487-3);stroke-width:2.65618;stroke-dasharray:none;stroke-opacity:1"
|
||||
inkscape:label="path12070"
|
||||
d="m 165.7597,167.56553 a 17.569547,17.569547 0 0 1 -17.56955,17.56955 17.569547,17.569547 0 0 1 -17.56955,-17.56955 17.569547,17.569547 0 0 1 17.56955,-17.56954 17.569547,17.569547 0 0 1 17.56955,17.56954 z m -8.78478,-13.17716 a 8.7847737,4.3925624 0 0 1 -8.78477,4.39257 8.7847737,4.3925624 0 0 1 -8.78478,-4.39257 8.7847737,4.3925624 0 0 1 8.78478,-4.39256 8.7847737,4.3925624 0 0 1 8.78477,4.39256 z m 5.5607,3.03332 a 15.215674,7.6080127 0 0 1 -5.29689,8.65252 15.215674,7.6080127 0 0 1 -18.09716,0 15.215674,7.6080127 0 0 1 -5.2969,-8.65252 m 31.91503,10.14384 a 17.569547,8.7849492 0 0 1 -8.78478,7.60799 17.569547,8.7849492 0 0 1 -17.56955,0 17.569547,8.7849492 0 0 1 -8.78477,-7.60799 m 31.91502,10.14385 a 15.215674,7.6080127 0 0 1 -14.34547,5.072 15.215674,7.6080127 0 0 1 -14.34548,-5.072 m 3.88269,-24.25834 a 17.569547,12.614541 53.4512 0 1 20.59668,6.60244 17.569547,12.614541 53.4512 0 1 0.3289,21.62655 m -23.03967,-1.8462 a 13.675933,17.569547 45.7116 0 1 -1.98167,-14.61228 13.675933,17.569547 45.7116 0 1 12.57688,-12.26829 13.675933,17.569547 45.7116 0 1 14.55855,2.34398 m -13.1908,29.82711 a 1.0615675,17.569547 2.00244 0 1 -0.61182,-8.81153 1.0615675,17.569547 2.00244 0 1 0.61391,-17.55882 1.0615675,17.569547 2.00244 0 1 1.22575,-8.74728" />
|
||||
<path
|
||||
id="path12070-9"
|
||||
style="fill:none;stroke:url(#radialGradient2487-35);stroke-width:2.65618;stroke-dasharray:none;stroke-opacity:1"
|
||||
inkscape:label="path12070"
|
||||
d="M 95.7597,167.56553 A 17.569547,17.569547 0 0 1 78.19015,185.13508 17.569547,17.569547 0 0 1 60.6206,167.56553 17.569547,17.569547 0 0 1 78.19015,149.99599 17.569547,17.569547 0 0 1 95.7597,167.56553 Z m -8.78478,-13.17716 a 8.7847737,4.3925624 0 0 1 -8.78477,4.39257 8.7847737,4.3925624 0 0 1 -8.78478,-4.39257 8.7847737,4.3925624 0 0 1 8.78478,-4.39256 8.7847737,4.3925624 0 0 1 8.78477,4.39256 z m 5.5607,3.03332 a 15.215674,7.6080127 0 0 1 -5.29689,8.65252 15.215674,7.6080127 0 0 1 -18.09716,0 15.215674,7.6080127 0 0 1 -5.2969,-8.65252 m 31.91503,10.14384 a 17.569547,8.7849492 0 0 1 -8.78478,7.60799 17.569547,8.7849492 0 0 1 -17.56955,0 17.569547,8.7849492 0 0 1 -8.78477,-7.60799 m 31.91502,10.14385 a 15.215674,7.6080127 0 0 1 -14.34547,5.072 15.215674,7.6080127 0 0 1 -14.34548,-5.072 m 3.88269,-24.25834 a 17.569547,12.614541 53.4512 0 1 20.59668,6.60244 17.569547,12.614541 53.4512 0 1 0.3289,21.62655 m -23.03967,-1.8462 a 13.675933,17.569547 45.7116 0 1 -1.98167,-14.61228 13.675933,17.569547 45.7116 0 1 12.57688,-12.26829 13.675933,17.569547 45.7116 0 1 14.55855,2.34398 m -13.1908,29.82711 a 1.0615675,17.569547 2.00244 0 1 -0.61182,-8.81153 1.0615675,17.569547 2.00244 0 1 0.61391,-17.55882 1.0615675,17.569547 2.00244 0 1 1.22575,-8.74728" />
|
||||
</g>
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer2"
|
||||
inkscape:label="Atoms" />
|
||||
</svg>
|
After Width: | Height: | Size: 9.4 KiB |
@ -5,6 +5,8 @@ import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import glob
|
||||
import scipy.interpolate as ip
|
||||
from spin_image import SpinImage, FFT
|
||||
from ditact_pic import plot
|
||||
from lattices import VO2_Lattice
|
||||
plt.style.use(["style", "colors", "one_column"])
|
||||
|
||||
@ -14,6 +16,72 @@ def check_percentage(p1, p2):
|
||||
plt.plot(p1, p2)
|
||||
|
||||
|
||||
def average_mean(arr, window_size=20):
|
||||
arr_sum = np.cumsum(arr)
|
||||
arr = (arr_sum[window_size:] - arr_sum[:-window_size]) / window_size
|
||||
return arr
|
||||
|
||||
|
||||
def new_merge(files):
|
||||
wp = []
|
||||
op = []
|
||||
spot_1 = []
|
||||
spot_2 = []
|
||||
spot_3 = []
|
||||
plt.figure()
|
||||
for file in files:
|
||||
print(file)
|
||||
data = np.load(file, allow_pickle=True)
|
||||
old_percentage = data["percentage"]
|
||||
w_percentage = data["w_percentage"]
|
||||
wp.append(w_percentage)
|
||||
op.append(old_percentage)
|
||||
# check_percentage(old_percentage, w_percentage)
|
||||
out = []
|
||||
for o in ["out_1", "out_2", "out_3", "out_4"]:
|
||||
out.append(np.array(data[o]))
|
||||
print(out)
|
||||
out = np.array(out)[:, :, 0]
|
||||
|
||||
spot_1.append(out[0, :])
|
||||
spot_2.append(out[3, :])
|
||||
spot_3.append(out[2, :])
|
||||
wp = np.concatenate(wp, axis=0)
|
||||
op = np.concatenate(op, axis=0)
|
||||
spot_1 = np.concatenate(spot_1, axis=0)
|
||||
spot_2 = np.concatenate(spot_2, axis=0)
|
||||
spot_3 = np.concatenate(spot_3, axis=0)
|
||||
|
||||
arg_sort = np.argsort(op)
|
||||
wp = wp[arg_sort]
|
||||
op = op[arg_sort]
|
||||
spot_1 = spot_1[arg_sort]
|
||||
spot_2 = spot_2[arg_sort]
|
||||
spot_3 = spot_3[arg_sort]
|
||||
|
||||
win = 100
|
||||
wp = average_mean(wp, win)
|
||||
op = average_mean(op, win)
|
||||
spot_1 = average_mean(spot_1, win)
|
||||
spot_2 = average_mean(spot_2, win)
|
||||
spot_3 = average_mean(spot_3, win)
|
||||
|
||||
x = op
|
||||
plt.plot(x, spot_1, "r.")
|
||||
plt.plot(x, spot_2, "g.")
|
||||
plt.plot(x, spot_3, "b.")
|
||||
|
||||
ma = np.max(spot_1+spot_2+spot_3)
|
||||
spot_1 /= ma
|
||||
spot_2 /= ma
|
||||
spot_3 /= ma
|
||||
|
||||
print("debug....")
|
||||
print(wp.shape)
|
||||
plt.savefig("debug.png")
|
||||
return op, np.stack([spot_2, spot_1, spot_3])
|
||||
|
||||
|
||||
def merge(files):
|
||||
merge = []
|
||||
plt.figure()
|
||||
@ -34,17 +102,18 @@ def merge(files):
|
||||
out = out / summe
|
||||
merge.append(out)
|
||||
|
||||
plt.plot(w_percentage,out[0, :], "r")
|
||||
plt.plot(w_percentage,out[3, :], "b")
|
||||
plt.plot(w_percentage,out[2, :], "g")
|
||||
plt.plot(w_percentage, out[0, :], "r.")
|
||||
plt.plot(w_percentage, out[3, :], "b.")
|
||||
plt.plot(w_percentage, out[2, :], "g.")
|
||||
|
||||
all = sum(merge)
|
||||
summe = np.max(np.sum(all, axis=0))
|
||||
all = all / summe
|
||||
|
||||
plt.plot(all[0, :], "k")
|
||||
plt.plot(all[3, :], "k")
|
||||
plt.plot(all[2, :], "k")
|
||||
# plt.plot(all[0, :], "k")
|
||||
# plt.plot(all[3, :], "k")
|
||||
# plt.plot(all[2, :], "k")
|
||||
plt.savefig("debug.png")
|
||||
percentage = 1-percentage
|
||||
return percentage, all
|
||||
|
||||
@ -60,7 +129,7 @@ def debug(percentage, out):
|
||||
|
||||
|
||||
def stacked_plot(ax, percentage, out, title=""):
|
||||
stacks = ax.stackplot(percentage, out[[0, 3, 2]], colors=[
|
||||
stacks = ax.stackplot(percentage, out[[0, 1, 2]], colors=[
|
||||
"w"], ls=(0, (0, 1)), ec="w")
|
||||
hatches = ["//", "|", "\\\\"]
|
||||
for stack, hatch, color in zip(stacks, hatches, ["C1", "C0", "C2"]):
|
||||
@ -76,7 +145,7 @@ def stacked_plot(ax, percentage, out, title=""):
|
||||
bbox=dict(boxstyle='square,pad=0.0', ec="None", fc="w"))
|
||||
ax.text(0.35, 0.73, "diffusive", backgroundcolor="w",
|
||||
bbox=dict(boxstyle='square,pad=0.0', ec="None", fc="w"))
|
||||
ax.stackplot(percentage, out[[0, 3, 2]], colors=["None"], ec="k")
|
||||
ax.stackplot(percentage, out[[0, 1, 2]], colors=["None"], ec="k")
|
||||
|
||||
|
||||
def time_scale(ax, p, o):
|
||||
@ -119,7 +188,6 @@ def read_file(file):
|
||||
o = files["o"]
|
||||
return p, o
|
||||
|
||||
|
||||
def intens(ax, file, p, o):
|
||||
intens = FFT()
|
||||
intens.load(file)
|
||||
@ -128,7 +196,7 @@ def intens(ax, file, p, o):
|
||||
ax.set_ylim([-.9, .9])
|
||||
ax.axis("off")
|
||||
|
||||
#rect = plt.Rectangle((-1, -.8), 2, 1.6, facecolor="None", hatch="//")
|
||||
# rect = plt.Rectangle((-1, -.8), 2, 1.6, facecolor="None", hatch="//")
|
||||
# ax.add_patch(rect)
|
||||
lat = VO2_Lattice(20, 20)
|
||||
reci = lat.get_spots()
|
||||
@ -156,28 +224,28 @@ def intens(ax, file, p, o):
|
||||
axins = ax.inset_axes([0.0, 0.0, 0.5, 0.5])
|
||||
axins.plot(p, o[0], label="rut.", color="C1")
|
||||
axins.plot(p, o[2], label="mono.", color="C2")
|
||||
axins.plot(p, o[3], label="diff.", color="C0")
|
||||
axins.plot(p, o[1], label="diff.", color="C0")
|
||||
axins.legend(loc='center left', bbox_to_anchor=(1, 0.5))
|
||||
axins.set_xlim([0, 1])
|
||||
axins.set_ylim([0, 1])
|
||||
axins.set_xlabel("phase (%)")
|
||||
axins.set_ylabel("signal",labelpad=-5)
|
||||
|
||||
axins.set_ylabel("signal", labelpad=-5)
|
||||
|
||||
# axins.get_yaxis().set_visible(False)
|
||||
# axins.yaxis.tick_right()
|
||||
axins.set_yticks([0, 1])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
p, o = merge(sys.argv[2:])
|
||||
p, o = new_merge(sys.argv[2:])
|
||||
np.savez("merged.npz", p=p, o=o)
|
||||
# eval_data_print(f)
|
||||
|
||||
fig, axs = plt.subplots(1, 3)
|
||||
fig.set_figheight(2)
|
||||
stacked_plot(axs[1], p, o)
|
||||
time_scale(axs[2], p, o)
|
||||
intens(axs[0], sys.argv[1], p, o)
|
||||
if "intens" in sys.argv[1]:
|
||||
intens(axs[0], sys.argv[1], p, o)
|
||||
plt.tight_layout()
|
||||
plt.savefig("analysis.pdf")
|
||||
plt.savefig("analysis.png")
|
@ -47,7 +47,7 @@ def plot(fft, ax):
|
||||
fft.intens,
|
||||
extent=fft.extents(),
|
||||
norm=matplotlib.colors.LogNorm(vmin=1e-10, vmax=1),
|
||||
#norm=matplotlib.colors.Normalize(vmax=1, vmin=1e-10),
|
||||
# norm=matplotlib.colors.Normalize(vmax=1, vmin=1e-10),
|
||||
cmap="magma",
|
||||
origin="lower"
|
||||
)
|
||||
@ -128,7 +128,7 @@ def load():
|
||||
if __name__ == "__main__":
|
||||
np.random.seed(1234)
|
||||
simulate()
|
||||
# np.savez("intens.npz", r=r, mo=mo, mi=mi)
|
||||
np.savez("intens.npz", r=r, mo=mo, mi=mi)
|
||||
r, mo, mi = load()
|
||||
max = norm(r, mo, mi)
|
||||
r.intens = r.intens/max
|
@ -21,8 +21,8 @@ ch.setFormatter(formatter)
|
||||
logger.addHandler(ch)
|
||||
|
||||
|
||||
def ising(file):
|
||||
LEN = 120
|
||||
def ising(file, num):
|
||||
LEN = 60
|
||||
#lat = VO2_New(LEN, LEN)
|
||||
lat = VO2_New(LEN, LEN)
|
||||
rect = Rect_Evaluator(lat.get_spots())
|
||||
@ -64,10 +64,10 @@ def ising(file):
|
||||
w_percentage=weighted_percentage, percentage=percentage, out_1=out_rect[0],
|
||||
out_2=out_rect[1], out_3=out_rect[2], out_4=out_rect[3])
|
||||
|
||||
def runner(file):
|
||||
def runner(file, idx):
|
||||
np.random.seed(1234)
|
||||
print(f"runnig: {file}")
|
||||
ising(file)
|
||||
ising(file,idx)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@ -78,4 +78,4 @@ if __name__ == "__main__":
|
||||
exit()
|
||||
if idx < 1:
|
||||
exit()
|
||||
runner(files[idx-1])
|
||||
runner(files[idx-1], idx)
|
137
test_fft.py
137
test_fft.py
@ -1,137 +0,0 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
def analysis(y, RESOLUTION):
|
||||
fft = np.fft.fft(y)
|
||||
fft_clean = np.fft.fftshift(fft)
|
||||
fft_freq = np.fft.fftfreq(y.size, RESOLUTION)
|
||||
fft_freq_clean = np.fft.fftshift(fft_freq)
|
||||
|
||||
return fft_freq_clean, np.abs(fft_clean) ** 2
|
||||
|
||||
|
||||
def play_1d():
|
||||
RESOLUTION = 0.001
|
||||
LENGTH = 10000
|
||||
|
||||
x = np.arange(0, LENGTH, RESOLUTION) # angstrom
|
||||
y = np.zeros_like(x)
|
||||
|
||||
pos_mono = np.arange(0, x.size, 2890)
|
||||
pos_mono = (
|
||||
pos_mono + np.random.normal(size=pos_mono.shape, loc=0, scale=10)
|
||||
).astype(int)
|
||||
|
||||
pos_rut = np.arange(0, x.size, 5780)
|
||||
|
||||
pos_rut = np.append(pos_rut, pos_rut - 3160)
|
||||
|
||||
# pos_rut = (pos_rut + np.random.normal(size=pos_rut.shape, loc=0, scale=10)).astype(int)
|
||||
|
||||
y[pos_rut] = 1
|
||||
y[pos_rut + 1] = 1
|
||||
y[pos_rut + 2] = 1
|
||||
|
||||
# y = np.sin(x)
|
||||
|
||||
fig, axs = plt.subplots(3, 1)
|
||||
ax = axs[0]
|
||||
ax.plot(x, y)
|
||||
|
||||
ax = axs[1]
|
||||
fft_x, fft_y = analysis(y, RESOLUTION)
|
||||
ax.plot(fft_x, fft_y)
|
||||
ax.plot([1.0 / 5.78, 1.0 / 2.62, 1.0 / 3.16], [0, 0, 0], "kx")
|
||||
ax.plot([2.0 / 5.78, 2.0 / 2.62, 2.0 / 3.16], [0, 0, 0], "rx")
|
||||
ax.plot([3.0 / 5.78, 3.0 / 2.62, 3.0 / 3.16], [0, 0, 0], "bx")
|
||||
ax.set_xlim(0, 3)
|
||||
|
||||
|
||||
def from_mask(mask):
|
||||
pos_mono = np.arange(0, mask.size * 2.89 * 2, 2.89)
|
||||
|
||||
pos_mono[::2][mask] -= 0.27
|
||||
pos_mono[1::2][mask] += 0.27
|
||||
|
||||
return pos_mono
|
||||
|
||||
|
||||
def image_from_pos(pos):
|
||||
RESOLUTION = 0.001
|
||||
LENGTH = 1000000
|
||||
|
||||
x = np.arange(0, LENGTH, RESOLUTION) # angstrom
|
||||
y = np.zeros_like(x)
|
||||
ind = np.searchsorted(x, pos)
|
||||
if np.any(ind > LENGTH):
|
||||
print("overflow")
|
||||
ind = ind[ind < LENGTH]
|
||||
y[ind] = 1
|
||||
|
||||
sigma = 500
|
||||
mu = int(LENGTH / 2)
|
||||
gaussian = (
|
||||
1
|
||||
/ (sigma * np.sqrt(2 * np.pi))
|
||||
* np.exp(-((x - mu) ** 2) / (2 * sigma * sigma))
|
||||
)
|
||||
# y = np.multiply(y, gaussian)
|
||||
|
||||
return x, y
|
||||
|
||||
|
||||
def plot_img(x, y, ax):
|
||||
ax.plot(x, y)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
RESOLUTION = 0.001
|
||||
print("Done")
|
||||
|
||||
LENGTH = 1000
|
||||
mask_h = np.ones(LENGTH).astype(bool)
|
||||
pos_h = from_mask(mask_h)
|
||||
x, img_h = image_from_pos(pos_h)
|
||||
fftx, ffty_h = analysis(img_h, RESOLUTION)
|
||||
|
||||
mask_l = np.zeros(LENGTH).astype(bool)
|
||||
pos_l = from_mask(mask_l)
|
||||
x, img_l = image_from_pos(pos_l)
|
||||
fftx, ffty_l = analysis(img_l, RESOLUTION)
|
||||
print("Done")
|
||||
|
||||
mask_mixed = np.zeros(LENGTH).astype(bool)
|
||||
ind = (np.random.rand(400) * (LENGTH - 1)).astype(int)
|
||||
mask_mixed[ind] = True
|
||||
pos_mixed = from_mask(mask_mixed)
|
||||
x, img_mixed = image_from_pos(pos_mixed)
|
||||
fftx, ffty_mixed = analysis(img_mixed, RESOLUTION)
|
||||
|
||||
print("Done")
|
||||
mask_near = np.zeros(LENGTH).astype(bool)
|
||||
ind = (np.random.rand(50) * (LENGTH - 1)).astype(int)
|
||||
#for i in range(1, 8):
|
||||
# ind = np.append(ind, ind+i)
|
||||
print("Done")
|
||||
|
||||
|
||||
mask_near[ind] = True
|
||||
pos_near = from_mask(mask_near)
|
||||
x, img_near = image_from_pos(pos_near)
|
||||
fftx, ffty_near = analysis(img_near, RESOLUTION)
|
||||
|
||||
fig, axs = plt.subplots(4, 1)
|
||||
plot_img(fftx, ffty_h, axs[0])
|
||||
plot_img(fftx, ffty_l, axs[1])
|
||||
plot_img(fftx, ffty_mixed, axs[2])
|
||||
plot_img(fftx, ffty_near, axs[3])
|
||||
for ax in axs:
|
||||
ax.plot([1.0 / 5.78, 1.0 / 2.62, 1.0 / 3.16], [0, 0, 0], "kx")
|
||||
ax.plot([2.0 / 5.78, 2.0 / 2.62, 2.0 / 3.16], [0, 0, 0], "rx")
|
||||
ax.plot([3.0 / 5.78, 3.0 / 2.62, 3.0 / 3.16], [0, 0, 0], "bx")
|
||||
ax.set_xlim(0, 3)
|
||||
# play_1d()
|
||||
plt.show()
|
||||
print("Done")
|
||||
pass
|
Loading…
Reference in New Issue
Block a user