from plotter import Plotter import matplotlib from lattices import VO2_New from spin_image import SpinImage, FFT import numpy as np import matplotlib.pyplot as plt plt.style.use("two_column") def simulate(): LEN = 50 lat = VO2_New(LEN, LEN) plot = Plotter(lat) si = SpinImage(lat.get_phases()) mask_misk = np.ones((LEN, 2*LEN)) ind = np.arange(mask_misk.size) np.random.shuffle(ind) mask_misk[np.unravel_index( ind[:int(mask_misk.size/2)], mask_misk.shape)] = 0 print(mask_misk.shape) si.apply_mask(lat.parse_mask(np.zeros((LEN, 2*LEN)))) si.gaussian(20) intens_mono = si.fft() intens_mono.clean() si.apply_mask(lat.parse_mask(np.ones((LEN, 2*LEN)))) si.gaussian(20) intens_rutile = si.fft() intens_rutile.clean() si.apply_mask(lat.parse_mask(mask_misk)) # si.apply_mask(mask_misk) si.gaussian(20) intens_mixed = si.fft() intens_mixed.clean() intens_rutile.save("intens_rut.npz") intens_mono.save("intens_mono.npz") intens_mixed.save("intens_mixed.npz") def plot(fft, ax): ax.imshow( fft.intens, extent=fft.extents(), norm=matplotlib.colors.LogNorm(), cmap="magma", origin="lower" ) def plot_all(intens_rutile, intens_mono, intens_mixed): fig, axs = plt.subplots(4, 2) fig.set_figheight(6) for ax in axs.flatten(): ax.axis("off") axs = axs[:, 1] ax = axs[0] plot(intens_rutile, ax) ax = axs[1] plot(intens_mono, ax) y_shift = 0.175 h_shift = 2*y_shift l_shift = 0.108 big_shift = l_shift + h_shift c = plt.Circle((-l_shift, y_shift), radius=0.07, label='patch', fill=False, ec="w", ls=":") ax.add_patch(c) c = plt.Circle((l_shift, -y_shift), radius=0.07, label='patch', fill=False, ec="w", ls=":") ax.add_patch(c) c = plt.Circle((-h_shift, -y_shift), radius=0.07, label='patch', fill=False, ec="w", ls=":") ax.add_patch(c) c = plt.Circle((h_shift, y_shift), radius=0.07, label='patch', fill=False, ec="w", ls=":") ax.add_patch(c) ax = axs[2] plot(intens_mixed, ax) # c = matplotlib.patches.Ellipse((0., 0.), width=0.2, height=1.4, angle=45, # label='patch', fill=False, ec="w", ls=":") # height = 1.4 # width = 0.0 # c = matplotlib.patches.Rectangle((-width/2, -height/2), width=width, height=height, # angle=45, rotation_point="center", # label='patch', fill=False, ec="w", ls=":") # ax.add_patch(c) ax.plot([-1, 1], [1, -1], "w", linestyle=(0, (2, 6))) ax = axs[3] plot(intens_mixed, ax) ax.plot([-1, 1], [0, 0], "w", linestyle=(0, (2, 6))) ax.plot([-1, 1], [2 * y_shift, 2 * y_shift], "w", linestyle=(0, (2, 6))) ax.plot([-1, 1], [-2*y_shift, -2*y_shift], "w", linestyle=(0, (2, 6))) ax.plot([-100*l_shift + big_shift*.5, 100*l_shift + big_shift*.5], [y_shift*100, -y_shift*100], "w", linestyle=(0, (2, 6))) ax.plot([-100*l_shift - big_shift*.5, 100*l_shift - big_shift*.5], [y_shift*100, -y_shift*100], "w", linestyle=(0, (2, 6))) for ax in axs: ax.axis("off") ax.set_xlim(-0.5, 0.5) ax.set_ylim(-0.5, 0.5) plt.tight_layout() fig.savefig("erklaerbaer.pdf") fig.savefig("erklaerbaer.png") # Plotting cuts def load(): r = FFT() r.load("intens_rut.npz") mo = FFT() mo.load("intens_mono.npz") mi = FFT() mi.load("intens_mixed.npz") return r, mo, mi if __name__ == "__main__": np.random.seed(1234) simulate() # np.savez("intens.npz", r=r, mo=mo, mi=mi) r, mo, mi = load() plot_all(r, mo, mi) plt.show()