Skip to content

Commit

Permalink
Add 2050 data points for PEMEL ad PEMFC for iridium and platinum
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Jul 11, 2024
2 parents 739942d + d130cc4 commit 4b24072
Show file tree
Hide file tree
Showing 61 changed files with 33,861 additions and 23,110 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ The tool is described in the following scientific publication: [Sacchi et al, 20
If this tool helps you in your research, please consider citing this publication.


What's new in 2.1.1?
====================

- Ecoinvent 3.10 support
- Adds inventories on ammonia production
- Fixes issues with scaling applied to PV systems

What's new in 2.1.0?
====================

- More efficient use of memory.
- Easier syntax for using custom scenarios.

What's new in 2.0.0?
====================
Expand All @@ -51,7 +63,7 @@ What's new in 2.0.0?
What's new in 1.8.0?
====================

- Added support for brightway 2.5
- Added support for brightway 2.5 (requires `bw2data` >= 4.0.0)
- Added support for Python 3.11
- Uses bw2io 0.8.10
- Adds electricity storage in electricity markets -- see [docs](https://premise.readthedocs.io/en/latest/transform.html#storage)
Expand Down Expand Up @@ -94,7 +106,7 @@ Requirements
* Some IAM output files come with the library and are located by default in the subdirectory "/data/iam_output_files". **If you wish to use
those files, you need to request (by [email](mailto:[email protected])) an encryption key from the developers**.
A file path can be specified to fetch IAM output files elsewhere on your computer.
* [brightway2][2] (optional)
* [brightway2][2] (optional). If you want to use the results in the Brightway 2 framework 8and Activity Browser), you need `bw2data <4.0.0`. To produce Brightway 2.5-compatible databases, you need `bw2data >=4.0.0`.

How to install this package?
----------------------------
Expand Down
2 changes: 1 addition & 1 deletion conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ requirements:
- constructive_geometries>=0.9.5
- cryptography
- datapackage
- numpy
- numpy <2.0.0
- pandas
- platformdirs
- prettytable
Expand Down
10,892 changes: 10,862 additions & 30 deletions dev/Untitled1.ipynb

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dev/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
source_db="ecoinvent 3.9.1 cutoff",
source_version="3.9.1",
key=b'tUePmX_S5B8ieZkkM7WUU2CnO8SmShwmAeWK9x2rTFo=',
use_multiprocessing=False,
)

ndb.update()
1,847 changes: 851 additions & 996 deletions dev/test_consequential.ipynb

Large diffs are not rendered by default.

183 changes: 124 additions & 59 deletions dev/test_custom_scenarios.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"outputs": [],
"source": [
"import bw2io, bw2data, bw2calc\n",
"bw2data.projects.set_current(\"ei39\")"
"bw2data.projects.set_current(\"ei310\")"
]
},
{
Expand All @@ -32,7 +32,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"premise v.(2, 0, 0, 'dev3')\n",
"premise v.(2, 1, 1, 'dev1')\n",
"+------------------------------------------------------------------+\n",
"| Warning |\n",
"+------------------------------------------------------------------+\n",
Expand Down Expand Up @@ -64,8 +64,6 @@
"Keep uncertainty data?\n",
"NewDatabase(..., keep_uncertainty_data=True)\n",
"\n",
"Disable multiprocessing?\n",
"NewDatabase(..., use_multiprocessing=False)\n",
"\n",
"Hide these messages?\n",
"NewDatabase(..., quiet=True)\n",
Expand All @@ -79,21 +77,21 @@
"name": "stderr",
"output_type": "stream",
"text": [
"Updating: external: 50%|███████▌ | 1/2 [00:32<00:32, 32.91s/it]"
"Processing scenarios: 0%| | 0/1 [00:00<?, ?it/s]"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"No efficiency factor provided for dataset aluminium production, primary, liquid, prebake in RoW\n"
"Extracted 1 worksheets in 0.20 seconds\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Updating: external: 100%|███████████████| 2/2 [00:42<00:00, 21.30s/it]"
"Processing scenarios: 100%|█████████████| 1/1 [00:51<00:00, 51.35s/it]"
]
},
{
Expand All @@ -113,52 +111,35 @@
}
],
"source": [
"#for url in urls:\n",
"scenarios = [\n",
" #{\"model\": \"image\", \"pathway\":\"SSP2-Base\", \"year\": 2020},\n",
" #{\"model\": \"image\", \"pathway\":\"SSP2-Base\", \"year\": 2025},\n",
" #{\"model\": \"image\", \"pathway\":\"SSP2-Base\", \"year\": 2030},\n",
" #{\"model\": \"image\", \"pathway\":\"SSP2-Base\", \"year\": 2035},\n",
" #{\"model\": \"image\", \"pathway\":\"SSP2-Base\", \"year\": 2040},\n",
" #{\"model\": \"image\", \"pathway\":\"SSP2-Base\", \"year\": 2045},\n",
" #{\"model\": \"image\", \"pathway\":\"SSP2-Base\", \"year\": 2050},\n",
" #{\"model\": \"image\", \"pathway\":\"SSP2-RCP26\", \"year\": 2020},\n",
" ##{\"model\": \"image\", \"pathway\":\"SSP2-RCP26\", \"year\": 2025},\n",
" #{\"model\": \"remind\", \"pathway\":\"SSP2-Base\", \"year\": 2020},\n",
" #{\"model\": \"remind\", \"pathway\":\"SSP2-Base\", \"year\": 2030},\n",
" #{\"model\": \"remind\", \"pathway\":\"SSP2-Base\", \"year\": 2050},\n",
" #{\"model\": \"remind\", \"pathway\":\"SSP2-PkBudg500\", \"year\": 2030},\n",
" {\"model\": \"remind\", \"pathway\":\"SSP2-PkBudg500\", \"year\": 2050},\n",
" #{\"model\": \"image\", \"pathway\":\"SSP2-RCP26\", \"year\": 2035},\n",
" #{\"model\": \"image\", \"pathway\":\"SSP2-RCP26\", \"year\": 2040},\n",
" #{\"model\": \"image\", \"pathway\":\"SSP2-RCP26\", \"year\": 2045},\n",
" \n",
"external_scenarios = [\n",
" #{\"scenario\": \"SPS\", \"data\": Package(\"/Users/romain/Github/metal-prospective-scenarios/datapackage.json\")},\n",
" #{\"scenario\": \"Business As Usual\", \"data\": Package(\"/Users/romain/Github/energy-perspective-2050-switzerland/datapackage.json\")},\n",
" #{\"scenario\": \"Business As Usual - remind\", \"data\": Package(\"/Users/romain/Github/ammonia-prospective-scenarios/datapackage.json\")},\n",
" {\"scenario\": \"Ambitious\", \"data\": Package(\"/Users/romain/Github/hydrogen-prospective-scenarios/datapackage.json\")},\n",
" #{\"scenario\": \"\", \"data\": Package(\"/Users/romain/Documents/marguerite/datapackage.json\")},\n",
"]\n",
"\n",
"marguerite = Package(\"/Users/romain/Documents/marguerite/datapackage.json\")\n",
"\n",
"ndb = NewDatabase(\n",
" scenarios = scenarios, \n",
" source_db=\"ecoinvent 3.9.1 cutoff\",\n",
" source_version=\"3.9\",\n",
" key='tUePmX_S5B8ieZkkM7WUU2CnO8SmShwmAeWK9x2rTFo=',\n",
" use_multiprocessing=False,\n",
" external_scenarios=[marguerite]\n",
")\n",
"ndb.update([\n",
" \"electricity\",\n",
" \"external\"\n",
"])\n",
"#ndb.write_db_to_brightway([\"test5\", \"test6\"])\n",
"#ndb.update_external_scenario()\n",
"#ndb.write_datapackage(name=\"test13\")\n",
"#ndb.write_superstructure_db_to_brightway(\"test9\")\n",
"#ndb.write_db_to_simapro(\"test_olca\")\n"
"for external in external_scenarios:\n",
" \n",
" scenarios = [\n",
" {\"model\": \"remind\", \"pathway\":\"SSP2-PkBudg500\", \"year\": 2050, \"external scenarios\": [external]},\n",
" #{\"model\": \"image\", \"pathway\":\"SSP2-RCP26\", \"year\": 2035, \"external scenarios\": external_scenarios},\n",
" ]\n",
" \n",
" \n",
" ndb = NewDatabase(\n",
" scenarios = scenarios, \n",
" source_db=\"ecoinvent-3.10-cutoff\",\n",
" source_version=\"3.10\",\n",
" key='tUePmX_S5B8ieZkkM7WUU2CnO8SmShwmAeWK9x2rTFo=',\n",
" biosphere_name=\"ecoinvent-3.10-biosphere\",\n",
" )\n",
" ndb.update(\"external\")\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 7,
"id": "799788bc-d53e-4cef-bdda-ded8d40cdb03",
"metadata": {
"tags": []
Expand All @@ -169,7 +150,8 @@
"output_type": "stream",
"text": [
"Write new database(s) to Brightway.\n",
"Running all checks...\n"
"Running all checks...\n",
"Minor anomalies found: check the change report.\n"
]
},
{
Expand All @@ -178,29 +160,112 @@
"text": [
"Writing activities to SQLite3 database:\n",
"0% [##############################] 100% | ETA: 00:00:00\n",
"Total time elapsed: 00:00:23\n"
"Total time elapsed: 00:00:21\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Title: Writing activities to SQLite3 database:\n",
" Started: 02/15/2024 10:08:54\n",
" Finished: 02/15/2024 10:09:18\n",
" Total time elapsed: 00:00:23\n",
" CPU %: 94.70\n",
" Memory %: 8.80\n",
"Created database: test marguerite 2\n",
" Started: 06/20/2024 16:31:51\n",
" Finished: 06/20/2024 16:32:12\n",
" Total time elapsed: 00:00:21\n",
" CPU %: 99.90\n",
" Memory %: 11.64\n",
"Created database: test marguerite 5\n",
"Generate scenario report.\n",
"Report saved under /Users/romain/GitHub/premise/dev/export/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"
"Report saved under /Users/romain/Github/premise/dev.\n"
]
}
],
"source": [
"ndb.write_db_to_brightway(\"test marguerite 2\")"
"ndb.write_db_to_brightway(\"test marguerite 5\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "91d9b891-1438-42ef-848a-440f97aff150",
"metadata": {},
"outputs": [],
"source": [
"from premise.utils import load_database\n",
"ndb.scenarios[0] = load_database(ndb.scenarios[0])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5779b911-0ff9-4e3b-940f-d7d1baeec710",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 6,
"id": "8dc932d9-e5f5-48b1-b900-ee38557c3049",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['comment', 'filename', 'location', 'production amount', 'reference product', 'source', 'type', 'unit', 'worksheet name', 'name', 'exchanges', 'database', 'code', 'regions', 'region mapping', 'production volume variable', 'production volume']\n",
"{'LAM': 'CL'}\n",
"Energy, solar, converted 3.8503 None\n",
"Heat, waste 0.25027 None\n",
"electricity production, photovoltaic, commercial 1 LAM\n",
"photovoltaic flat-roof installation, 156 kWp, multi-Si, on roof 2.433772229872875e-10 CH\n",
"photovoltaic flat-roof installation, 156 kWp, single-Si, on roof 1.2890969393392591e-10 CH\n",
"photovoltaic open ground installation, 570 kWp, CIS, on open ground 6.664318406721691e-10 RER\n",
"photovoltaic open ground installation, 570 kWp, CdTe, on open ground 8.080054441310238e-10 RER\n",
"photovoltaic open ground installation, 570 kWp, micro-Si, on open ground 1.0531694891451379e-10 RER\n",
"photovoltaic open ground installation, 570 kWp, multi-Si, on open ground 2.1339630960383448e-08 RER\n",
"photovoltaic open ground installation, 570 kWp, single-Si, on open ground 1.129135812952328e-08 RER\n",
"photovoltaic slanted-roof installation, 93 kWp, multi-Si, laminated, integrated, on roof 3.877718056324967e-11 CH\n",
"photovoltaic slanted-roof installation, 93 kWp, multi-Si, panel, mounted, on roof 4.531078252850883e-10 CH\n",
"photovoltaic slanted-roof installation, 93 kWp, single-Si, laminated, integrated, on roof 1.4423184735559989e-11 CH\n",
"photovoltaic slanted-roof installation, 93 kWp, single-Si, panel, mounted, on roof 2.400125609183388e-10 CH\n",
"tap water, water balance according to MoeK 2013, at user 0.00092565 BR\n",
"tap water, water balance according to MoeK 2013, at user 0.00092565 CL\n",
"tap water, water balance according to MoeK 2013, at user 0.00092565 CO\n",
"tap water, water balance according to MoeK 2013, at user 0.00092565 MX\n",
"treatment of wastewater, average, wastewater treatment -3.3323e-06 RoW\n"
]
}
],
"source": [
"for ds in ndb.scenarios[0][\"database\"]:\n",
" if ds[\"name\"] == \"electricity production, photovoltaic, commercial\" and ds[\"location\"] == \"LAM\":\n",
" print(list(ds.keys()))\n",
" print(ds['region mapping'])\n",
" for e in ds[\"exchanges\"]:\n",
" print(e[\"name\"], e[\"amount\"], e.get(\"location\"))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "b561179c-bccd-472a-8750-b9c615be22b8",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'LAM'"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"geo.ecoinvent_to_iam_location(\"IAI Area, South America\")"
]
},
{
Expand Down Expand Up @@ -1622,7 +1687,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.10.13"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 4b24072

Please sign in to comment.