OEP Client Tutorial 01 - Download data from the Open Energy Platform using the OEP Client in a python script¶
Learnings¶
This tutorials will enable you to:
Requirements¶
- Python packages:
oep-client>=0.14
(installs also the command line tool)- jupyter notebook, e.g.
notebook
orjupyterlab
- Skills:
- use python with jupyter notebooks
Feedback¶
You can provide feedback on this tutorial here: https://github.com/OpenEnergyPlatform/academy/issues/235
Setup¶
In [1]:
Copied!
# install required packages with: pip install "oep-client>=0.17"
# import required packages
import json
from oep_client import OepClient
cli = OepClient()
table = "tutorial_example_table"
# install required packages with: pip install "oep-client>=0.17"
# import required packages
import json
from oep_client import OepClient
cli = OepClient()
table = "tutorial_example_table"
In [2]:
Copied!
data = cli.select_from_table(table)
# show results in notebook
print(json.dumps(data, indent=4))
data = cli.select_from_table(table)
# show results in notebook
print(json.dumps(data, indent=4))
[ { "id": 1, "name": "unit1", "is_active": true, "capacity_mw": 1.2, "installation_datetime_utc": "2010-02-03T00:00:00", "location": "01010000008FC2F5285C8F4A40713D0AD7A3B02040" }, { "id": 2, "name": "unit2", "is_active": false, "capacity_mw": 2.1, "installation_datetime_utc": "2010-01-08T00:00:00", "location": null }, { "id": 3, "name": "unit3", "is_active": true, "capacity_mw": 100.0, "installation_datetime_utc": "2010-01-02T10:30:00", "location": "0101000000EC51B81E85AB4B405C8FC2F5285C1D40" } ]
In [3]:
Copied!
data = cli.select_from_table(table, where=["is_active=true", "capacity_mw>10"])
# show results in notebook
print(json.dumps(data, indent=4))
data = cli.select_from_table(table, where=["is_active=true", "capacity_mw>10"])
# show results in notebook
print(json.dumps(data, indent=4))
[ { "id": 3, "name": "unit3", "is_active": true, "capacity_mw": 100.0, "installation_datetime_utc": "2010-01-02T10:30:00", "location": "0101000000EC51B81E85AB4B405C8FC2F5285C1D40" } ]
In [4]:
Copied!
metadata = cli.get_metadata(table)
# show results in notebook
print(json.dumps(metadata, indent=4))
metadata = cli.get_metadata(table)
# show results in notebook
print(json.dumps(metadata, indent=4))
{ "id": "test_table", "keywords": [ "energy", "installations", "geo" ], "resources": [ { "name": "test_table", "schema": { "foreignKeys": [], "fields": [ { "name": "id", "description": "numerical id of this data point", "type": "integer" }, { "name": "name", "description": "name of installation", "type": "string" }, { "name": "is_active", "description": "true/false if installation is active", "type": "boolean" }, { "name": "capacity_mw", "description": "installed capacity in MW", "type": "number" }, { "name": "installation_datetime_utc", "description": "date (and time) when installation was build", "type": "string" }, { "name": "location", "description": "point location of installation", "type": "geojson" } ] } } ], "metaMetadata": { "metadataVersion": "OEP-1.5.2", "metadataLicense": { "name": "CC0-1.0", "title": "Creative Commons Zero v1.0 Universal", "path": "https://creativecommons.org/publicdomain/zero/1.0/" } }, "_comment": { "metadata": "Metadata documentation and explanation (https://github.com/OpenEnergyPlatform/oemetadata)", "dates": "Dates and time must follow the ISO8601 including time zone (YYYY-MM-DD or YYYY-MM-DDThh:mm:ss\u00b1hh)", "units": "Use a space between numbers and units (100 m)", "languages": "Languages must follow the IETF (BCP47) format (en-GB, en-US, de-DE)", "licenses": "License name must follow the SPDX License List (https://spdx.org/licenses/)", "review": "Following the OEP Data Review (https://github.com/OpenEnergyPlatform/data-preprocessing/blob/master/data-review/manual/review_manual.md)", "null": "If not applicable use: null", "todo": "If a value is not yet available, use: todo" } }
About this tutorial¶
- Author: Christian Winger
- Copyright: Öko-Institut (2024)
- License: CC BY 4.0
- Attribution: Öko-Institut (2024): OEP Client Tutorial 01 - Download data from the Open Energy Platform using the OEP Client in a python script
- Last update 2024-09-26