From 57b39273a4c1d7361c4afce52e68b4ed00dc1ab1 Mon Sep 17 00:00:00 2001 From: kim-mskw Date: Wed, 20 Nov 2024 11:12:48 +0100 Subject: [PATCH] - renaming of "set2 key to "PolicySet" to translate Amiris SupportPolicies --- assume/scenario/loader_amiris.py | 2 +- .../07_interoperability_example.ipynb | 109 ++---------------- 2 files changed, 13 insertions(+), 98 deletions(-) diff --git a/assume/scenario/loader_amiris.py b/assume/scenario/loader_amiris.py index e3d9b2d3..9b022d3c 100644 --- a/assume/scenario/loader_amiris.py +++ b/assume/scenario/loader_amiris.py @@ -154,7 +154,7 @@ def add_agent_to_world( match agent["Type"]: case "SupportPolicy": support_data = agent["Attributes"]["SetSupportData"] - supports |= {x.pop("Set"): x for x in support_data} + supports |= {x.pop("PolicySet"): x for x in support_data} world.add_unit_operator(agent["Id"]) for name, support in supports.items(): diff --git a/examples/notebooks/07_interoperability_example.ipynb b/examples/notebooks/07_interoperability_example.ipynb index 1572eddb..fa584422 100644 --- a/examples/notebooks/07_interoperability_example.ipynb +++ b/examples/notebooks/07_interoperability_example.ipynb @@ -41,7 +41,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -63,7 +63,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -80,7 +80,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -107,33 +107,13 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": { "vscode": { "languageId": "shellscript" } }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "INFO:assume.world:connected to db\n", - "INFO:assume.scenario.loader_csv:Starting Scenario example_01a/base from examples/inputs\n", - "ERROR:root:Simulation aborted\n", - "Traceback (most recent call last):\n", - " File \"C:\\Users\\tg3533\\Documents\\Code\\assume\\assume_cli\\cli.py\", line 152, in cli\n", - " load_scenario_folder(\n", - " File \"C:\\Users\\tg3533\\Documents\\Code\\assume\\assume\\scenario\\loader_csv.py\", line 773, in load_scenario_folder\n", - " scenario_data = load_config_and_create_forecaster(inputs_path, scenario, study_case)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"C:\\Users\\tg3533\\Documents\\Code\\assume\\assume\\scenario\\loader_csv.py\", line 429, in load_config_and_create_forecaster\n", - " with open(f\"{path}/config.yaml\") as f:\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - "FileNotFoundError: [Errno 2] No such file or directory: 'examples/inputs/example_01a/config.yaml'\n" - ] - } - ], + "outputs": [], "source": [ "if not IN_COLAB:\n", " !cd ../.. && assume -s example_01a -c base -db \"postgresql://assume:assume@localhost:5432/assume\"\n", @@ -161,26 +141,9 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "INFO:assume.world:connected to db\n", - "INFO:assume.world:activating container\n", - "INFO:assume.world:all agents up - starting simulation\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "world_script_simulation 2023-03-31 00:00:00: : 7689601.0it [00:13, 549334.81it/s] \n" - ] - } - ], + "outputs": [], "source": [ "import logging\n", "import os\n", @@ -291,15 +254,7 @@ "languageId": "shellscript" } }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "fatal: destination path 'amiris-examples' already exists and is not an empty directory.\n" - ] - } - ], + "outputs": [], "source": [ "!cd .. && git clone https://gitlab.com/dlr-ve/esy/amiris/examples.git amiris-examples" ] @@ -313,29 +268,9 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "INFO:assume.world:connected to db\n" - ] - }, - { - "ename": "KeyError", - "evalue": "'Output'", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mKeyError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[1;32mIn[9], line 18\u001b[0m\n\u001b[0;32m 15\u001b[0m db_uri \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mpostgresql://assume:assume@localhost:5432/assume\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 17\u001b[0m world \u001b[38;5;241m=\u001b[39m World(database_uri\u001b[38;5;241m=\u001b[39mdb_uri)\n\u001b[1;32m---> 18\u001b[0m \u001b[43mload_amiris\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 19\u001b[0m \u001b[43m \u001b[49m\u001b[43mworld\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 20\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mamiris\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[0;32m 21\u001b[0m \u001b[43m \u001b[49m\u001b[43mscenario\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlower\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 22\u001b[0m \u001b[43m \u001b[49m\u001b[43mbase_path\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 23\u001b[0m \u001b[43m)\u001b[49m\n\u001b[0;32m 24\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdid load \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mscenario\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m - now simulating\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 25\u001b[0m world\u001b[38;5;241m.\u001b[39mrun()\n", - "File \u001b[1;32m~\\Documents\\Code\\assume\\assume\\scenario\\loader_amiris.py:482\u001b[0m, in \u001b[0;36mload_amiris\u001b[1;34m(world, scenario, study_case, base_path)\u001b[0m\n\u001b[0;32m 480\u001b[0m end \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m timedelta(minutes\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m2\u001b[39m)\n\u001b[0;32m 481\u001b[0m sim_id \u001b[38;5;241m=\u001b[39m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mscenario\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mstudy_case\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m--> 482\u001b[0m save_interval \u001b[38;5;241m=\u001b[39m \u001b[43mamiris_scenario\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mGeneralProperties\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mOutput\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mInterval\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n\u001b[0;32m 483\u001b[0m prices \u001b[38;5;241m=\u001b[39m {}\n\u001b[0;32m 484\u001b[0m index \u001b[38;5;241m=\u001b[39m pd\u001b[38;5;241m.\u001b[39mdate_range(start\u001b[38;5;241m=\u001b[39mstart, end\u001b[38;5;241m=\u001b[39mend, freq\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m1h\u001b[39m\u001b[38;5;124m\"\u001b[39m, inclusive\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mleft\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", - "\u001b[1;31mKeyError\u001b[0m: 'Output'" - ] - } - ], + "outputs": [], "source": [ "from assume import World\n", "from assume.scenario.loader_amiris import load_amiris\n", @@ -382,29 +317,9 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "INFO:assume.world:connected to db\n", - "WARNING:pypsa.io:Importing network from PyPSA version v0.17.1 while current version is v0.30.3. Read the release notes at https://pypsa.readthedocs.io/en/latest/release_notes.html to prepare your network for import.\n", - "INFO:assume.scenario.loader_pypsa:loading scenario world_pypsa_ac_dc_meshed\n", - "INFO:assume.world:activating container\n", - "INFO:assume.common.outputs:tried writing grid data to non postGIS database\n", - "INFO:assume.world:all agents up - starting simulation\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "world_pypsa_ac_dc_meshed 2015-01-01 09:00:00: : 32401.0it [00:01, 30289.78it/s] \n" - ] - } - ], + "outputs": [], "source": [ "from collections import defaultdict\n", "from datetime import timedelta\n",