Files

69 lines
2.3 KiB
Python

#!/usr/bin/env python3
import numpy as np
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
def load(path):
with open(path) as fh:
lines = [l for l in fh.read().splitlines() if l.strip()]
header = lines[0].split()
rows = [l.split() for l in lines[1:]]
arr = np.array(rows, dtype=float)
cols = {name: i for i, name in enumerate(header)}
return cols, arr
def series(path, stem):
cols, arr = load(path)
e = arr[:, cols["dataE"]]
val_key = next(k for k in cols if k.startswith(stem + "_") and k.endswith(tuple("0123456789")))
err_key = next(k for k in cols if k.startswith(stem + "_") and k.endswith("PosErr"))
return e, arr[:, cols[val_key]], arr[:, cols[err_key]]
d1 = {s: series("dataset1.dat", s) for s in ("Asy", "Sgm", "Bfield")}
d2 = {s: series("dataset2.dat", s) for s in ("Asy", "Sgm", "Bfield")}
BLUE = "#1f5fbf"
RED = "#c62828"
panels = [
("Bfield", r"Magnetic field $B$ (G)", "Magnetic field"),
("Sgm", r"Gaussian relaxation $\sigma$ (MHz)", "Gaussian relaxation"),
("Asy", r"Initial asymmetry $A_0$", "Initial asymmetry"),
]
fig, axes = plt.subplots(1, 3, figsize=(12.6, 3.9))
for ax, (stem, ylabel, title) in zip(axes, panels):
for data, color, label in (
(d1, BLUE, "3.8 K (superconducting)"),
(d2, RED, "10 K (normal state)"),
):
e, v, err = data[stem]
order = np.argsort(e)
e, v, err = e[order], v[order], err[order]
ax.errorbar(e, v, yerr=err, color=color, marker="o", ms=4.2,
lw=1.5, capsize=2.5, elinewidth=1.0, mec="white",
mew=0.5, label=label, zorder=3)
ax.set_xlabel("Implantation energy (keV)")
ax.set_ylabel(ylabel)
ax.set_title(title, fontsize=11)
ax.grid(True, color="0.85", lw=0.7)
ax.set_axisbelow(True)
for s in ("top", "right"):
ax.spines[s].set_visible(False)
axes[0].set_ylim(93.5, 101.5)
axes[1].set_ylim(0.36, 0.68)
axes[2].set_ylim(0.09, 0.235)
axes[0].legend(frameon=False, fontsize=9, loc="lower left")
fig.suptitle("LEM 2025 · 85 nm Nb/Al$_2$O$_3$ · Gaussian cosine fit · B ≈ 100 G",
fontsize=11.5, y=0.985)
fig.tight_layout(rect=(0, 0, 1, 0.95))
fig.savefig("lem2025_energy_scan.png", dpi=300)
fig.savefig("lem2025_energy_scan.svg")
print("wrote lem2025_energy_scan.png/.svg")