diff --git a/dev/Untitled.ipynb b/dev/Untitled.ipynb index a601c5ce..88eb49ba 100644 --- a/dev/Untitled.ipynb +++ b/dev/Untitled.ipynb @@ -5227,7 +5227,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.11.8" } }, "nbformat": 4, diff --git a/dev/test_consequential.ipynb b/dev/test_consequential.ipynb index b10cb7c6..6ffa34c6 100644 --- a/dev/test_consequential.ipynb +++ b/dev/test_consequential.ipynb @@ -9,7 +9,7 @@ "source": [ "import brightway2 as bw\n", "from premise import *\n", - "bw.projects.set_current(\"ei310\")" + "bw.projects.set_current(\"ecoinvent-3.10-consequential\")" ] }, { @@ -44,7 +44,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "1e6ebbae-2743-4e76-ab3d-e7a5dd873539", "metadata": {}, "outputs": [ @@ -52,7 +52,28 @@ "name": "stdout", "output_type": "stream", "text": [ - "premise v.(2, 1, 1, 'dev0')\n", + "Cache folder cleared!\n", + "premise requires the name of your biosphere database.\n", + "Please enter the name of your biosphere database as it appears in your project.\n", + "Databases dictionary with 4 object(s):\n", + "\tecoinvent-3.10-biosphere\n", + "\tecoinvent-3.10-consequential\n", + "\ttest1\n", + "\ttest2\n" + ] + }, + { + "name": "stdin", + "output_type": "stream", + "text": [ + "Name of the biosphere database: ecoinvent-3.10-biosphere\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "premise v.(2, 1, 2)\n", "+------------------------------------------------------------------+\n", "| Warning |\n", "+------------------------------------------------------------------+\n", @@ -82,10 +103,7 @@ "| ndb.generate_scenario_report() | important scenarios' variables. |\n", "+--------------------------------+----------------------------------+\n", "Keep uncertainty data?\n", - "NewDatabase(..., keep_uncertainty_data=True)\n", - "\n", - "Disable multiprocessing?\n", - "NewDatabase(..., use_multiprocessing=False)\n", + "NewDatabase(..., keep_source_db_uncertainty=True), keep_imports_uncertainty=True)\n", "\n", "Hide these messages?\n", "NewDatabase(..., quiet=True)\n", @@ -98,7 +116,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "100%|███████████████████████████████████████████████████████████████████████████████████████████████| 20772/20772 [00:00<00:00, 380432.91it/s]\n" + "100%|█████████████████████████████████████████████████████████████████████████| 20772/20772 [00:00<00:00, 121485.03it/s]\n" ] }, { @@ -112,7 +130,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "100%|██████████████████████████████████████████████████████████████████████████████████████████████| 610085/610085 [00:20<00:00, 30228.62it/s]\n" + "100%|████████████████████████████████████████████████████████████████████████| 610085/610085 [00:21<00:00, 29044.81it/s]\n" ] }, { @@ -126,7 +144,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "100%|████████████████████████████████████████████████████████████████████████████████████████████████| 20772/20772 [00:01<00:00, 11200.08it/s]\n" + "100%|██████████████████████████████████████████████████████████████████████████| 20772/20772 [00:01<00:00, 10814.53it/s]\n" ] }, { @@ -170,12 +188,7 @@ "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "Extracted 1 worksheets in 0.01 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", + "Extracted 1 worksheets in 0.02 seconds\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", @@ -188,125 +201,55 @@ "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "Extracted 1 worksheets in 0.01 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", + "Extracted 4 worksheets in 0.17 seconds\n", + "Remove uncertainty data.\n", + "Extracted 1 worksheets in 0.02 seconds\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "List of unlinked exchanges:\n", - "+-------------------------------------------------------+-------------------+----------+------------+----------+--------------+-----------------------+\n", - "| Name | Reference product | Location | Categories | Unit | Type | File |\n", - "+-------------------------------------------------------+-------------------+----------+------------+----------+--------------+-----------------------+\n", - "| industrial gases production, cryogenic air separation | nitrogen, liquid | RoW | None | kilogram | technosphere | lci-carbon-fiber.xlsx |\n", - "+-------------------------------------------------------+-------------------+----------+------------+----------+--------------+-----------------------+\n", "Extracted 7 worksheets in 0.03 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "List of unlinked exchanges:\n", - "+------------------------------------------------------------+-------------------------------------------------+----------+------------+----------+--------------+------------------+\n", - "| Name | Reference product | Location | Categories | Unit | Type | File |\n", - "+------------------------------------------------------------+-------------------------------------------------+----------+------------+----------+--------------+------------------+\n", - "| market for neutralising agent, sodium hydroxide-equivalent | neutralising agent, sodium hydroxide-equivalent | GLO | None | kilogram | technosphere | lci-lithium.xlsx |\n", - "+------------------------------------------------------------+-------------------------------------------------+----------+------------+----------+--------------+------------------+\n", "Extracted 1 worksheets in 0.02 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", "Extracted 1 worksheets in 0.01 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "List of unlinked exchanges:\n", - "+-----------------+-------------------+----------+------------+-----------+--------------+-------------------+\n", - "| Name | Reference product | Location | Categories | Unit | Type | File |\n", - "+-----------------+-------------------+----------+------------+-----------+--------------+-------------------+\n", - "| coke production | coal gas | RoW | None | megajoule | technosphere | lci-graphite.xlsx |\n", - "+-----------------+-------------------+----------+------------+-----------+--------------+-------------------+\n", - "Extracted 1 worksheets in 0.02 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", + "Extracted 1 worksheets in 0.03 seconds\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", "Extracted 1 worksheets in 0.03 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", "Extracted 1 worksheets in 0.02 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", "Extracted 1 worksheets in 0.03 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Could not find a biosphere flow for ('Iron, 72% in magnetite, 14% in crude ore', 'natural resource', 'in ground', 'kilogram') in /Users/romain/GitHub/premise/premise/data/additional_inventories/lci-vanadium.xlsx. Exchange deleted.\n", - "Could not find a biosphere flow for ('TiO2, 54% in ilmenite, 18% in crude ore, in ground', 'natural resource', 'in ground', 'kilogram') in /Users/romain/GitHub/premise/premise/data/additional_inventories/lci-vanadium.xlsx. Exchange deleted.\n", "Remove uncertainty data.\n", - "List of unlinked exchanges:\n", - "+-----------------------------------------------------------+---------------------------+----------+------------+-----------+--------------+-------------------+\n", - "| Name | Reference product | Location | Categories | Unit | Type | File |\n", - "+-----------------------------------------------------------+---------------------------+----------+------------+-----------+--------------+-------------------+\n", - "| hydrochloric acid production, Mannheim process | sodium sulfate, anhydrite | RER | None | kilogram | technosphere | lci-vanadium.xlsx |\n", - "| vanadium-titanomagnetite mine operation and beneficiation | iron ore concentrate | CN | None | kilogram | technosphere | lci-vanadium.xlsx |\n", - "| industrial gases production, cryogenic air separation | nitrogen, liquid | RoW | None | kilogram | technosphere | lci-vanadium.xlsx |\n", - "| blast furnace gas, Recycled Content cut-off | blast furnace gas | GLO | None | megajoule | technosphere | lci-vanadium.xlsx |\n", - "| blast furnace slag, Recycled Content cut-off | blast furnace slag | GLO | None | kilogram | technosphere | lci-vanadium.xlsx |\n", - "+-----------------------------------------------------------+---------------------------+----------+------------+-----------+--------------+-------------------+\n", - "Extracted 1 worksheets in 0.01 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", + "Extracted 1 worksheets in 0.02 seconds\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", + "Remove uncertainty data.\n", + "Extracted 1 worksheets in 0.02 seconds\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "List of unlinked exchanges:\n", - "+-------------------------------------------------------+-------------------+----------+------------+----------+--------------+------------------------+\n", - "| Name | Reference product | Location | Categories | Unit | Type | File |\n", - "+-------------------------------------------------------+-------------------+----------+------------+----------+--------------+------------------------+\n", - "| industrial gases production, cryogenic air separation | nitrogen, liquid | RoW | None | kilogram | technosphere | lci-batteries-SIB.xlsx |\n", - "+-------------------------------------------------------+-------------------+----------+------------+----------+--------------+------------------------+\n", + "Extracted 2 worksheets in 0.02 seconds\n", + "Remove uncertainty data.\n", "Extracted 1 worksheets in 0.01 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "Extracted 1 worksheets in 0.36 seconds\n", + "Extracted 1 worksheets in 0.31 seconds\n", "Migrating to 3.8 first\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", @@ -336,39 +279,19 @@ "| vinyl fluoride production | vinyl fluoride | US | lci-PV.xlsx |\n", "| wafer factory construction | wafer factory | DE | lci-PV.xlsx |\n", "+--------------------------------+--------------------------------+----------+-------------+\n", - "List of unlinked exchanges:\n", - "+----------------------------------------------------------------+-------------------------------------------------------------+----------+------------+---------------+--------------+-------------+\n", - "| Name | Reference product | Location | Categories | Unit | Type | File |\n", - "+----------------------------------------------------------------+-------------------------------------------------------------+----------+------------+---------------+--------------+-------------+\n", - "| treatment of municipal solid waste, municipal incineration FAE | heat, for reuse in municipal waste incineration only | CH | None | megajoule | technosphere | lci-PV.xlsx |\n", - "| phenol production, cumene oxidation | acetone, liquid | RER | None | kilogram | technosphere | lci-PV.xlsx |\n", - "| industrial gases production, cryogenic air separation | nitrogen, liquid | RoW | None | kilogram | technosphere | lci-PV.xlsx |\n", - "| treatment of municipal solid waste, municipal incineration FAE | electricity, for reuse in municipal waste incineration only | CH | None | kilowatt hour | technosphere | lci-PV.xlsx |\n", - "+----------------------------------------------------------------+-------------------------------------------------------------+----------+------------+---------------+--------------+-------------+\n", - "Extracted 1 worksheets in 0.04 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", + "Extracted 1 worksheets in 0.02 seconds\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", + "Remove uncertainty data.\n", + "Extracted 1 worksheets in 0.04 seconds\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", "Extracted 1 worksheets in 0.01 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", "Extracted 1 worksheets in 0.02 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", @@ -430,7 +353,7 @@ "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "Extracted 1 worksheets in 0.01 seconds\n", + "Extracted 1 worksheets in 0.02 seconds\n", "Migrating to 3.8 first\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", @@ -481,21 +404,11 @@ "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "Extracted 1 worksheets in 0.01 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", + "Extracted 1 worksheets in 0.00 seconds\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", "Extracted 1 worksheets in 0.01 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", @@ -514,6 +427,10 @@ "+--------------------------------+--------------------------------+----------+--------------------------------+\n", "| methanol production facility, | methanol production facility, | RER | lci-synfuels-from-methanol-fro |\n", "+--------------------------------+--------------------------------+----------+--------------------------------+\n", + "Extracted 1 worksheets in 0.02 seconds\n", + "Applying strategy: migrate_datasets\n", + "Applying strategy: migrate_exchanges\n", + "Remove uncertainty data.\n", "Extracted 1 worksheets in 0.01 seconds\n", "Migrating to 3.8 first\n", "Applying strategy: migrate_datasets\n", @@ -595,105 +512,45 @@ "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "Extracted 1 worksheets in 0.00 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", + "Extracted 1 worksheets in 0.01 seconds\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", "Extracted 1 worksheets in 0.07 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", "Extracted 1 worksheets in 0.01 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", "Extracted 1 worksheets in 0.01 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", "Extracted 1 worksheets in 0.02 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", "Extracted 1 worksheets in 0.01 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Remove uncertainty data.\n", - "Extracted 1 worksheets in 0.02 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", "Extracted 1 worksheets in 0.01 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", "Extracted 1 worksheets in 0.01 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", "Extracted 1 worksheets in 0.04 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", "Extracted 1 worksheets in 0.01 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", - "Remove uncertainty data.\n", - "Extracted 1 worksheets in 0.01 seconds\n", - "Migrating to 3.8 first\n", - "Applying strategy: migrate_datasets\n", - "Applying strategy: migrate_exchanges\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "Extracted 39 worksheets in 0.35 seconds\n", + "Extracted 19 worksheets in 1.40 seconds\n", "Migrating to 3.8 first\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", @@ -702,7 +559,7 @@ "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "Extracted 1 worksheets in 0.20 seconds\n", + "Extracted 1 worksheets in 0.21 seconds\n", "Migrating to 3.8 first\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", @@ -720,7 +577,7 @@ "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "Extracted 1 worksheets in 0.79 seconds\n", + "Extracted 1 worksheets in 0.92 seconds\n", "Migrating to 3.8 first\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", @@ -729,6 +586,14 @@ "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", + "Extracted 1 worksheets in 0.03 seconds\n", + "Applying strategy: migrate_datasets\n", + "Applying strategy: migrate_exchanges\n", + "Remove uncertainty data.\n", + "Extracted 1 worksheets in 0.02 seconds\n", + "Remove uncertainty data.\n", + "Extracted 1 worksheets in 0.02 seconds\n", + "Remove uncertainty data.\n", "Data cached. It is advised to restart your workflow at this point.\n", "This allows premise to use the cached data instead, which results in\n", "a faster workflow.\n", @@ -738,200 +603,169 @@ "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", "| Region | Measurement method | Foresight? | Duration | Avg. start year | Avg. end year | Avg. capital repl. rate | Volume change |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| CAZ | 0 | False | False | 2031 | 2035 | -0.01 | 0.11 |\n", + "| CAZ | 0 | False | False | 2031 | 2035 | -0.01 | 0.15 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| CHA | 0 | False | False | 2031 | 2035 | -0.02 | 1.79 |\n", + "| CHA | 0 | False | False | 2030 | 2034 | -0.02 | 2.0 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| EUR | 0 | False | False | 2031 | 2035 | -0.02 | 0.46 |\n", + "| EUR | 0 | False | False | 2031 | 2035 | -0.03 | 0.64 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| IND | 0 | False | False | 2031 | 2035 | -0.03 | 0.73 |\n", + "| IND | 0 | False | False | 2031 | 2035 | -0.03 | 0.85 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| JPN | 0 | False | False | 2031 | 2035 | -0.02 | 0.01 |\n", + "| JPN | 0 | False | False | 2031 | 2035 | -0.02 | 0.07 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| LAM | 0 | False | False | 2031 | 2035 | -0.01 | 0.62 |\n", + "| LAM | 0 | False | False | 2030 | 2034 | -0.02 | 0.73 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| MEA | 0 | False | False | 2030 | 2034 | -0.03 | 0.52 |\n", + "| MEA | 0 | False | False | 2030 | 2034 | -0.03 | 0.42 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| NEU | 0 | False | False | 2031 | 2035 | -0.01 | 0.09 |\n", + "| NEU | 0 | False | False | 2031 | 2035 | -0.01 | 0.14 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| OAS | 0 | False | False | 2030 | 2034 | -0.02 | 0.82 |\n", + "| OAS | 0 | False | False | 2030 | 2034 | -0.02 | 0.85 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| REF | 0 | False | False | 2031 | 2035 | -0.02 | 0.2 |\n", + "| REF | 0 | False | False | 2031 | 2035 | -0.02 | 0.32 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| SSA | 0 | False | False | 2031 | 2035 | -0.02 | 0.44 |\n", + "| SSA | 0 | False | False | 2030 | 2034 | -0.02 | 0.42 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| USA | 0 | False | False | 2030 | 2034 | -0.03 | 0.56 |\n", + "| USA | 0 | False | False | 2030 | 2034 | -0.03 | 0.62 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| World | 0 | False | False | 2031 | 2035 | -0.02 | 6.4 |\n", + "| World | 0 | False | False | 2031 | 2035 | -0.02 | 7.66 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", "\n", "Summary of the petrol marginal market mixes:\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", "| Region | Measurement method | Foresight? | Duration | Avg. start year | Avg. end year | Avg. capital repl. rate | Volume change |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| CAZ | 0 | False | False | 2030 | 2034 | -0.03 | -0.03 |\n", + "| CAZ | 0 | False | False | 2030 | 2034 | -0.03 | -0.05 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| CHA | 0 | False | False | 2030 | 2034 | -0.03 | 0.02 |\n", + "| CHA | 0 | False | False | 2031 | 2035 | -0.03 | -0.03 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| EUR | 0 | False | False | 2031 | 2035 | -0.03 | -0.12 |\n", + "| EUR | 0 | False | False | 2031 | 2035 | -0.03 | -0.15 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| IND | 0 | False | False | 2031 | 2035 | -0.03 | 0.03 |\n", + "| IND | 0 | False | False | 2031 | 2035 | -0.03 | -0.06 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| JPN | 0 | False | False | 2031 | 2035 | -0.03 | 0.0 |\n", + "| JPN | 0 | False | False | 2031 | 2035 | -0.03 | 0.01 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| LAM | 0 | False | False | 2031 | 2035 | -0.03 | 0.08 |\n", + "| LAM | 0 | False | False | 2031 | 2035 | -0.03 | -0.07 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| MEA | 0 | False | False | 2030 | 2034 | -0.03 | -0.01 |\n", + "| MEA | 0 | False | False | 2031 | 2035 | -0.03 | -0.03 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| NEU | 0 | False | False | 2031 | 2035 | -0.03 | 0.0 |\n", + "| NEU | 0 | False | False | 2031 | 2035 | -0.03 | -0.0 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| OAS | 0 | False | False | 2031 | 2035 | -0.03 | -0.07 |\n", + "| OAS | 0 | False | False | 2031 | 2035 | -0.03 | -0.11 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", "| REF | 0 | False | False | 2031 | 2035 | -0.03 | -0.01 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| SSA | 0 | False | False | 2031 | 2035 | -0.03 | 0.11 |\n", + "| SSA | 0 | False | False | 2031 | 2035 | -0.03 | 0.02 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| USA | 0 | False | False | 2031 | 2035 | -0.03 | 0.1 |\n", + "| USA | 0 | False | False | 2031 | 2035 | -0.03 | 0.18 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| World | 0 | False | False | 2031 | 2035 | -0.03 | -0.14 |\n", + "| World | 0 | False | False | 2030 | 2034 | -0.03 | -0.59 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", "\n", "Summary of the diesel marginal market mixes:\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", "| Region | Measurement method | Foresight? | Duration | Avg. start year | Avg. end year | Avg. capital repl. rate | Volume change |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| CAZ | 0 | False | False | 2031 | 2035 | -0.03 | -0.14 |\n", + "| CAZ | 0 | False | False | 2031 | 2035 | -0.03 | -0.16 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| CHA | 0 | False | False | 2030 | 2034 | -0.03 | 0.0 |\n", + "| CHA | 0 | False | False | 2031 | 2035 | -0.03 | -0.08 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| EUR | 0 | False | False | 2031 | 2035 | -0.03 | -0.23 |\n", + "| EUR | 0 | False | False | 2031 | 2035 | -0.03 | -0.32 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| IND | 0 | False | False | 2030 | 2034 | -0.03 | 0.09 |\n", + "| IND | 0 | False | False | 2031 | 2035 | -0.03 | -0.08 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| JPN | 0 | False | False | 2031 | 2035 | -0.03 | -0.04 |\n", + "| JPN | 0 | False | False | 2030 | 2034 | -0.03 | -0.05 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| LAM | 0 | False | False | 2030 | 2034 | -0.03 | -0.05 |\n", + "| LAM | 0 | False | False | 2031 | 2035 | -0.03 | -0.1 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| MEA | 0 | False | False | 2031 | 2035 | -0.03 | -0.09 |\n", + "| MEA | 0 | False | False | 2031 | 2035 | -0.03 | -0.14 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| NEU | 0 | False | False | 2031 | 2035 | -0.03 | -0.01 |\n", + "| NEU | 0 | False | False | 2030 | 2034 | -0.03 | -0.02 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| OAS | 0 | False | False | 2031 | 2035 | -0.03 | -0.09 |\n", + "| OAS | 0 | False | False | 2031 | 2035 | -0.03 | -0.15 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| REF | 0 | False | False | 2031 | 2035 | -0.03 | -0.1 |\n", + "| REF | 0 | False | False | 2031 | 2035 | -0.03 | -0.11 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| SSA | 0 | False | False | 2030 | 2034 | -0.03 | 0.11 |\n", + "| SSA | 0 | False | False | 2030 | 2034 | -0.03 | 0.04 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| USA | 0 | False | False | 2030 | 2034 | -0.03 | -0.34 |\n", + "| USA | 0 | False | False | 2031 | 2035 | -0.03 | -0.49 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| World | 0 | False | False | 2031 | 2035 | -0.03 | -0.9 |\n", + "| World | 0 | False | False | 2031 | 2035 | -0.03 | -1.64 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", "\n", "Summary of the gas marginal market mixes:\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", "| Region | Measurement method | Foresight? | Duration | Avg. start year | Avg. end year | Avg. capital repl. rate | Volume change |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| CAZ | 0 | False | False | 2031 | 2035 | -0.03 | -0.13 |\n", + "| CAZ | 0 | False | False | 2031 | 2035 | -0.03 | -0.14 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| CHA | 0 | False | False | 2031 | 2035 | -0.03 | -0.14 |\n", + "| CHA | 0 | False | False | 2031 | 2035 | -0.03 | -0.28 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| EUR | 0 | False | False | 2031 | 2035 | -0.03 | -0.51 |\n", + "| EUR | 0 | False | False | 2031 | 2035 | -0.03 | -0.87 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", "| IND | 0 | False | False | 2031 | 2035 | -0.03 | -0.01 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| JPN | 0 | False | False | 2031 | 2035 | -0.03 | -0.06 |\n", + "| JPN | 0 | False | False | 2031 | 2035 | -0.03 | -0.09 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| LAM | 0 | False | False | 2031 | 2035 | -0.03 | -0.07 |\n", + "| LAM | 0 | False | False | 2031 | 2035 | -0.03 | -0.11 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| MEA | 0 | False | False | 2031 | 2035 | -0.03 | -0.33 |\n", + "| MEA | 0 | False | False | 2031 | 2035 | -0.03 | -0.36 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| NEU | 0 | False | False | 2031 | 2035 | -0.03 | -0.03 |\n", + "| NEU | 0 | False | False | 2031 | 2035 | -0.03 | -0.08 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| OAS | 0 | False | False | 2031 | 2035 | -0.03 | -0.06 |\n", + "| OAS | 0 | False | False | 2031 | 2035 | -0.03 | -0.26 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| REF | 0 | False | False | 2031 | 2035 | -0.03 | -0.43 |\n", + "| REF | 0 | False | False | 2031 | 2035 | -0.03 | -0.4 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| SSA | 0 | False | False | 2031 | 2035 | -0.03 | 0.05 |\n", + "| SSA | 0 | False | False | 2031 | 2035 | -0.03 | 0.0 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| USA | 0 | False | False | 2031 | 2035 | -0.03 | -0.68 |\n", + "| USA | 0 | False | False | 2031 | 2035 | -0.03 | -0.8 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| World | 0 | False | False | 2031 | 2035 | -0.03 | -2.41 |\n", + "| World | 0 | False | False | 2031 | 2035 | -0.03 | -3.41 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", "\n", "Summary of the hydrogen marginal market mixes:\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", "| Region | Measurement method | Foresight? | Duration | Avg. start year | Avg. end year | Avg. capital repl. rate | Volume change |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| CAZ | 0 | False | False | 2031 | 2035 | -0.03 | 0.03 |\n", + "| CAZ | 0 | False | False | 2031 | 2035 | -0.03 | 0.05 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| CHA | 0 | False | False | 2031 | 2035 | -0.03 | 0.07 |\n", + "| CHA | 0 | False | False | 2030 | 2034 | -0.03 | 0.29 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| EUR | 0 | False | False | 2031 | 2035 | -0.03 | 0.12 |\n", + "| EUR | 0 | False | False | 2030 | 2034 | -0.03 | 0.26 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| IND | 0 | False | False | 2031 | 2035 | -0.03 | 0.13 |\n", + "| IND | 0 | False | False | 2031 | 2035 | -0.03 | 0.14 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| JPN | 0 | False | False | 2031 | 2035 | -0.03 | 0.06 |\n", + "| JPN | 0 | False | False | 2030 | 2034 | -0.03 | 0.06 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| LAM | 0 | False | False | 2031 | 2035 | -0.03 | 0.07 |\n", + "| LAM | 0 | False | False | 2030 | 2034 | -0.03 | 0.11 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| MEA | 0 | False | False | 2031 | 2035 | -0.03 | 0.14 |\n", + "| MEA | 0 | False | False | 2030 | 2034 | -0.03 | 0.19 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| NEU | 0 | False | False | 2031 | 2035 | -0.03 | 0.01 |\n", + "| NEU | 0 | False | False | 2030 | 2034 | -0.03 | 0.04 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| OAS | 0 | False | False | 2031 | 2035 | -0.03 | 0.07 |\n", + "| OAS | 0 | False | False | 2031 | 2035 | -0.03 | 0.14 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| REF | 0 | False | False | 2031 | 2035 | -0.03 | 0.02 |\n", + "| REF | 0 | False | False | 2031 | 2035 | -0.03 | 0.08 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| SSA | 0 | False | False | 2031 | 2035 | -0.03 | 0.03 |\n", + "| SSA | 0 | False | False | 2030 | 2034 | -0.03 | 0.03 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| USA | 0 | False | False | 2031 | 2035 | -0.03 | 0.13 |\n", + "| USA | 0 | False | False | 2031 | 2035 | -0.03 | 0.36 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "| World | 0 | False | False | 2030 | 2034 | -0.03 | 0.8 |\n", + "| World | 0 | False | False | 2031 | 2035 | -0.03 | 1.88 |\n", "+--------+--------------------+------------+----------+-----------------+---------------+-------------------------+---------------+\n", - "Done!\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Processing scenarios: 100%|█████████████| 1/1 [01:20<00:00, 81.00s/it]\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ "Done!\n", - "\n", - "Write new database(s) to Brightway.\n", - "Running all checks...\n", - "Minor anomalies found: check the change report.\n", - "---> MAJOR anomalies found: check the change report.\n" - ] - }, - { - "ename": "KeyError", - "evalue": "\"Can't find linking activity for exchange:\\n{'amount': 0.0148,\\n 'location': 'GLO',\\n 'name': 'market for neutralising agent, sodium hydroxide-equivalent',\\n 'type': 'technosphere',\\n 'unit': 'kilogram'}\"", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", - "File \u001b[0;32m/opt/homebrew/Caskroom/miniforge/base/envs/premise/lib/python3.11/site-packages/wurst/linking.py:28\u001b[0m, in \u001b[0;36mlink_internal\u001b[0;34m(data, fields)\u001b[0m\n\u001b[1;32m 27\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m---> 28\u001b[0m exc[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124minput\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m products[\u001b[43mget_tuple\u001b[49m\u001b[43m(\u001b[49m\u001b[43mexc\u001b[49m\u001b[43m)\u001b[49m]\n\u001b[1;32m 29\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m:\n", - "File \u001b[0;32m/opt/homebrew/Caskroom/miniforge/base/envs/premise/lib/python3.11/site-packages/wurst/linking.py:12\u001b[0m, in \u001b[0;36mlink_internal..\u001b[0;34m(exc)\u001b[0m\n\u001b[1;32m 11\u001b[0m input_databases \u001b[38;5;241m=\u001b[39m get_input_databases(data)\n\u001b[0;32m---> 12\u001b[0m get_tuple \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mlambda\u001b[39;00m exc: \u001b[38;5;28mtuple\u001b[39m(\u001b[43m[\u001b[49m\u001b[43mexc\u001b[49m\u001b[43m[\u001b[49m\u001b[43mf\u001b[49m\u001b[43m]\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mf\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mfields\u001b[49m\u001b[43m]\u001b[49m)\n\u001b[1;32m 13\u001b[0m products \u001b[38;5;241m=\u001b[39m {\n\u001b[1;32m 14\u001b[0m get_tuple(reference_product(ds)): (ds[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdatabase\u001b[39m\u001b[38;5;124m\"\u001b[39m], ds[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcode\u001b[39m\u001b[38;5;124m\"\u001b[39m]) \u001b[38;5;28;01mfor\u001b[39;00m ds \u001b[38;5;129;01min\u001b[39;00m data\n\u001b[1;32m 15\u001b[0m }\n", - "File \u001b[0;32m/opt/homebrew/Caskroom/miniforge/base/envs/premise/lib/python3.11/site-packages/wurst/linking.py:12\u001b[0m, in \u001b[0;36m\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 11\u001b[0m input_databases \u001b[38;5;241m=\u001b[39m get_input_databases(data)\n\u001b[0;32m---> 12\u001b[0m get_tuple \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mlambda\u001b[39;00m exc: \u001b[38;5;28mtuple\u001b[39m([\u001b[43mexc\u001b[49m\u001b[43m[\u001b[49m\u001b[43mf\u001b[49m\u001b[43m]\u001b[49m \u001b[38;5;28;01mfor\u001b[39;00m f \u001b[38;5;129;01min\u001b[39;00m fields])\n\u001b[1;32m 13\u001b[0m products \u001b[38;5;241m=\u001b[39m {\n\u001b[1;32m 14\u001b[0m get_tuple(reference_product(ds)): (ds[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdatabase\u001b[39m\u001b[38;5;124m\"\u001b[39m], ds[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcode\u001b[39m\u001b[38;5;124m\"\u001b[39m]) \u001b[38;5;28;01mfor\u001b[39;00m ds \u001b[38;5;129;01min\u001b[39;00m data\n\u001b[1;32m 15\u001b[0m }\n", - "\u001b[0;31mKeyError\u001b[0m: 'product'", - "\nDuring handling of the above exception, another exception occurred:\n", - "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[3], line 18\u001b[0m\n\u001b[1;32m 9\u001b[0m ndb \u001b[38;5;241m=\u001b[39m NewDatabase(\n\u001b[1;32m 10\u001b[0m scenarios \u001b[38;5;241m=\u001b[39m scenarios, \n\u001b[1;32m 11\u001b[0m source_db\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mecoinvent-3.10-consequential\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 15\u001b[0m \u001b[38;5;66;03m#system_args = args\u001b[39;00m\n\u001b[1;32m 16\u001b[0m )\n\u001b[1;32m 17\u001b[0m ndb\u001b[38;5;241m.\u001b[39mupdate()\n\u001b[0;32m---> 18\u001b[0m \u001b[43mndb\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mwrite_db_to_brightway\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m~/GitHub/premise/premise/new_database.py:1047\u001b[0m, in \u001b[0;36mNewDatabase.write_db_to_brightway\u001b[0;34m(self, name)\u001b[0m\n\u001b[1;32m 1039\u001b[0m scenario \u001b[38;5;241m=\u001b[39m load_database(scenario)\n\u001b[1;32m 1040\u001b[0m _prepare_database(\n\u001b[1;32m 1041\u001b[0m scenario\u001b[38;5;241m=\u001b[39mscenario,\n\u001b[1;32m 1042\u001b[0m db_name\u001b[38;5;241m=\u001b[39mname[s],\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 1045\u001b[0m biosphere_name\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mbiosphere_name,\n\u001b[1;32m 1046\u001b[0m )\n\u001b[0;32m-> 1047\u001b[0m \u001b[43mwrite_brightway_database\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1048\u001b[0m \u001b[43m \u001b[49m\u001b[43mscenario\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mdatabase\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1049\u001b[0m \u001b[43m \u001b[49m\u001b[43mname\u001b[49m\u001b[43m[\u001b[49m\u001b[43ms\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1050\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1051\u001b[0m \u001b[38;5;66;03m# delete the database from the scenario\u001b[39;00m\n\u001b[1;32m 1052\u001b[0m \u001b[38;5;28;01mdel\u001b[39;00m scenario[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdatabase\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n", - "File \u001b[0;32m~/GitHub/premise/premise/brightway2.py:46\u001b[0m, in \u001b[0;36mwrite_brightway_database\u001b[0;34m(data, name)\u001b[0m\n\u001b[1;32m 43\u001b[0m \u001b[38;5;66;03m# Restore parameters to Brightway2 format\u001b[39;00m\n\u001b[1;32m 44\u001b[0m \u001b[38;5;66;03m# which allows for uncertainty and comments\u001b[39;00m\n\u001b[1;32m 45\u001b[0m change_db_name(data, name)\n\u001b[0;32m---> 46\u001b[0m \u001b[43mlink_internal\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdata\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 47\u001b[0m check_internal_linking(data)\n\u001b[1;32m 48\u001b[0m BW2Importer(name, data)\u001b[38;5;241m.\u001b[39mwrite_database()\n", - "File \u001b[0;32m/opt/homebrew/Caskroom/miniforge/base/envs/premise/lib/python3.11/site-packages/wurst/linking.py:30\u001b[0m, in \u001b[0;36mlink_internal\u001b[0;34m(data, fields)\u001b[0m\n\u001b[1;32m 28\u001b[0m exc[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124minput\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m products[get_tuple(exc)]\n\u001b[1;32m 29\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m:\n\u001b[0;32m---> 30\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(\n\u001b[1;32m 31\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCan\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mt find linking activity for exchange:\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mformat(pformat(exc))\n\u001b[1;32m 32\u001b[0m )\n\u001b[1;32m 33\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m data\n", - "\u001b[0;31mKeyError\u001b[0m: \"Can't find linking activity for exchange:\\n{'amount': 0.0148,\\n 'location': 'GLO',\\n 'name': 'market for neutralising agent, sodium hydroxide-equivalent',\\n 'type': 'technosphere',\\n 'unit': 'kilogram'}\"" + "premise requires the name of your biosphere database.\n", + "Please enter the name of your biosphere database as it appears in your project.\n", + "Databases dictionary with 4 object(s):\n", + "\tecoinvent-3.10-biosphere\n", + "\tecoinvent-3.10-consequential\n", + "\ttest1\n", + "\ttest2\n" ] } ], "source": [ + "clear_cache()\n", "scenarios = [\n", " {\"model\": \"remind\", \"pathway\":\"SSP2-PkBudg500\", \"year\": 2030},\n", " #{\"model\": \"remind\", \"pathway\":\"SSP2-PkBudg1150\", \"year\": 2050},\n", @@ -948,80 +782,34 @@ " system_model=\"consequential\",\n", " #system_args = args\n", " )\n", - " ndb.update()\n", - " ndb.write_db_to_brightway()\n", + " #ndb.update()\n", + " #ndb.write_db_to_brightway()\n", " " ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "id": "11c51f14-4187-462e-997e-218baf195cc2", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[('IPCC 2001 (superseded)', 'climate change', 'GWP 500a'),\n", - " ('IPCC 2001 (superseded)', 'climate change', 'GWP 20a'),\n", - " ('IPCC 2001 (superseded)', 'climate change', 'GWP 100a'),\n", - " ('IPCC 2007 (superseded)', 'climate change', 'GWP 100a'),\n", - " ('IPCC 2007 (superseded)', 'climate change', 'GWP 20a'),\n", - " ('IPCC 2007 (superseded)', 'climate change', 'GWP 500a'),\n", - " ('IPCC 2007 no LT (superseded)', 'climate change', 'GWP 100a'),\n", - " ('IPCC 2007 no LT (superseded)', 'climate change', 'GWP 20a'),\n", - " ('IPCC 2007 no LT (superseded)', 'climate change', 'GWP 500a'),\n", - " ('IPCC 2013 no LT', 'climate change', 'GTP 100a'),\n", - " ('IPCC 2013 no LT', 'climate change', 'GTP 20a'),\n", - " ('IPCC 2013 no LT', 'climate change', 'GWP 100a'),\n", - " ('IPCC 2013 no LT', 'climate change', 'GWP 20a'),\n", - " ('IPCC 2013', 'climate change', 'GTP 100a'),\n", - " ('IPCC 2013', 'climate change', 'GTP 20a'),\n", - " ('IPCC 2013', 'climate change', 'GWP 100a'),\n", - " ('IPCC 2013', 'climate change', 'GWP 20a'),\n", - " ('IPCC 2013', 'climate change', 'GWP 20a, incl. H'),\n", - " ('IPCC 2013', 'climate change', 'GWP 20a, incl. H and bio CO2'),\n", - " ('IPCC 2013', 'climate change', 'GWP 100a, incl. H and bio CO2'),\n", - " ('IPCC 2013', 'climate change', 'GTP 100a, incl. bio CO2'),\n", - " ('IPCC 2013', 'climate change', 'GTP 20a, incl. bio CO2'),\n", - " ('IPCC 2013', 'climate change', 'GWP 100a, incl. H')]" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "[m for m in bw.methods if \"IPCC\" in m[0]]" ] }, { "cell_type": "code", - "execution_count": 25, + "execution_count": null, "id": "167c3c97-d697-4ffa-844f-ecd124f6d15c", "metadata": {}, - "outputs": [ - { - "ename": "KeyError", - "evalue": "'ben0'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", - "Input \u001b[0;32mIn [25]\u001b[0m, in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mbw\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcalculation_setups\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mben0\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\n", - "File \u001b[0;32m/opt/homebrew/Caskroom/miniforge/base/envs/premise/lib/python3.9/site-packages/bw2data/serialization.py:146\u001b[0m, in \u001b[0;36mSerializedDict.__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m 144\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(key, \u001b[38;5;28mlist\u001b[39m):\n\u001b[1;32m 145\u001b[0m key \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mtuple\u001b[39m(key)\n\u001b[0;32m--> 146\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdata\u001b[49m\u001b[43m[\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m]\u001b[49m\n", - "\u001b[0;31mKeyError\u001b[0m: 'ben0'" - ] - } - ], + "outputs": [], "source": [ "bw.calculation_setups[\"ben0\"]" ] }, { "cell_type": "code", - "execution_count": 33, + "execution_count": null, "id": "384800ec-5ab8-4cbb-988c-985708df7be5", "metadata": {}, "outputs": [], @@ -1032,7 +820,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": null, "id": "77396b6e-0dd4-49f2-b0b6-6ef679df7e0a", "metadata": {}, "outputs": [], @@ -1048,24 +836,10 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": null, "id": "3f66c789-cbbd-4064-8671-82d1fdff3838", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'inv': [{('ben_db_0', '9498048180618909048101470389'): 1},\n", - " {('ben_db_0', '4143946432033982059594954568'): 1},\n", - " {('ben_db_0', '56883951199402670991359028683'): 1}],\n", - " 'ia': [('IPCC 2013', 'climate change', 'GWP 100a')]}" - ] - }, - "execution_count": 35, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "bw.calculation_setups[\"ben_0\"]" ] @@ -1082,255 +856,10 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "e6fb1b00-f5e6-4e07-a857-648619561f19", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "+------------------------------------------------------------------+\n", - "| Warning |\n", - "+------------------------------------------------------------------+\n", - "| Because some of the scenarios can yield LCI databases |\n", - "| containing net negative emission technologies (NET), |\n", - "| it is advised to account for biogenic CO2 flows when calculating |\n", - "| Global Warming potential indicators. |\n", - "| `premise_gwp` provides characterization factors for such flows. |\n", - "| |\n", - "| Within your bw2 project: |\n", - "| from premise_gwp import add_premise_gwp |\n", - "| add_premise_gwp() |\n", - "+------------------------------------------------------------------+\n", - "\n", - "////////////////////// EXTRACTING SOURCE DATABASE //////////////////\n", - "Done!\n", - "\n", - "//////////////////// IMPORTING DEFAULT INVENTORIES /////////////////\n", - "Done!\n", - "\n", - "///////////////////////// EXTRACTING IAM DATA //////////////////////\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "(28,)\n", - "[[2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " [2. 2. 2. ... 2. 2. 2.]\n", - " ...\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]\n", - " [1. 1. 1. ... 1. 1. 1.]]\n", - "Done!\n" - ] - } - ], + "outputs": [], "source": [ "import brightway2 as bw\n", "from premise import *\n", @@ -1366,7 +895,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "929ac8e3-af97-4b13-820b-20a1d8c070cf", "metadata": {}, "outputs": [], diff --git a/premise/__init__.py b/premise/__init__.py index 3dc3b24e..d1a864ec 100644 --- a/premise/__init__.py +++ b/premise/__init__.py @@ -4,7 +4,7 @@ "clear_inventory_cache", "get_regions_definition", ) -__version__ = (2, 1, 2) +__version__ = (2, 1, 3) from premise.new_database import NewDatabase diff --git a/premise/data/additional_inventories/lci-PV-perovskite.xlsx b/premise/data/additional_inventories/lci-PV-perovskite.xlsx index 2be1d9f0..8695d6c5 100644 Binary files a/premise/data/additional_inventories/lci-PV-perovskite.xlsx and b/premise/data/additional_inventories/lci-PV-perovskite.xlsx differ diff --git a/premise/new_database.py b/premise/new_database.py index ca183de5..3282cf2f 100644 --- a/premise/new_database.py +++ b/premise/new_database.py @@ -713,7 +713,7 @@ def __import_inventories(self) -> List[dict]: # with HiddenPrints(): # Manual import # file path and original ecoinvent version - data = [] + data, unlinked = [], [] filepaths = [ (FILEPATH_OIL_GAS_INVENTORIES, "3.7"), (FILEPATH_CARMA_INVENTORIES, "3.5"), @@ -817,6 +817,10 @@ def __import_inventories(self) -> List[dict]: datasets = inventory.merge_inventory() data.extend(datasets) self.database.extend(datasets) + unlinked.extend(inventory.list_unlinked) + + if len(unlinked) > 0: + raise ValueError("Fix the unlinked exchanges before proceeding") return data diff --git a/tests/test_process_ei38_conseq.py b/tests/test_process_ei38_conseq.py new file mode 100644 index 00000000..7488620b --- /dev/null +++ b/tests/test_process_ei38_conseq.py @@ -0,0 +1,82 @@ +import gc +import os + +import bw2calc +import bw2data +import bw2io +import pytest +from dotenv import load_dotenv + +from premise import NewDatabase, clear_inventory_cache +from premise.utils import delete_all_pickles + +load_dotenv() + + +ei_user = os.environ["EI_USERNAME"] +ei_pass = os.environ["EI_PASSWORD"] +key = os.environ["IAM_FILES_KEY"] +# convert to bytes +key = key.encode() + +ei_version = "3.8" +system_model = "consequential" + + +scenarios = [ + {"model": "remind", "pathway": "SSP2-Base", "year": 2050}, + {"model": "image", "pathway": "SSP2-RCP19", "year": 2050}, +] + + +@pytest.mark.slow +def test_brightway(): + + bw2data.projects.set_current(f"ecoinvent-{ei_version}-{system_model}") + + clear_inventory_cache() + + if f"ecoinvent-{ei_version}-{system_model}" not in bw2data.databases: + bw2io.import_ecoinvent_release( + version=ei_version, + system_model=system_model, + username=ei_user, + password=ei_pass, + ) + + ndb = NewDatabase( + scenarios=scenarios, + source_db=f"ecoinvent-{ei_version}-{system_model}", + source_version=ei_version, + key=key, + system_model=system_model, + biosphere_name=f"ecoinvent-{ei_version}-biosphere", + ) + + ndb.update() + + if "test1" in bw2data.databases: + del bw2data.databases["test1"] + if "test2" in bw2data.databases: + del bw2data.databases["test2"] + + ndb.write_db_to_brightway( + [ + "test1", + "test2", + ] + ) + + method = [m for m in bw2data.methods if "IPCC" in m[0]][0] + + lca = bw2calc.LCA({bw2data.Database("test1").random(): 1}, method) + lca.lci() + lca.lcia() + assert isinstance(lca.score, float) + print(lca.score) + + # destroy all objects + del ndb + del lca + gc.collect() + delete_all_pickles() diff --git a/tests/test_process_ei38_cutoff.py b/tests/test_process_ei38_cutoff.py new file mode 100644 index 00000000..6a19a59b --- /dev/null +++ b/tests/test_process_ei38_cutoff.py @@ -0,0 +1,81 @@ +import gc +import os + +import bw2calc +import bw2data +import bw2io +import pytest +from dotenv import load_dotenv + +from premise import NewDatabase, clear_inventory_cache +from premise.utils import delete_all_pickles + +load_dotenv() + + +ei_user = os.environ["EI_USERNAME"] +ei_pass = os.environ["EI_PASSWORD"] +key = os.environ["IAM_FILES_KEY"] +# convert to bytes +key = key.encode() + +ei_version = "3.8" +system_model = "cutoff" + + +scenarios = [ + {"model": "remind", "pathway": "SSP2-Base", "year": 2050}, + {"model": "image", "pathway": "SSP2-RCP19", "year": 2050}, +] + + +@pytest.mark.slow +def test_brightway(): + + bw2data.projects.set_current(f"ecoinvent-{ei_version}-{system_model}") + clear_inventory_cache() + + if f"ecoinvent-{ei_version}-{system_model}" not in bw2data.databases: + bw2io.import_ecoinvent_release( + version=ei_version, + system_model=system_model, + username=ei_user, + password=ei_pass, + ) + + ndb = NewDatabase( + scenarios=scenarios, + source_db=f"ecoinvent-{ei_version}-{system_model}", + source_version=ei_version, + key=key, + system_model=system_model, + biosphere_name=f"ecoinvent-{ei_version}-biosphere", + ) + + ndb.update() + + if "test1" in bw2data.databases: + del bw2data.databases["test1"] + if "test2" in bw2data.databases: + del bw2data.databases["test2"] + + ndb.write_db_to_brightway( + [ + "test1", + "test2", + ] + ) + + method = [m for m in bw2data.methods if "IPCC" in m[0]][0] + + lca = bw2calc.LCA({bw2data.Database("test1").random(): 1}, method) + lca.lci() + lca.lcia() + assert isinstance(lca.score, float) + print(lca.score) + + # destroy all objects + del ndb + del lca + gc.collect() + delete_all_pickles() diff --git a/tests/test_process_ei39_conseq.py b/tests/test_process_ei39_conseq.py new file mode 100644 index 00000000..6c600f4e --- /dev/null +++ b/tests/test_process_ei39_conseq.py @@ -0,0 +1,82 @@ +import gc +import os + +import bw2calc +import bw2data +import bw2io +import pytest +from dotenv import load_dotenv + +from premise import NewDatabase, clear_inventory_cache +from premise.utils import delete_all_pickles + +load_dotenv() + + +ei_user = os.environ["EI_USERNAME"] +ei_pass = os.environ["EI_PASSWORD"] +key = os.environ["IAM_FILES_KEY"] +# convert to bytes +key = key.encode() + +ei_version = "3.9.1" +system_model = "consequential" + + +scenarios = [ + {"model": "remind", "pathway": "SSP2-Base", "year": 2050}, + {"model": "image", "pathway": "SSP2-RCP19", "year": 2050}, +] + + +@pytest.mark.slow +def test_brightway(): + + bw2data.projects.set_current(f"ecoinvent-{ei_version}-{system_model}") + + clear_inventory_cache() + + if f"ecoinvent-{ei_version}-{system_model}" not in bw2data.databases: + bw2io.import_ecoinvent_release( + version=ei_version, + system_model=system_model, + username=ei_user, + password=ei_pass, + ) + + ndb = NewDatabase( + scenarios=scenarios, + source_db=f"ecoinvent-{ei_version}-{system_model}", + source_version=ei_version, + key=key, + system_model=system_model, + biosphere_name=f"ecoinvent-{ei_version}-biosphere", + ) + + ndb.update() + + if "test1" in bw2data.databases: + del bw2data.databases["test1"] + if "test2" in bw2data.databases: + del bw2data.databases["test2"] + + ndb.write_db_to_brightway( + [ + "test1", + "test2", + ] + ) + + method = [m for m in bw2data.methods if "IPCC" in m[0]][0] + + lca = bw2calc.LCA({bw2data.Database("test1").random(): 1}, method) + lca.lci() + lca.lcia() + assert isinstance(lca.score, float) + print(lca.score) + + # destroy all objects + del ndb + del lca + gc.collect() + delete_all_pickles()