fixed bug
This commit is contained in:
parent
3bdb036ae5
commit
635b159858
@ -1,3 +1,4 @@
|
||||
import sys
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import glob
|
||||
@ -54,9 +55,9 @@ def parse_lists(out):
|
||||
def eval_data_print(file):
|
||||
data = np.load(file, allow_pickle=True)
|
||||
percentage = data["percentage"]
|
||||
#out = parse_lists(data["out"])
|
||||
# out = parse_lists(data["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]))
|
||||
fig, all_axs = plt.subplots(2, len(out))
|
||||
axs = all_axs[0, :]
|
||||
@ -66,7 +67,7 @@ def eval_data_print(file):
|
||||
ax.plot(percentage, o/o[0])
|
||||
# ax.plot(percentage, o)
|
||||
o = np.mean(o, axis=1)
|
||||
#o = o/o[0]
|
||||
# o = o/o[0]
|
||||
ax2.plot(percentage, o)
|
||||
ax2.plot([0, 1], [o[0], o[-1]], "k:")
|
||||
ax.set_title(lab)
|
||||
@ -87,7 +88,18 @@ def eval_data_print(file):
|
||||
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__":
|
||||
for f in glob.glob("*.npz"):
|
||||
eval_data_print(f)
|
||||
for f in sys.argv[1:]:
|
||||
#eval_data_print(f)
|
||||
stacked_plot(f)
|
||||
plt.show()
|
||||
|
@ -15,12 +15,6 @@ class Plotter:
|
||||
self.lattice = lat
|
||||
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):
|
||||
length_2 = self.length_2
|
||||
rect = patches.Rectangle(
|
||||
@ -33,7 +27,11 @@ class Plotter:
|
||||
)
|
||||
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:
|
||||
t = ax_log.imshow(
|
||||
intens,
|
||||
@ -43,6 +41,7 @@ class Plotter:
|
||||
cmap="viridis",
|
||||
origin="lower"
|
||||
)
|
||||
self.add_peaks(ax_log)
|
||||
plt.colorbar(t, ax=ax_log)
|
||||
if ax_lin:
|
||||
t = ax_lin.imshow(
|
||||
@ -132,6 +131,12 @@ def test_mixed():
|
||||
np.random.shuffle(ind)
|
||||
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.gaussian(20)
|
||||
fx, fy, intens_mono = si.fft()
|
||||
@ -147,12 +152,15 @@ def test_mixed():
|
||||
fx, fy, intens_mixed = si.fft()
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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
|
||||
|
||||
@ -175,33 +183,34 @@ def random(seed):
|
||||
out_voro = [[] for x in range(len(lat.reci())+1)]
|
||||
percentage = []
|
||||
counter = 0
|
||||
plot = Plotter(lat)
|
||||
[(x, y), (x1, y1)] = lat.get_both()
|
||||
si = SpinImage_Two_Phase(x, y, x1, y1)
|
||||
already_inited = False
|
||||
|
||||
for i in tqdm.tqdm(ind):
|
||||
maske[np.unravel_index(i, (LEN, LEN))] = True
|
||||
counter += 1
|
||||
if np.mod(counter, 100) != 0:
|
||||
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()
|
||||
img = Image_Wrapper(intens, fx, fy)
|
||||
if not already_inited:
|
||||
print("start_init")
|
||||
voro.generate_mask(img, merge=True)
|
||||
print("stop_init")
|
||||
rect.generate_mask(img, merge=True)
|
||||
already_inited = True
|
||||
#if not already_inited:
|
||||
# print("start_init")
|
||||
# voro.generate_mask(img, merge=True)
|
||||
# rect.generate_mask(img, merge=True)
|
||||
# already_inited = True
|
||||
|
||||
iv, vv = voro.extract(img)
|
||||
ir, vr = rect.extract(img)
|
||||
for lis, val in zip(out_rect, vr):
|
||||
lis.append(val)
|
||||
for lis, val in zip(out_voro, vv):
|
||||
lis.append(val)
|
||||
percentage.append(np.sum(maske))
|
||||
#iv, vv = voro.extract(img)
|
||||
#ir, vr = rect.extract(img)
|
||||
#for lis, val in zip(out_rect, vr):
|
||||
# lis.append(val)
|
||||
#for lis, val in zip(out_voro, vv):
|
||||
# lis.append(val)
|
||||
#percentage.append(np.sum(maske))
|
||||
|
||||
percentage = np.array(percentage)
|
||||
percentage /= np.max(percentage)
|
||||
@ -303,17 +312,16 @@ def test_me():
|
||||
maske = np.invert(maske)
|
||||
si.apply_mask(maske)
|
||||
axs[2].imshow(si.img)
|
||||
|
||||
axs[3].imshow(si.img+tmp)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
np.random.seed(1234)
|
||||
# test_me()
|
||||
# test_square()
|
||||
test_mixed()
|
||||
plt.show()
|
||||
# random()
|
||||
# np.random.seed(1234)
|
||||
#random(1234)
|
||||
# for i in np.random.randint(0, 10000, 1):
|
||||
# random(i)
|
||||
# ising(i)
|
||||
|
@ -114,10 +114,6 @@ class VO2_Lattice(Lattice):
|
||||
# offset_a_r = -offset_a_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 * \
|
||||
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
|
||||
@ -166,7 +162,7 @@ class VO2_New(VO2_Lattice):
|
||||
# maske[0::4, :] = np.roll(maske[0::4, :], axis=1, shift=1)
|
||||
# maske[1::4, :] = np.roll(maske[1::4, :], axis=1, shift=1)
|
||||
# return maske
|
||||
#def parse_mask(self, mask: np.ndarray) -> np.ndarray:
|
||||
# def parse_mask(self, mask: np.ndarray) -> np.ndarray:
|
||||
# print(mask.shape)
|
||||
# maske = np.empty((mask.shape[0]*2, mask.shape[1]))
|
||||
# maske[0::2, :] = mask
|
||||
|
Loading…
Reference in New Issue
Block a user