126 lines
3.2 KiB
Python
126 lines
3.2 KiB
Python
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 = []
|
|
plt.figure()
|
|
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 = old_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)
|
|
|
|
plt.plot(out[0, :], "r")
|
|
plt.plot(out[3, :], "b")
|
|
plt.plot(out[2, :], "g")
|
|
|
|
all = sum(merge)
|
|
|
|
summe = np.max(np.sum(all, axis=0))
|
|
all = all / summe
|
|
|
|
plt.plot(all[0, :], "k")
|
|
plt.plot(all[3, :], "k")
|
|
plt.plot(all[2, :], "k")
|
|
percentage = 1-percentage
|
|
return percentage, all
|
|
|
|
|
|
def debug(percentage, out):
|
|
plt.figure()
|
|
for o in out:
|
|
plt.plot(percentage, o)
|
|
|
|
plt.plot(percentage, out[0, :], "k")
|
|
plt.plot(percentage, out[3, :], "k")
|
|
plt.plot(percentage, out[2, :], "k")
|
|
|
|
|
|
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("Metallic 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)
|
|
plt.savefig("intens.png")
|
|
plt.savefig("intens.pdf")
|
|
|
|
|
|
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])
|
|
cs_rut = ip.interp1d(p[::-1], rut_perc[::-1])
|
|
cs_mono = ip.interp1d(p[::-1], mono_perc[::-1])
|
|
|
|
plt.figure()
|
|
ph = np.linspace(0.01, 0.99, 100)
|
|
plt.plot(ph, cs_rut(ph))
|
|
plt.plot(ph, cs_mono(ph))
|
|
|
|
time = np.linspace(0.01, 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, "k:", label="corr.")
|
|
plt.plot(time, rut_phase, label="rut.")
|
|
plt.plot(time, mono_phase, label="mono")
|
|
plt.xlabel("time (a.u.)")
|
|
plt.ylabel("Metallic Phase (%)")
|
|
plt.legend()
|
|
plt.tight_layout()
|
|
plt.savefig("timescale.png")
|
|
plt.savefig("timescale.pdf")
|
|
|
|
def read_file(file):
|
|
files = np.load("./merged.npz")
|
|
p = files["p"]
|
|
o = files["o"]
|
|
return p, o
|
|
|
|
|
|
if __name__ == "__main__":
|
|
p, o = merge(sys.argv[1:])
|
|
# debug(p, o)
|
|
stacked_plot(p, o)
|
|
time_scale(p, o)
|
|
plt.show()
|