SPB Git
2.2 KB · 45 lines python
1#!/usr/bin/env python32"""Figure ch05 — surface de rente bicentrique simulée (courbes de niveau) : enveloppe de deux surfaces d'enchère3exponentielles (centre principal et sous-centre) au-dessus d'une rente agricole ; PARAMÈTRES PÉDAGOGIQUES DÉCLARÉS.4Sortie : assets/figures/ch05/ch05-fig-surface-rente.pdf"""5import sys, pathlib6ROOT = pathlib.Path(__file__).resolve().parents[3]7sys.path.insert(0, str(ROOT / "analysis/python"))8import numpy as np9import matplotlib.pyplot as plt10from traite.style import setup, palette, savefig, LARGEUR1112CENTRES = [  # (x, y, rente au centre $/m²/an, gradient exponentiel 1/km, nom)13    (0.0, 0.0, 80.0, 0.085, "Centre principal"),14    (13.0, 5.0, 36.0, 0.13, "Sous-centre"),15]16RA = 2.01718def surface(X, Y):19    r = np.full_like(X, RA)20    for cx, cy, r0, g, _ in CENTRES:21        d = np.hypot(X - cx, Y - cy)22        r = np.maximum(r, r0 * np.exp(-g * d))23    return r2425def main():26    setup()27    x = np.linspace(-22, 30, 420); y = np.linspace(-18, 22, 340)28    X, Y = np.meshgrid(x, y); R = surface(X, Y)29    fig, ax = plt.subplots(figsize=(LARGEUR, 3.9))30    niveaux = [2, 4, 6, 10, 15, 20, 30, 40, 55, 70]31    cf = ax.contourf(X, Y, R, levels=niveaux + [85], cmap=palette.cmap_seq(), alpha=0.95)32    cs = ax.contour(X, Y, R, levels=niveaux, colors=palette.ink, linewidths=0.5, alpha=0.6)33    ax.clabel(cs, fmt=lambda v: f"{v:.0f}", fontsize=6.5, colors=palette.ink, inline=True)34    for cx, cy, r0, g, nom in CENTRES:35        ax.plot(cx, cy, marker="*", ms=9, color=palette.ink, mec=palette.surface)36        ax.annotate(f"{nom}\n$r_0$ = {r0:.0f} \\$/m²/an, $\\gamma$ = {g:.3f}/km", (cx, cy), xytext=(8, -26) if cx == 0 else (-118, 14), textcoords="offset points", fontsize=7, color=palette.ink)37    cb = fig.colorbar(cf, ax=ax, pad=0.02, shrink=0.9); cb.set_label("Rente foncière ($/m² de terrain/an)")38    ax.set_aspect("equal"); ax.set_xlabel("km (est-ouest)"); ax.set_ylabel("km (nord-sud)")39    ax.grid(False)40    ax.set_title("Enveloppe de deux surfaces d'enchère exponentielles au-dessus de la rente agricole (2 $/m²/an)", loc="left", fontsize=8.5)41    out = savefig(fig, "ch05/ch05-fig-surface-rente.pdf"); print("OK", out)4243if __name__ == "__main__":44    main()45
Files · 87c44d2be896891b2c9c8e7fa2e8f7fe990e491b
Menu

Theme