SPB Git
2.1 KB · 39 lines python
1#!/usr/bin/env python32"""Figure ch44 — flux annuels des deux mesures énergétiques du sujet du cas 1 (DONNÉES SYNTHÉTIQUES, hypothèses déclarées3dans analysis/python/cases/ch44_renovation.py) : coût net à t = 0, économies annuelles croissantes et cumul actualisé.4Sortie : assets/figures/ch44/ch44-fig-flux.pdf"""5import sys, pathlib6ROOT = pathlib.Path(__file__).resolve().parents[3]7sys.path.insert(0, str(ROOT / "analysis/python")); sys.path.insert(0, str(ROOT / "analysis/python/cases"))8import numpy as np, matplotlib.pyplot as plt9from traite.style import setup, palette, savefig, LARGEUR, fmt_dollars10import ch44_renovation as cas111213def panneau(ax, fl, titre, couleur):14    t = np.arange(len(fl["flux"]))15    ax.bar(t[0], fl["flux"][0], color=palette.ink2, width=0.8, label="Coût net (t = 0)")16    ax.bar(t[1:], fl["flux"][1:], color=couleur, width=0.8, label="Économie annuelle")17    ax.plot(t, fl["cumul_actualise"], color=palette.ink, lw=1.4, ls="--", marker="o", ms=2.5, label="Cumul actualisé")18    ax.axhline(0, color=palette.ink2, lw=0.6)19    ax.set_title(titre, loc="left", fontsize=9)20    ax.set_xlabel("Année"); ax.yaxis.set_major_formatter(plt.FuncFormatter(fmt_dollars))21    ax.annotate(f"VAN {fmt_dollars(fl['van'])}".replace("-", "−"), xy=(t[-1], fl["cumul_actualise"][-1]), xytext=(4, -22 if fl["van"] < 0 else 10),22                textcoords="offset points", ha="right", va="top" if fl["van"] < 0 else "bottom", fontsize=8, color=palette.ink)232425def main():26    setup()27    mm = cas.mesures()28    fa, fb = cas.flux_mesure(mm["A"]), cas.flux_mesure(mm["B"])29    fig, (a, b) = plt.subplots(1, 2, figsize=(LARGEUR, 3.2), gridspec_kw={"wspace": 0.32, "width_ratios": [1, 1.35]})30    panneau(a, fa, "(a) Thermopompe climat froid (15 ans)", palette.cat[0])31    panneau(b, fb, "(b) Isolation de l'entretoit (31 ans)", palette.cat[1])32    a.set_ylim(-13500, 2500); b.set_ylim(-2600, 600)33    h, l = a.get_legend_handles_labels(); fig.legend(h, l, loc="lower center", ncol=3, bbox_to_anchor=(0.5, -0.08), frameon=False)34    out = savefig(fig, "ch44/ch44-fig-flux.pdf"); print("OK", out)353637if __name__ == "__main__":38    main()39
Files · ae9e02e7cd803a16ec66687feb5b5de2a15d673f
Menu

Theme