import sys import numpy as np import matplotlib.pyplot as plt import glob import scipy.interpolate as ip plt.style.use(["style", "colors", "two_column"]) def check_percentage(p1, p2): plt.figure() plt.plot(p1, p2) def merge(files): merge = [] for file in files: data = np.load(file, allow_pickle=True) old_percentage = data["percentage"] w_percentage = data["w_percentage"] # check_percentage(old_percentage, w_percentage) percentage = w_percentage out = [] for o in ["out_1", "out_2", "out_3", "out_4"]: out.append(np.array(data[o])) out = np.array(out)[:, :, 0] summe = np.max(np.sum(out, axis=0)) out = out / summe merge.append(out) print(merge) merge = sum(merge) summe = np.max(np.sum(merge, axis=0)) merge = merge / summe print(merge) return percentage, merge def debug(percentage, out): plt.figure() for o in out: plt.plot(percentage, o) def stacked_plot(percentage, out, title=""): plt.figure() stacks = plt.stackplot(percentage, out[[0, 3, 1, 2], :], colors=[ "w"], ls="solid", ec="k") hatches = ["/", "", "\\", "\\"] for stack, hatch in zip(stacks, hatches): stack.set_hatch(hatch) plt.xlabel("Insulating Phase (%)") plt.ylabel("normalized Intensity ") plt.ylim([0.4, 1]) plt.xlim([0., 1]) plt.tight_layout() plt.text(0.1, 0.9, "monoclinic", backgroundcolor="w") plt.text(0.6, 0.5, "rutile", backgroundcolor="w") plt.text(0.35, 0.75, "diffusive", backgroundcolor="w") plt.title(title) def time_scale(p, o): rut_perc = o[0] rut_perc = rut_perc - np.min(rut_perc) rut_perc /= np.max(rut_perc) mono_perc = -o[2] mono_perc = mono_perc - np.min(mono_perc) mono_perc /= np.max(mono_perc) cs_rut = ip.CubicSpline(p[::-1], rut_perc[::-1]) cs_mono = ip.CubicSpline(p[::-1], mono_perc[::-1]) plt.figure() ph = np.linspace(0, 1, 100) plt.plot(ph, cs_rut(ph)) plt.plot(ph, cs_mono(ph)) time = np.linspace(0, 3, 1000) phy_phase = np.exp(-time) rut_phase = cs_rut(phy_phase) mono_phase = cs_mono(phy_phase) plt.figure() plt.plot(time, phy_phase) plt.plot(time, rut_phase) plt.plot(time, mono_phase) if __name__ == "__main__": p, o = merge(sys.argv[1:]) # eval_data_print(f) stacked_plot(p, o) # debug(p, o) time_scale(p, o) plt.show()