{ "cells": [ { "cell_type": "markdown", "id": "7659bd4fd436", "metadata": {}, "source": [ "# EnergyDataModel — Quickstart\n", "\n", "Describe an energy portfolio — assets, sites, areas, the lines that connect them — as plain Python objects. Time series stay with the asset, geometry is Shapely, and every element carries a stable UUID that rides through JSON. One expression to declare it, one line to save it, one subclass to extend it." ] }, { "cell_type": "markdown", "id": "190bcf8ab1f2", "metadata": {}, "source": [ "## 1. Setup\n", "\n", "Pure Python — `pip install` and import. Runs locally or on Colab." ] }, { "cell_type": "code", "execution_count": 1, "id": "1967d749600f", "metadata": { "execution": { "iopub.execute_input": "2026-05-06T10:58:07.574636Z", "iopub.status.busy": "2026-05-06T10:58:07.574495Z", "iopub.status.idle": "2026-05-06T10:58:07.578374Z", "shell.execute_reply": "2026-05-06T10:58:07.577825Z" } }, "outputs": [], "source": [ "try:\n", " import google.colab # noqa: F401\n", "\n", " !pip install -q energydatamodel\n", "except ImportError:\n", " pass" ] }, { "cell_type": "code", "execution_count": 2, "id": "1747be5604bc", "metadata": { "execution": { "iopub.execute_input": "2026-05-06T10:58:07.580060Z", "iopub.status.busy": "2026-05-06T10:58:07.579928Z", "iopub.status.idle": "2026-05-06T10:58:08.424047Z", "shell.execute_reply": "2026-05-06T10:58:08.423525Z" } }, "outputs": [], "source": [ "import json\n", "\n", "import energydatamodel as edm\n", "from shapely.geometry import Polygon" ] }, { "cell_type": "markdown", "id": "d3cd3729f827", "metadata": {}, "source": [ "## 2. Declare your portfolio\n", "\n", "A `Portfolio` is a Python expression: sites, wind farms, turbines, PV systems, batteries — each a typed dataclass with the domain fields you'd expect. `members=[...]` nests them; `lat=` / `lon=` places them. No YAML. No schema files." ] }, { "cell_type": "code", "execution_count": 3, "id": "c8e1a6298602", "metadata": { "execution": { "iopub.execute_input": "2026-05-06T10:58:08.425910Z", "iopub.status.busy": "2026-05-06T10:58:08.425572Z", "iopub.status.idle": "2026-05-06T10:58:08.430821Z", "shell.execute_reply": "2026-05-06T10:58:08.430249Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Portfolio('Nordic')\n", "├── Site('Lillgrund')\n", "│ └── WindFarm('Lillgrund-WF')\n", "│ ├── WindTurbine('T01')\n", "│ └── WindTurbine('T02')\n", "└── Site('Stockholm-Rooftop')\n", " ├── PVSystem('PV-01')\n", " │ └── PVArray()\n", " └── Battery('B-01')\n" ] } ], "source": [ "portfolio = edm.Portfolio(\n", " name=\"Nordic\",\n", " members=[\n", " edm.Site(\n", " name=\"Lillgrund\",\n", " lat=55.51,\n", " lon=12.78,\n", " members=[\n", " edm.wind.WindFarm(\n", " name=\"Lillgrund-WF\",\n", " capacity=110,\n", " members=[\n", " edm.wind.WindTurbine(name=\"T01\", capacity=2.3, hub_height=68.5, lat=55.510, lon=12.780),\n", " edm.wind.WindTurbine(name=\"T02\", capacity=2.3, hub_height=68.5, lat=55.515, lon=12.790),\n", " ],\n", " ),\n", " ],\n", " ),\n", " edm.Site(\n", " name=\"Stockholm-Rooftop\",\n", " lat=59.33,\n", " lon=18.07,\n", " members=[\n", " edm.solar.PVSystem(\n", " name=\"PV-01\",\n", " capacity=12.0,\n", " surface_tilt=25,\n", " surface_azimuth=180,\n", " members=[edm.solar.PVArray(capacity=12.0, surface_tilt=25, surface_azimuth=180)],\n", " ),\n", " edm.battery.Battery(name=\"B-01\", storage_capacity=20, max_charge=10, max_discharge=10),\n", " ],\n", " ),\n", " ],\n", ")\n", "\n", "print(portfolio.to_tree())" ] }, { "cell_type": "markdown", "id": "33e4ce050cea", "metadata": {}, "source": [ "## 3. Time series in plain English\n", "\n", "Attach metadata-only `TimeSeries` declarations with the energy vocabulary — `electricity_supply`, `electricity_demand`, `spot_price`, `cross_border_flow`, `grid_frequency`, ... Each carries unit, data type (actual / forecast / capacity / ...), and optional frequency. They stay with the asset and ride through JSON." ] }, { "cell_type": "code", "execution_count": 4, "id": "73867bf6add5", "metadata": { "execution": { "iopub.execute_input": "2026-05-06T10:58:08.432840Z", "iopub.status.busy": "2026-05-06T10:58:08.432638Z", "iopub.status.idle": "2026-05-06T10:58:08.440933Z", "shell.execute_reply": "2026-05-06T10:58:08.440166Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "