diff --git a/dev/Untitled.ipynb b/dev/Untitled.ipynb index 84203af0..fbf15b59 100644 --- a/dev/Untitled.ipynb +++ b/dev/Untitled.ipynb @@ -4395,7 +4395,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.11.8" } }, "nbformat": 4, diff --git a/dev/Untitled1.ipynb b/dev/Untitled1.ipynb index a582c1d9..8771e331 100644 --- a/dev/Untitled1.ipynb +++ b/dev/Untitled1.ipynb @@ -90,7 +90,7 @@ "Cannot find cached inventories. Will create them now for next time...\n", "Importing default inventories...\n", "\n", - "Extracted 1 worksheets in 0.10 seconds\n", + "Extracted 1 worksheets in 0.09 seconds\n", "Migrating to 3.8 first\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", @@ -135,7 +135,9 @@ "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "Extracted 1 worksheets in 0.01 seconds\n", + "Extracted 4 worksheets in 0.17 seconds\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", @@ -221,7 +223,7 @@ "Remove uncertainty data.\n", "Extracted 1 worksheets in 0.01 seconds\n", "Remove uncertainty data.\n", - "Extracted 1 worksheets in 0.39 seconds\n", + "Extracted 1 worksheets in 0.35 seconds\n", "Migrating to 3.8 first\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", @@ -251,7 +253,7 @@ "| vinyl fluoride production | vinyl fluoride | US | lci-PV.xlsx |\n", "| wafer factory construction | wafer factory | DE | lci-PV.xlsx |\n", "+--------------------------------+--------------------------------+----------+-------------+\n", - "Extracted 1 worksheets in 0.05 seconds\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", @@ -327,7 +329,7 @@ "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "Extracted 1 worksheets in 0.02 seconds\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", @@ -336,7 +338,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", @@ -387,7 +389,7 @@ "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "Extracted 1 worksheets in 0.00 seconds\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", @@ -438,7 +440,7 @@ "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "Extracted 5 worksheets in 0.14 seconds\n", + "Extracted 5 worksheets in 0.62 seconds\n", "Migrating to 3.8 first\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", @@ -510,14 +512,14 @@ "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "Extracted 1 worksheets in 0.00 seconds\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.48 seconds\n", + "Extracted 1 worksheets in 0.09 seconds\n", "Migrating to 3.8 first\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", @@ -583,7 +585,7 @@ "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "Extracted 1 worksheets in 0.04 seconds\n", + "Extracted 1 worksheets in 0.09 seconds\n", "Migrating to 3.8 first\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", @@ -608,7 +610,7 @@ "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "Extracted 19 worksheets in 0.29 seconds\n", + "Extracted 19 worksheets in 0.28 seconds\n", "Migrating to 3.8 first\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", @@ -617,7 +619,7 @@ "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "Extracted 1 worksheets in 0.21 seconds\n", + "Extracted 1 worksheets in 0.19 seconds\n", "Migrating to 3.8 first\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", @@ -626,7 +628,7 @@ "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "Extracted 1 worksheets in 0.17 seconds\n", + "Extracted 1 worksheets in 0.15 seconds\n", "Migrating to 3.8 first\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", @@ -635,7 +637,7 @@ "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", "Remove uncertainty data.\n", - "Extracted 1 worksheets in 0.81 seconds\n", + "Extracted 1 worksheets in 0.75 seconds\n", "Migrating to 3.8 first\n", "Applying strategy: migrate_datasets\n", "Applying strategy: migrate_exchanges\n", @@ -659,7 +661,7 @@ " #{\"model\":\"remind\", \"pathway\":\"SSP2-Base\", \"year\":2010},\n", " #{\"model\":\"image\", \"pathway\":\"SSP2-Base\", \"year\":2020},\n", " #{\"model\":\"remind\", \"pathway\":\"SSP2-Base\", \"year\":2050},\n", - " {\"model\":\"remind\", \"pathway\":\"SSP2-PkBudg1150\", \"year\":2050},\n", + " {\"model\":\"remind\", \"pathway\":\"SSP2-PkBudg1150\", \"year\":2020},\n", " #{\"model\":\"image\", \"pathway\":\"SSP2-RCP26\", \"year\":2040},\n", " #{\"model\":\"image\", \"pathway\":\"SSP2-RCP26\", \"year\":2060},\n", " #{\"model\":\"image\", \"pathway\":\"SSP2-RCP19\", \"year\":2050},\n", @@ -672,6 +674,71 @@ ")" ] }, + { + "cell_type": "code", + "execution_count": 5, + "id": "967ecac3-a402-4290-a095-8986bc2ae64b", + "metadata": {}, + "outputs": [], + "source": [ + "ndb.scenarios[0][\"database\"] = ndb.database" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "c353ff76-c1b2-4ccc-b311-44bfde9c3a98", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Write new database(s) to Brightway.\n", + "Running all checks...\n", + "Minor anomalies found: check the change report.\n", + "Database waste chp 3 already exists: it will be overwritten.\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Writing activities to SQLite3 database:\n", + "0% [##############################] 100% | ETA: 00:00:00\n", + "Total time elapsed: 00:00:17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Title: Writing activities to SQLite3 database:\n", + " Started: 07/18/2024 10:37:54\n", + " Finished: 07/18/2024 10:38:12\n", + " Total time elapsed: 00:00:17\n", + " CPU %: 91.40\n", + " Memory %: 10.54\n", + "Created database: waste chp 3\n", + "Generate scenario report.\n", + "Report saved under /Users/romain/GitHub/premise/dev/export/scenario_report.\n", + "Generate change report.\n", + "Report saved under /Users/romain/GitHub/premise/dev.\n" + ] + } + ], + "source": [ + "ndb.write_db_to_brightway(\"waste chp 3\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "62307835-ad98-41bd-bfc6-51f1119fc908", + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": 5, @@ -11862,7 +11929,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.11.8" } }, "nbformat": 4, diff --git a/premise/clean_datasets.py b/premise/clean_datasets.py index 1c598196..2c5f8bdc 100644 --- a/premise/clean_datasets.py +++ b/premise/clean_datasets.py @@ -127,9 +127,13 @@ def remove_categories(database: List[dict]) -> List[dict]: if "categories" in dataset: del dataset["categories"] for exc in dataset["exchanges"]: - if exc["type"] in ["production", "technosphere"]: - if "categories" in exc: - del exc["categories"] + try: + if exc["type"] in ["production", "technosphere"]: + if "categories" in exc: + del exc["categories"] + except KeyError: + print(f"Exchange {exc['name']} in {dataset['name']} has no type") + pass return database diff --git a/premise/data/additional_inventories/lci-battery-capacity.xlsx b/premise/data/additional_inventories/lci-battery-capacity.xlsx index ed0b2a67..d644150f 100644 Binary files a/premise/data/additional_inventories/lci-battery-capacity.xlsx and b/premise/data/additional_inventories/lci-battery-capacity.xlsx differ diff --git a/premise/data/additional_inventories/lci-biofuels.xlsx b/premise/data/additional_inventories/lci-biofuels.xlsx index fe4fbc1e..b3c036aa 100644 Binary files a/premise/data/additional_inventories/lci-biofuels.xlsx and b/premise/data/additional_inventories/lci-biofuels.xlsx differ diff --git a/premise/data/additional_inventories/lci-two_wheelers.xlsx b/premise/data/additional_inventories/lci-two_wheelers.xlsx index b0d0394e..d2bca5a8 100644 Binary files a/premise/data/additional_inventories/lci-two_wheelers.xlsx and b/premise/data/additional_inventories/lci-two_wheelers.xlsx differ diff --git a/premise/data/additional_inventories/lci-waste-CHP.xlsx b/premise/data/additional_inventories/lci-waste-CHP.xlsx index ff52df40..0b4186b2 100644 Binary files a/premise/data/additional_inventories/lci-waste-CHP.xlsx and b/premise/data/additional_inventories/lci-waste-CHP.xlsx differ diff --git a/premise/iam_variables_mapping/electricity_variables.yaml b/premise/iam_variables_mapping/electricity_variables.yaml index d2e9c3dd..4abb882c 100644 --- a/premise/iam_variables_mapping/electricity_variables.yaml +++ b/premise/iam_variables_mapping/electricity_variables.yaml @@ -125,7 +125,7 @@ Biomass IGCC CCS: Biomass MSW: ecoinvent_aliases: fltr: - name: treatment of municipal solid waste, incineration + name: treatment of municipal solid waste, reference product: electricity ecoinvent_fuel_aliases: fltr: diff --git a/premise/new_database.py b/premise/new_database.py index 0b092226..8bb04a73 100644 --- a/premise/new_database.py +++ b/premise/new_database.py @@ -72,6 +72,7 @@ FILEPATH_CC_INVENTORIES = INVENTORY_DIR / "lci-carbon-capture.xlsx" FILEPATH_BIOFUEL_INVENTORIES = INVENTORY_DIR / "lci-biofuels.xlsx" FILEPATH_BIOGAS_INVENTORIES = INVENTORY_DIR / "lci-biogas.xlsx" +FILEPATH_WASTE_CHP_INVENTORIES = INVENTORY_DIR / "lci-waste-CHP.xlsx" FILEPATH_CARBON_FIBER_INVENTORIES = INVENTORY_DIR / "lci-carbon-fiber.xlsx" FILEPATH_HYDROGEN_DISTRI_INVENTORIES = INVENTORY_DIR / "lci-hydrogen-distribution.xlsx" @@ -709,6 +710,7 @@ def __import_inventories(self) -> List[dict]: (FILEPATH_CHP_INVENTORIES, "3.5"), (FILEPATH_CC_INVENTORIES, "3.9"), (FILEPATH_BIOGAS_INVENTORIES, "3.6"), + (FILEPATH_WASTE_CHP_INVENTORIES, "3.10"), (FILEPATH_CARBON_FIBER_INVENTORIES, "3.9"), (FILEPATH_LITHIUM, "3.8"), (FILEPATH_COBALT, "3.8"),