From 3f8fdd38d1df79ff2f69460b189e4ac6853779ac Mon Sep 17 00:00:00 2001 From: Jacob Date: Tue, 25 Apr 2023 16:25:05 +0200 Subject: [PATCH] updated picture --- clean_python/ditact_pic.py | 62 ++++++++++++++++++-------------------- clean_python/lattices.py | 18 +---------- clean_python/main.py | 5 +-- 3 files changed, 34 insertions(+), 51 deletions(-) diff --git a/clean_python/ditact_pic.py b/clean_python/ditact_pic.py index c523354..e27ab9b 100644 --- a/clean_python/ditact_pic.py +++ b/clean_python/ditact_pic.py @@ -6,7 +6,7 @@ import numpy as np import matplotlib.pyplot as plt -plt.style.use("two_column") +plt.style.use(["style", "colors","two_column"]) def simulate(): @@ -14,19 +14,19 @@ def simulate(): lat = VO2_New(LEN, LEN) plot = Plotter(lat) si = SpinImage(lat.get_phases()) - mask_misk = np.ones((LEN, 2*LEN)) + mask_misk = np.ones((2*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.apply_mask(lat.parse_mask(np.ones((2*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.apply_mask(lat.parse_mask(np.zeros((2*LEN, 2*LEN)))) si.gaussian(20) intens_rutile = si.fft() intens_rutile.clean() @@ -43,18 +43,25 @@ def simulate(): def plot(fft, ax): - ax.imshow( + return ax.imshow( fft.intens, extent=fft.extents(), - norm=matplotlib.colors.LogNorm(), + norm=matplotlib.colors.LogNorm(vmin=1e-10, vmax=1), + #norm=matplotlib.colors.Normalize(vmax=1, vmin=1e-10), cmap="magma", origin="lower" ) +def norm(*intenss): + max = 1e-10 + for intens in intenss: + m = np.max(intens.intens) + max = np.maximum(max,m) + return max def plot_all(intens_rutile, intens_mono, intens_mixed): - fig, axs = plt.subplots(4, 2) - fig.set_figheight(6) + fig, axs = plt.subplots(3, 2) + fig.set_figheight(5.2) for ax in axs.flatten(): ax.axis("off") axs = axs[:, 1] @@ -83,33 +90,20 @@ def plot_all(intens_rutile, intens_mono, intens_mixed): 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))) + cmap = plot(intens_mixed, ax) + cut_off = 0.8 for ax in axs: ax.axis("off") - ax.set_xlim(-0.5, 0.5) - ax.set_ylim(-0.5, 0.5) + ax.set_xlim(-cut_off, cut_off) + ax.set_ylim(-cut_off, cut_off) plt.tight_layout() + fig.subplots_adjust(bottom=0.1,right=0.95,left=0.15,wspace=0.) + cbar_ax = fig.add_axes([0.55, 0.07, 0.4, 0.015]) + cbar = fig.colorbar(cmap, cax=cbar_ax, orientation="horizontal", ticks=[1e-10, 1e-5, 1e0]) + #cbar.ax.set_xticklabels(['Low', 'Medium', 'High']) + + fig.savefig("erklaerbaer.pdf") fig.savefig("erklaerbaer.png") # Plotting cuts @@ -128,9 +122,13 @@ def load(): if __name__ == "__main__": np.random.seed(1234) - simulate() + #simulate() # np.savez("intens.npz", r=r, mo=mo, mi=mi) r, mo, mi = load() + max = norm(r,mo,mi) + r.intens = r.intens/max + mo.intens = mo.intens/max + mi.intens = mi.intens/max plot_all(r, mo, mi) plt.show() diff --git a/clean_python/lattices.py b/clean_python/lattices.py index a7e438f..b18b0b4 100644 --- a/clean_python/lattices.py +++ b/clean_python/lattices.py @@ -111,7 +111,7 @@ class VO2_Lattice(Lattice): # offset_a_m = -offset_a_m offset_a_r, offset_c_r = self._mono_2_rutile(offset_c_m, offset_a_m) - # offset_a_r = -offset_a_r + offset_a_r = -offset_a_r # offset_c_r = -offset_c_r x = offset_a_r + self.X * \ @@ -153,21 +153,5 @@ class VO2_Lattice(Lattice): class VO2_New(VO2_Lattice): - # def parse_mask(self, mask: np.ndarray) -> np.ndarray: - # maske = np.empty((mask.shape[0]*2, mask.shape[1]*2)) - # maske[0::2, 0::2] = mask - # maske[1::2, 0::2] = mask - # maske[0::2, 1::2] = mask - # maske[1::2, 1::2] = mask - # 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: - # print(mask.shape) - # maske = np.empty((mask.shape[0]*2, mask.shape[1])) - # maske[0::2, :] = mask - # maske[1::2, :] = mask - # print(maske.shape) - # return maske def parse_mask(self, mask: np.ndarray): return mask diff --git a/clean_python/main.py b/clean_python/main.py index 9fbdaf6..a053e65 100644 --- a/clean_python/main.py +++ b/clean_python/main.py @@ -24,8 +24,9 @@ logger.addHandler(ch) def random(seed): np.random.seed(seed) LEN = 40 - lat = VO2_New(LEN, LEN) - maske = np.zeros((LEN*2, LEN*2)) + #lat = VO2_New(LEN, LEN) + lat = VO2_Lattice(LEN, LEN) + maske = np.zeros((LEN, LEN)) ind = np.arange(maske.size) np.random.shuffle(ind) rect = Rect_Evaluator(lat.get_spots())