from pathlib import Path

import matplotlib.pyplot as plt
import numpy as np
from tqdm import tqdm


if __name__ == '__main__':
    
    all_mu = Path("22-05-13-LPS-no-POTCAR").rglob("mu.dat")

    fig, ax = plt.subplots(1, 1, figsize=(3, 2))

    for path in tqdm(list(all_mu)):
        X = np.loadtxt(path)
        x = X[:, 0]
        y = X[:, 1:].sum(axis=1)
        assert (y > 0.0).sum() / len(y) > 0.8  # Sanity check
        ax.plot(x, y, alpha=0.1)

    plt.savefig("test_plot.pdf", bbox_inches="tight", dpi=300)
