Results & Visualization¶
Overview¶
After solving, the model produces results in several formats:
PyPSA network (
results/{name}/solved/model_scen-{scenario}.nc): Complete optimization results in NetCDF formatAnalysis outputs (
results/{name}/analysis/scen-{scenario}/*.csv): Extracted statistics and impact assessments (see Analysis)Visualizations (
results/{name}/plots/scen-{scenario}/*.pdf): Publication-quality plots and maps
The various output files are structured as follows:
results/{name}/
├── build/
│ └── model_scen-{scenario}.nc # Built model before solving
├── solved/
│ └── model_scen-{scenario}.nc # Solved model with optimal values
├── analysis/
│ └── scen-{scenario}/
│ ├── crop_production.csv # Production by crop/region
│ ├── land_use.csv # Land allocation
│ ├── animal_production.csv # Livestock production
│ ├── food_consumption.csv # Consumption by food
│ ├── food_group_consumption.csv # Consumption by food group
│ ├── ghg_attribution.csv # Consumption-attributed GHG intensity by food
│ ├── ghg_attribution_totals.csv # Total attributed GHG by country/food group
│ ├── net_emissions.csv # Net GHG emissions by gas
│ ├── health_marginals.csv # Marginal health impacts by food group
│ ├── health_totals.csv # Total YLL by health cluster
│ └── objective_breakdown.csv # Cost categories breakdown
└── plots/
└── scen-{scenario}/
└── *.pdf # Visualizations
PyPSA Network Results¶
The solved network (results/{name}/solved/model_scen-{scenario}.nc) is a PyPSA Network whose components can be inspected as follows (for example):
import pypsa
n = pypsa.Network("results/my_scenario/solved/model_scen-default.nc")
# Access component data
links_df = n.links # All links (production, processing, trade)
buses_df = n.buses # All buses (crops, foods, nutrients, land)
stores_df = n.stores # Resource availability (land, water)
# Optimal flows
link_flows = n.links_t.p0 # Power/flow on each link (time series if multi-period)
# Shadow prices (marginal costs)
bus_prices = n.buses_t.marginal_price # Marginal value of each commodity
Key Data Structures¶
- n.links
Production, processing, and trade links with optimal flows. Columns:
bus0,bus1,bus2, …: Connected busesp_nom_opt: Optimal capacityp0: Flow balance atbus0(withdrawing or adding material)efficiency,efficiency2, …: Conversion factors relative to withdrawal frombus0marginal_cost: Cost per unit flow relative tobus0
- n.buses
Commodity buses (crops, foods, nutrients) with prices. Columns:
carrier: Commodity type (e.g.,crop_wheat,nutrient_protein)marginal_price: Shadow price (USD/unit) — economic value of one more unit
- n.stores
Resource stores (land, water, fertilizer) with usage. Columns:
e_nom: Total capacity (Mha for land, Mm³ for water, Mt for fertilizer)e_initial: Available amounte: Amount used or deposited (after solving)
- n.global_constraints
System-wide limits (total fertilizer, emissions caps, nutritional requirements).