fixed bug
This commit is contained in:
parent
3bdb036ae5
commit
635b159858
@ -1,3 +1,4 @@
|
|||||||
|
import sys
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import glob
|
import glob
|
||||||
@ -54,9 +55,9 @@ def parse_lists(out):
|
|||||||
def eval_data_print(file):
|
def eval_data_print(file):
|
||||||
data = np.load(file, allow_pickle=True)
|
data = np.load(file, allow_pickle=True)
|
||||||
percentage = data["percentage"]
|
percentage = data["percentage"]
|
||||||
#out = parse_lists(data["out"])
|
# out = parse_lists(data["out"])
|
||||||
out = []
|
out = []
|
||||||
for o in ["out_1","out_2","out_3","out_4"]:
|
for o in ["out_1", "out_2", "out_3", "out_4"]:
|
||||||
out.append(np.array(data[o]))
|
out.append(np.array(data[o]))
|
||||||
fig, all_axs = plt.subplots(2, len(out))
|
fig, all_axs = plt.subplots(2, len(out))
|
||||||
axs = all_axs[0, :]
|
axs = all_axs[0, :]
|
||||||
@ -66,7 +67,7 @@ def eval_data_print(file):
|
|||||||
ax.plot(percentage, o/o[0])
|
ax.plot(percentage, o/o[0])
|
||||||
# ax.plot(percentage, o)
|
# ax.plot(percentage, o)
|
||||||
o = np.mean(o, axis=1)
|
o = np.mean(o, axis=1)
|
||||||
#o = o/o[0]
|
# o = o/o[0]
|
||||||
ax2.plot(percentage, o)
|
ax2.plot(percentage, o)
|
||||||
ax2.plot([0, 1], [o[0], o[-1]], "k:")
|
ax2.plot([0, 1], [o[0], o[-1]], "k:")
|
||||||
ax.set_title(lab)
|
ax.set_title(lab)
|
||||||
@ -87,7 +88,18 @@ def eval_data_print(file):
|
|||||||
plt.tight_layout()
|
plt.tight_layout()
|
||||||
|
|
||||||
|
|
||||||
|
def stacked_plot(file):
|
||||||
|
data = np.load(file, allow_pickle=True)
|
||||||
|
percentage = data["percentage"]
|
||||||
|
# out = parse_lists(data["out"])
|
||||||
|
out = []
|
||||||
|
for o in ["out_1", "out_2", "out_3", "out_4"]:
|
||||||
|
out.append(np.array(data[o]))
|
||||||
|
out = np.array(out)
|
||||||
|
plt.stackplot(percentage, out)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
for f in glob.glob("*.npz"):
|
for f in sys.argv[1:]:
|
||||||
eval_data_print(f)
|
#eval_data_print(f)
|
||||||
|
stacked_plot(f)
|
||||||
plt.show()
|
plt.show()
|
||||||
|
@ -15,12 +15,6 @@ class Plotter:
|
|||||||
self.lattice = lat
|
self.lattice = lat
|
||||||
self.length_2 = 0.05
|
self.length_2 = 0.05
|
||||||
|
|
||||||
def reduce(self, arr):
|
|
||||||
arr = np.array(arr)
|
|
||||||
arr = arr.flatten()
|
|
||||||
return np.mean(arr)
|
|
||||||
# return np.sum(arr[np.argpartition(arr, -8)[-8:]])
|
|
||||||
|
|
||||||
def rect_at_point(self, x, y, color):
|
def rect_at_point(self, x, y, color):
|
||||||
length_2 = self.length_2
|
length_2 = self.length_2
|
||||||
rect = patches.Rectangle(
|
rect = patches.Rectangle(
|
||||||
@ -33,7 +27,11 @@ class Plotter:
|
|||||||
)
|
)
|
||||||
return rect
|
return rect
|
||||||
|
|
||||||
def plot(self, freqx, freqy, intens, ax_log=None, ax_lin=None, vmax=None):
|
|
||||||
|
def plot(self, freqx, freqy, intens, ax_log=None, ax_lin=None, vmax=None, evaluator=None):
|
||||||
|
if evaluator is not None:
|
||||||
|
img = Image_Wrapper(freqx,freqy, intens)
|
||||||
|
intens = evaluator.debug(img)
|
||||||
if ax_log:
|
if ax_log:
|
||||||
t = ax_log.imshow(
|
t = ax_log.imshow(
|
||||||
intens,
|
intens,
|
||||||
@ -43,6 +41,7 @@ class Plotter:
|
|||||||
cmap="viridis",
|
cmap="viridis",
|
||||||
origin="lower"
|
origin="lower"
|
||||||
)
|
)
|
||||||
|
self.add_peaks(ax_log)
|
||||||
plt.colorbar(t, ax=ax_log)
|
plt.colorbar(t, ax=ax_log)
|
||||||
if ax_lin:
|
if ax_lin:
|
||||||
t = ax_lin.imshow(
|
t = ax_lin.imshow(
|
||||||
@ -132,6 +131,12 @@ def test_mixed():
|
|||||||
np.random.shuffle(ind)
|
np.random.shuffle(ind)
|
||||||
mask_misk[np.unravel_index(ind[:800], (LEN, LEN))] = False
|
mask_misk[np.unravel_index(ind[:800], (LEN, LEN))] = False
|
||||||
|
|
||||||
|
|
||||||
|
all_rutile = np.stack(lat.reci()[0]).T
|
||||||
|
all_mono = np.stack(lat.reci()[1]).T
|
||||||
|
all_mono2 = np.stack(lat.reci()[2]).T
|
||||||
|
#voro = Voronoi_Evaluator([all_rutile, all_mono, all_mono2])
|
||||||
|
|
||||||
si.apply_mask(np.zeros((LEN, LEN), dtype=bool))
|
si.apply_mask(np.zeros((LEN, LEN), dtype=bool))
|
||||||
si.gaussian(20)
|
si.gaussian(20)
|
||||||
fx, fy, intens_mono = si.fft()
|
fx, fy, intens_mono = si.fft()
|
||||||
@ -147,12 +152,15 @@ def test_mixed():
|
|||||||
fx, fy, intens_mixed = si.fft()
|
fx, fy, intens_mixed = si.fft()
|
||||||
si.plot(axs[0, 1])
|
si.plot(axs[0, 1])
|
||||||
|
|
||||||
|
img =
|
||||||
|
rect = Rect_Evaluator([all_rutile, all_mono, all_mono2])
|
||||||
|
rect.generate_mask(img)
|
||||||
plot.plot(freqx=fx, freqy=fy, intens=intens_rutile,
|
plot.plot(freqx=fx, freqy=fy, intens=intens_rutile,
|
||||||
ax_log=axs[1, 0], ax_lin=axs[2, 0], vmax=10e7)
|
ax_log=axs[1, 0], ax_lin=axs[2, 0], evaluator=rect)
|
||||||
plot.plot(freqx=fx, freqy=fy, intens=intens_mono,
|
plot.plot(freqx=fx, freqy=fy, intens=intens_mono,
|
||||||
ax_log=axs[1, 2], ax_lin=axs[2, 2], vmax=10e7)
|
ax_log=axs[1, 2], ax_lin=axs[2, 2], evaluator=rect)
|
||||||
plot.plot(freqx=fx, freqy=fy, intens=intens_mixed,
|
plot.plot(freqx=fx, freqy=fy, intens=intens_mixed,
|
||||||
ax_log=axs[1, 1], ax_lin=axs[2, 1], vmax=10e7)
|
ax_log=axs[1, 1], ax_lin=axs[2, 1], evaluator=rect)
|
||||||
|
|
||||||
# Plotting cuts
|
# Plotting cuts
|
||||||
|
|
||||||
@ -175,33 +183,34 @@ def random(seed):
|
|||||||
out_voro = [[] for x in range(len(lat.reci())+1)]
|
out_voro = [[] for x in range(len(lat.reci())+1)]
|
||||||
percentage = []
|
percentage = []
|
||||||
counter = 0
|
counter = 0
|
||||||
|
plot = Plotter(lat)
|
||||||
|
[(x, y), (x1, y1)] = lat.get_both()
|
||||||
|
si = SpinImage_Two_Phase(x, y, x1, y1)
|
||||||
already_inited = False
|
already_inited = False
|
||||||
|
|
||||||
for i in tqdm.tqdm(ind):
|
for i in tqdm.tqdm(ind):
|
||||||
maske[np.unravel_index(i, (LEN, LEN))] = True
|
maske[np.unravel_index(i, (LEN, LEN))] = True
|
||||||
counter += 1
|
counter += 1
|
||||||
if np.mod(counter, 100) != 0:
|
if np.mod(counter, 100) != 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
si.apply_mask(maske)
|
||||||
|
si.gaussian(20)
|
||||||
|
|
||||||
pos_x, pos_y = lat.get_from_mask(maske)
|
|
||||||
si = SpinImage(pos_x, pos_y)
|
|
||||||
si.pad_it_square(10, size=2300)
|
|
||||||
fx, fy, intens = si.fft()
|
fx, fy, intens = si.fft()
|
||||||
img = Image_Wrapper(intens, fx, fy)
|
img = Image_Wrapper(intens, fx, fy)
|
||||||
if not already_inited:
|
#if not already_inited:
|
||||||
print("start_init")
|
# print("start_init")
|
||||||
voro.generate_mask(img, merge=True)
|
# voro.generate_mask(img, merge=True)
|
||||||
print("stop_init")
|
# rect.generate_mask(img, merge=True)
|
||||||
rect.generate_mask(img, merge=True)
|
# already_inited = True
|
||||||
already_inited = True
|
|
||||||
|
|
||||||
iv, vv = voro.extract(img)
|
#iv, vv = voro.extract(img)
|
||||||
ir, vr = rect.extract(img)
|
#ir, vr = rect.extract(img)
|
||||||
for lis, val in zip(out_rect, vr):
|
#for lis, val in zip(out_rect, vr):
|
||||||
lis.append(val)
|
# lis.append(val)
|
||||||
for lis, val in zip(out_voro, vv):
|
#for lis, val in zip(out_voro, vv):
|
||||||
lis.append(val)
|
# lis.append(val)
|
||||||
percentage.append(np.sum(maske))
|
#percentage.append(np.sum(maske))
|
||||||
|
|
||||||
percentage = np.array(percentage)
|
percentage = np.array(percentage)
|
||||||
percentage /= np.max(percentage)
|
percentage /= np.max(percentage)
|
||||||
@ -303,17 +312,16 @@ def test_me():
|
|||||||
maske = np.invert(maske)
|
maske = np.invert(maske)
|
||||||
si.apply_mask(maske)
|
si.apply_mask(maske)
|
||||||
axs[2].imshow(si.img)
|
axs[2].imshow(si.img)
|
||||||
|
|
||||||
axs[3].imshow(si.img+tmp)
|
axs[3].imshow(si.img+tmp)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
np.random.seed(1234)
|
||||||
# test_me()
|
# test_me()
|
||||||
# test_square()
|
# test_square()
|
||||||
test_mixed()
|
test_mixed()
|
||||||
plt.show()
|
plt.show()
|
||||||
# random()
|
#random(1234)
|
||||||
# np.random.seed(1234)
|
|
||||||
# for i in np.random.randint(0, 10000, 1):
|
# for i in np.random.randint(0, 10000, 1):
|
||||||
# random(i)
|
# random(i)
|
||||||
# ising(i)
|
# ising(i)
|
||||||
|
@ -114,10 +114,6 @@ class VO2_Lattice(Lattice):
|
|||||||
# offset_a_r = -offset_a_r
|
# offset_a_r = -offset_a_r
|
||||||
# offset_c_r = -offset_c_r
|
# offset_c_r = -offset_c_r
|
||||||
|
|
||||||
res = 0.05
|
|
||||||
offset_a_r = res * int(offset_a_r/res)
|
|
||||||
offset_c_r = res * int(offset_c_r/res)
|
|
||||||
|
|
||||||
x = offset_a_r + self.X * \
|
x = offset_a_r + self.X * \
|
||||||
self.base_c_r + np.mod(self.Y, 4) * 0.5 * self.base_c_r
|
self.base_c_r + np.mod(self.Y, 4) * 0.5 * self.base_c_r
|
||||||
x[np.mod(self.X, 2) == 0] -= 2 * offset_a_r
|
x[np.mod(self.X, 2) == 0] -= 2 * offset_a_r
|
||||||
@ -166,7 +162,7 @@ class VO2_New(VO2_Lattice):
|
|||||||
# maske[0::4, :] = np.roll(maske[0::4, :], axis=1, shift=1)
|
# maske[0::4, :] = np.roll(maske[0::4, :], axis=1, shift=1)
|
||||||
# maske[1::4, :] = np.roll(maske[1::4, :], axis=1, shift=1)
|
# maske[1::4, :] = np.roll(maske[1::4, :], axis=1, shift=1)
|
||||||
# return maske
|
# return maske
|
||||||
#def parse_mask(self, mask: np.ndarray) -> np.ndarray:
|
# def parse_mask(self, mask: np.ndarray) -> np.ndarray:
|
||||||
# print(mask.shape)
|
# print(mask.shape)
|
||||||
# maske = np.empty((mask.shape[0]*2, mask.shape[1]))
|
# maske = np.empty((mask.shape[0]*2, mask.shape[1]))
|
||||||
# maske[0::2, :] = mask
|
# maske[0::2, :] = mask
|
||||||
|
Loading…
Reference in New Issue
Block a user