diff --git a/dev/Add AWARE CFs.ipynb b/dev/Add AWARE CFs.ipynb new file mode 100644 index 0000000..ed7b115 --- /dev/null +++ b/dev/Add AWARE CFs.ipynb @@ -0,0 +1,923 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "afe615cf-7a63-4899-8ce8-95d3f7c53c21", + "metadata": {}, + "outputs": [], + "source": [ + "import httpx\n", + "import pandas\n", + "import tempfile\n", + "import bw2data as bd\n", + "import math\n", + "import country_converter as coco" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "29fa5764-55fd-478f-b387-9701fdfe80ec", + "metadata": {}, + "outputs": [], + "source": [ + "df = pandas.read_excel(\n", + " \"/Users/cmutel/Downloads/AWARE_country_regions_Corrected_online_20230113-1.xlsx\", \n", + " keep_default_na=False,\n", + " na_values=[None, \"\", \" \"],\n", + " sheet_name=\"AWARE-annual\", \n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "cb934002-f7e2-44c7-9415-961950714a71", + "metadata": {}, + "outputs": [], + "source": [ + "bd.projects.set_current(\"agribalyse-3.1.1 transformations\")" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "343e1b97-0065-469c-aa1a-3feb569f0e89", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Databases dictionary with 8 object(s):\n", + "\tagribalyse-3.1.1\n", + "\tagribalyse-3.1.1-biosphere-placeholders\n", + "\tecoinvent-3.10-biosphere\n", + "\tecoinvent-3.10-cutoff\n", + "\tecoinvent-3.8-biosphere\n", + "\tecoinvent-3.8-cutoff\n", + "\tgeneric-regionalized-biosphere-proxies\n", + "\tgeneric_simapro_ecoinvent_biosphere_placeholders" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "bd.databases" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "e8d6e17a-b837-4f49-8690-2f83f63bbdb1", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'AR',\n", + " 'AU',\n", + " 'Asia, South East',\n", + " 'BR',\n", + " 'CA',\n", + " 'CI',\n", + " 'CM',\n", + " 'CN',\n", + " 'CO',\n", + " 'CR',\n", + " 'DE',\n", + " 'EC',\n", + " 'ES',\n", + " 'Europe, Eastern',\n", + " 'Europe, Western',\n", + " 'FR',\n", + " 'FSU',\n", + " 'GB',\n", + " 'GLO',\n", + " 'IE',\n", + " 'IL',\n", + " 'IT',\n", + " 'KE',\n", + " 'MX',\n", + " 'MY',\n", + " 'Mixed data',\n", + " 'NO',\n", + " None,\n", + " 'PE',\n", + " 'PH',\n", + " 'RAF',\n", + " 'RER',\n", + " 'RLA',\n", + " 'RME',\n", + " 'RNA',\n", + " 'RU',\n", + " 'SAS',\n", + " 'South and Central America',\n", + " 'TH',\n", + " 'UA',\n", + " 'US',\n", + " 'World'}" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "{x['location'] for x in bd.Database(\"agribalyse-3.1.1\")}" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "id": "4058e380-1fae-4ab8-812b-359232f42a6d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[(57.935456987292476, 'AF'),\n", + " (34.1634942960456, 'AL'),\n", + " (64.17180130077834, 'DZ'),\n", + " (4.417532544, 'AS'),\n", + " (56.3308179373251, 'AD'),\n", + " (5.788541614191322, 'AO'),\n", + " (22.37208753, 'AI'),\n", + " (5.759905111728797, 'AG'),\n", + " (30.14148180514807, 'AR'),\n", + " (85.75290069851204, 'AM'),\n", + " (0.0, 'AW'),\n", + " (71.08118653712059, 'AU'),\n", + " (1.2459292893288103, 'AT'),\n", + " (84.6293212973196, 'AZ'),\n", + " (8.72716077896561, 'BH'),\n", + " (2.9863210944027583, 'BD'),\n", + " (9.70662042091232, 'BB'),\n", + " (3.364175972996923, 'BY'),\n", + " (1.3736930005596066, 'BE'),\n", + " (1.0883962832274388, 'BZ'),\n", + " (6.323668271898761, 'BJ'),\n", + " (1.0214274439494864, 'BT'),\n", + " (2.891210759394875, 'BO'),\n", + " (1.1746002891612453, 'BA'),\n", + " (21.712667514866858, 'BW'),\n", + " (2.2752038902763507, 'BR'),\n", + " (14.6191233, 'VG'),\n", + " (0.18278962258374884, 'BN'),\n", + " (26.6952216599752, 'BG'),\n", + " (18.20079075155446, 'BF'),\n", + " (29.111873606634934, 'BI'),\n", + " (8.564984330130088, 'KH'),\n", + " (7.14011138484715, 'CM'),\n", + " (6.577624816701168, 'CA'),\n", + " (24.81282098, 'CV'),\n", + " (8.88104290530532, 'CF'),\n", + " (21.602798326139393, 'TD'),\n", + " (81.37974926668001, 'CL'),\n", + " (42.47130357170714, 'CN'),\n", + " (1.4211688663547368, 'CO'),\n", + " (9.678611459789712, 'KM'),\n", + " (0.5686078891285439, 'CG'),\n", + " (7.709208228664474, 'CD'),\n", + " (1.083363375510291, 'CR'),\n", + " (6.017534440799839, 'CI'),\n", + " (1.5859634618153011, 'HR'),\n", + " (3.6570075696193154, 'CU'),\n", + " (75.67978076465347, 'CY'),\n", + " (1.827334000202975, 'CZ'),\n", + " (2.034372271328134, 'DK'),\n", + " (20.924589532401097, 'DJ'),\n", + " (6.8808723631871604, 'DM'),\n", + " (10.185232984464601, 'DO'),\n", + " (9.603630847441483, 'TL'),\n", + " (6.726708773143528, 'EC'),\n", + " (95.9648821177559, 'EG'),\n", + " (1.6640941210718314, 'SV'),\n", + " (0.2892203989118381, 'GQ'),\n", + " (44.06515833697833, 'ER'),\n", + " (1.092361549241158, 'EE'),\n", + " (28.985178513440506, 'ET'),\n", + " (5.38829823708395, 'FK'),\n", + " (1.4392618900696958, 'FO'),\n", + " (2.0929793986468685, 'FJ'),\n", + " (1.6723354337812035, 'FI'),\n", + " (8.150621234141653, 'FR'),\n", + " (0.47708962377029185, 'GF'),\n", + " (0.4430631327832625, 'GA'),\n", + " (75.9483117081722, 'GE'),\n", + " (1.312326145829117, 'DE'),\n", + " (16.43845623587336, 'GH'),\n", + " (46.16274165, 'GI'),\n", + " (68.03632881973094, 'GR'),\n", + " (0.0, 'GL'),\n", + " (11.82217293, 'GD'),\n", + " (9.523865416596072, 'GP'),\n", + " (1.1172605438493581, 'GT'),\n", + " (15.386723209854896, 'GN'),\n", + " (2.6985831947717793, 'GW'),\n", + " (0.934698642571197, 'GY'),\n", + " (5.9617055477650105, 'HT'),\n", + " (0.9806276189767968, 'HN'),\n", + " (1.2638431819999996, 'HU'),\n", + " (1.08280436804684, 'IS'),\n", + " (29.835985412704375, 'IN'),\n", + " (21.81359914900988, 'ID'),\n", + " (66.28166263891961, 'IR'),\n", + " (58.66426033155479, 'IQ'),\n", + " (0.7965654499483344, 'IE'),\n", + " (4.976552229400558, 'IM'),\n", + " (84.87228471909822, 'IL'),\n", + " (43.214023490982164, 'IT'),\n", + " (8.685348817899964, 'JM'),\n", + " (0.5889385615388466, 'JP'),\n", + " (13.54248473, 'JE'),\n", + " (77.68153877382986, 'JO'),\n", + " (50.599335986124935, 'KZ'),\n", + " (21.267563585088336, 'KE'),\n", + " (58.94111340860293, 'KW'),\n", + " (62.958996288490496, 'KG'),\n", + " (5.75160077815627, 'LA'),\n", + " (1.258120207270554, 'LV'),\n", + " (83.41792198542393, 'LB'),\n", + " (18.609237651691114, 'LS'),\n", + " (0.6809118965022888, 'LR'),\n", + " (46.11558945868434, 'LY'),\n", + " (0.761009827, 'LI'),\n", + " (1.312842781488865, 'LT'),\n", + " (0.7741985418146776, 'LU'),\n", + " (48.894392851197125, 'MK'),\n", + " (7.381302466362454, 'MG'),\n", + " (5.483267661742227, 'MW'),\n", + " (0.5573927404203949, 'MY'),\n", + " (17.97116633936847, 'ML'),\n", + " (65.1026238860145, 'MT'),\n", + " (14.724954619463576, 'MQ'),\n", + " (90.4399250141566, 'MR'),\n", + " (3.337113643, 'MU'),\n", + " (0.0, 'YT'),\n", + " (33.57793114310919, 'MX'),\n", + " (2.1762822204839907, 'MD'),\n", + " (3.041993431, 'MC'),\n", + " (21.853972240933107, 'MN'),\n", + " (1.1683761128406958, 'ME'),\n", + " (10.45098999, 'MS'),\n", + " (87.35252045847695, 'MA'),\n", + " (6.987530206273024, 'MZ'),\n", + " (5.463924365640522, 'MM'),\n", + " (22.043385274439363, 'NA'),\n", + " (14.185384858172197, 'NP'),\n", + " (1.2021270393448966, 'NL'),\n", + " (3.459762381994274, 'NC'),\n", + " (6.612839381474864, 'NZ'),\n", + " (1.345460360501996, 'NI'),\n", + " (8.66185440156322, 'NE'),\n", + " (8.923473503509143, 'NG'),\n", + " (2.7161357448341494, 'KP'),\n", + " (0.7572540703136722, 'NO'),\n", + " (14.38848180410625, 'OM'),\n", + " (58.44766681900599, 'PK'),\n", + " (0.6604112890570929, 'PA'),\n", + " (0.47596340061506925, 'PG'),\n", + " (1.3757958710166995, 'PY'),\n", + " (27.786641503516694, 'PE'),\n", + " (6.981908381895548, 'PH'),\n", + " (2.0160652030385107, 'PL'),\n", + " (50.884223130811925, 'PT'),\n", + " (9.385421907818303, 'PR'),\n", + " (49.51193068796642, 'QA'),\n", + " (7.392684862410681, 'RE'),\n", + " (3.98374096209284, 'RO'),\n", + " (12.517204967549324, 'RU'),\n", + " (74.85884452719728, 'RW'),\n", + " (0.9100331987223297, 'WS'),\n", + " (15.65697383, 'SM'),\n", + " (30.07901418402109, 'ST'),\n", + " (18.561459066825222, 'SA'),\n", + " (78.37955382951877, 'SN'),\n", + " (3.7616828578003543, 'RS'),\n", + " (1.1330029586922774, 'SL'),\n", + " (0.9263012563975874, 'SG'),\n", + " (1.274217457657727, 'SK'),\n", + " (1.173683733285171, 'SI'),\n", + " (0.8599889526089556, 'SB'),\n", + " (66.4556138255428, 'SO'),\n", + " (38.35347124026599, 'ZA'),\n", + " (0.8939803047196755, 'KR'),\n", + " (79.33437358182134, 'ES'),\n", + " (22.169594725925567, 'LK'),\n", + " (4.585908102, 'KN'),\n", + " (41.54708127, 'LC'),\n", + " (16.066780527137983, 'PM'),\n", + " (9.232881605, 'VC'),\n", + " (52.93602157148623, 'SD'),\n", + " (0.6551111303721703, 'SR'),\n", + " (45.42733786, 'SJ'),\n", + " (1.8253130513308697, 'SZ'),\n", + " (2.1165682768206553, 'SE'),\n", + " (0.9654023640101609, 'CH'),\n", + " (78.58676474200307, 'SY'),\n", + " (2.2258052399166144, 'TW'),\n", + " (71.580781543099, 'TJ'),\n", + " (13.706350636934776, 'TZ'),\n", + " (6.981634567110632, 'TH'),\n", + " (27.35628595871462, 'BS'),\n", + " (10.965959321090885, 'GM'),\n", + " (10.352282263427748, 'TG'),\n", + " (12.675336914389902, 'TO'),\n", + " (25.68477661387648, 'TT'),\n", + " (68.91146065662537, 'TN'),\n", + " (56.46029314767752, 'TR'),\n", + " (66.81676221137803, 'TM'),\n", + " (12.66219083, 'TC'),\n", + " (86.91517025369376, 'UG'),\n", + " (32.48622207233222, 'UA'),\n", + " (15.200247342633217, 'AE'),\n", + " (1.6121654673313333, 'GB'),\n", + " (33.12697202548858, 'US'),\n", + " (0.5421017305750162, 'UY'),\n", + " (72.11340698310264, 'UZ'),\n", + " (2.0534842504803934, 'VU'),\n", + " (5.954343548095184, 'VE'),\n", + " (12.098095914568045, 'VN'),\n", + " (14.6191233, 'VG'),\n", + " (56.33408095492583, 'EH'),\n", + " (47.01708842231054, 'YE'),\n", + " (5.6251672922035905, 'ZM'),\n", + " (4.683723042670664, 'ZW'),\n", + " (42.953530866940355, 'GLO'),\n", + " (40.9641, 'RER'),\n", + " (71.60061, 'RAF'),\n", + " (42.21324, 'RAS'),\n", + " (31.09006, 'RLA'),\n", + " (32.72436, 'RNA'),\n", + " (59.81223, 'RME'),\n", + " (42.52015, 'ENTSO-E'),\n", + " (68.29584, 'UN-OCEANIA')]" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cfs = []\n", + "reached_zimbabwe = False\n", + "\n", + "FIXES = {\n", + " 'Raunion': 'Reunion',\n", + " 'OCEANIA': 'UN-OCEANIA',\n", + " 'ENTSOE': 'ENTSO-E'\n", + "}\n", + "IGNORE = {'World AGRI', 'World NON-AGRI', 'Europe-CH', 'RoW',\"BRIC\",\"BRICS\",\"OECD\",\"OECD+BRIC\",\"OECD+BRICS\",\"CS\",\"PS\", \"REGIONS\"}\n", + "\n", + "for row_dict in df.to_dict(orient=\"records\"):\n", + " if not isinstance(row_dict['Unnamed: 0'], str) and math.isnan(row_dict['Unnamed: 0']):\n", + " continue\n", + " if not reached_zimbabwe:\n", + " cfs.append((\n", + " row_dict['Agg_CF_unspecified'],\n", + " coco.convert(names=[FIXES.get(row_dict['Unnamed: 0'], row_dict['Unnamed: 0'])], to='ISO2'),\n", + " ))\n", + " if row_dict['Unnamed: 0'] == 'Zimbabwe':\n", + " reached_zimbabwe = True\n", + " else:\n", + " if row_dict['Unnamed: 0'] == 'World, UNKNOWN':\n", + " cfs.append((\n", + " row_dict['Agg_CF_irri'],\n", + " \"GLO\",\n", + " ))\n", + " elif row_dict['Unnamed: 0'] in IGNORE:\n", + " continue\n", + " else:\n", + " cfs.append((\n", + " row_dict['Agg_CF_unspecified'],\n", + " FIXES.get(row_dict['Unnamed: 0'], row_dict['Unnamed: 0']),\n", + " ))\n", + "\n", + "cfs" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "caa805c4-388e-4e4f-ab42-508f1fda9081", + "metadata": { + "collapsed": true, + "jupyter": { + "outputs_hidden": true + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[Project: 2.5 examples in action,\n", + " Project: 3.10-test-import-bio,\n", + " Project: 36 APOS test,\n", + " Project: 371 APOS test,\n", + " Project: 38 APOS test,\n", + " Project: __ecoinvent__project__,\n", + " Project: ab-dev-test,\n", + " Project: agribalyse-3.1.1 transformations,\n", + " Project: Agrifootprint - economic - 2022,\n", + " Project: agrifootprint-2022-import,\n", + " Project: agrobalyse-3.1.1 import test,\n", + " Project: agrobalyse-3.1.1 randonneur,\n", + " Project: agrobalyse-3.1.1 transformations,\n", + " Project: another-one,\n", + " Project: check-units-bug,\n", + " Project: Cytiva,\n", + " Project: DARE,\n", + " Project: default,\n", + " Project: dmeo-marin,\n", + " Project: ecoinvent 3.8 cutoff bw2,\n", + " Project: ecoinvent-3.8-cutoff,\n", + " Project: ecoinvent-3.8-cutoff RS bug,\n", + " Project: ecoinvent-3.9.1-all,\n", + " Project: ecoinvent-3.9.1-consequential,\n", + " Project: ecoinvent-3.9.1-cutoff,\n", + " Project: ecoinvent-migration,\n", + " Project: ecoinvent-multiversion-cutoff,\n", + " Project: ecoinvent-multiversion-cutoff-base,\n", + " Project: ecoinvent-test-import,\n", + " Project: Exiobase 3.8.1 monetary,\n", + " Project: EXIOBASE regionalized case study,\n", + " Project: exiobase tests,\n", + " Project: FiBL analysis,\n", + " Project: forwast,\n", + " Project: from-the-ground-up,\n", + " Project: GSA for archetypes,\n", + " Project: hi-bas,\n", + " Project: IKEA SimaPro CSV import,\n", + " Project: ikea-base,\n", + " Project: import-directory,\n", + " Project: import-grouped-directory,\n", + " Project: import-with-migrations,\n", + " Project: IPCC 2021 OpenLCA,\n", + " Project: jsvg1,\n", + " Project: jsvg3,\n", + " Project: jsvg4,\n", + " Project: LC IMPACT case study,\n", + " Project: matchbox-example,\n", + " Project: mf-demo,\n", + " Project: mf-test-manual,\n", + " Project: moar-multi6,\n", + " Project: multi6,\n", + " Project: multifunctional-demo,\n", + " Project: multifunctional-example,\n", + " Project: multifunctional-manual,\n", + " Project: multifunctional-products-example,\n", + " Project: multifunctional_demo,\n", + " Project: other,\n", + " Project: porto,\n", + " Project: sandwich,\n", + " Project: Sanofi,\n", + " Project: search-test,\n", + " Project: simapro-matching-attempt,\n", + " Project: simapro_import_multifunctional_import,\n", + " Project: simapro_migration,\n", + " Project: Simple calcs example BW25,\n", + " Project: Speed tests,\n", + " Project: spreadsheet,\n", + " Project: supply chain graph,\n", + " Project: to_dataframe,\n", + " Project: to_dataframe Exiobase 3.8.1 monetary,\n", + " Project: to_dataframe USEEIO,\n", + " Project: tutorial,\n", + " Project: US EEIO 1.1,\n", + " Project: US LCI import,\n", + " Project: USEEIO,\n", + " Project: USEEIO example,\n", + " Project: USEEIO-1.1,\n", + " Project: useeio-ex,\n", + " Project: xt-vector-test]" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sorted(bd.projects)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "9195885e-d0d3-49eb-b609-c5fee5aa13dc", + "metadata": {}, + "outputs": [], + "source": [ + "countries = {\n", + " x['location']\n", + " for x in bd.Database('ecoinvent-3.10-cutoff')\n", + " if (len(x['location']) == 2 and x['location'].upper() == x['location'])\n", + "}\n", + "\n", + "locations = {\n", + " x['location']\n", + " for x in bd.Database('ecoinvent-3.10-cutoff')\n", + " if not (len(x['location']) == 2 and x['location'].upper() == x['location'])\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "8781f546-f99e-4630-941f-f8b4f9c9dcb3", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'Canada without Quebec': 'CA',\n", + " 'Europe without Austria': 'RER',\n", + " 'Europe without Switzerland and Austria': 'RER',\n", + " 'Europe without Switzerland': 'RER',\n", + " 'Europe, without Russia and Türkiye': 'RER',\n", + " 'IAI Area, Africa': 'RAF',\n", + " 'IAI Area, Asia, without China and GCC': 'RAS',\n", + " 'IAI Area, EU27 & EFTA': 'RER',\n", + " 'IAI Area, Gulf Cooperation Council': 'RME',\n", + " 'IAI Area, North America': 'RNA',\n", + " 'IAI Area, Russia & RER w/o EU27 & EFTA': 'RU',\n", + " 'IAI Area, South America': 'RLA',\n", + " 'NORDEL': 'ENTSO-E',\n", + " 'North America without Quebec': 'RNA',\n", + " 'OCEANIA': 'UN-OCEANIA',\n", + " 'RER w/o CH+DE': 'RER',\n", + " 'RER w/o DE+NL+RU': 'RER',\n", + " 'RER w/o RU': 'RER',\n", + " 'RoE': 'RER',\n", + " 'RoW': 'GLO',\n", + " 'SAS': 'RAS',\n", + " 'UCTE without Germany': 'ENTSO-E',\n", + " 'UCTE': 'ENTSO-E',\n", + " 'WECC': 'US',\n", + " 'WEU': 'RER',\n", + " 'CN-SC': 'CN',\n", + " 'CN-NWG': 'CN',\n", + " 'IN-WB': 'IN',\n", + " 'US-PR': 'US',\n", + " 'BR-Northern grid': 'BR',\n", + " 'CN-HE': 'CN',\n", + " 'IN-CH': 'IN',\n", + " 'IN-GA': 'IN',\n", + " 'IN-Northern grid': 'IN',\n", + " 'AU-WA': 'AU',\n", + " 'IN-MH': 'IN',\n", + " 'CN-LN': 'CN',\n", + " 'CN-GX': 'CN',\n", + " 'CN-JL': 'CN',\n", + " 'US-WA': 'US',\n", + " 'CN-SA': 'CN',\n", + " 'CN-CSG': 'CN',\n", + " 'CA-NB': 'CA',\n", + " 'BR-North-eastern grid': 'BR',\n", + " 'IN-SK': 'IN',\n", + " 'IN-AR': 'IN',\n", + " 'IN-PB': 'IN',\n", + " 'US-SERC': 'US',\n", + " 'CN-YN': 'CN',\n", + " 'IN-TN': 'IN',\n", + " 'CN-QH': 'CN',\n", + " 'IN-RJ': 'IN',\n", + " 'BR-AM': 'BR',\n", + " 'BR-PA': 'BR',\n", + " 'BR-PE': 'BR',\n", + " 'CA-SK': 'CA',\n", + " 'CN-NECG': 'CN',\n", + " 'US-MN': 'US',\n", + " 'CA-NT': 'CA',\n", + " 'CA-NF': 'CA',\n", + " 'US-CA': 'US',\n", + " 'IN-MP': 'IN',\n", + " 'AU-QLD': 'AU',\n", + " 'BR-TO': 'BR',\n", + " 'CN-CQ': 'CN',\n", + " 'CN-HU': 'CN',\n", + " 'BR-AC': 'BR',\n", + " 'BR-SE': 'BR',\n", + " 'CN-ECGC': 'CN',\n", + " 'CN-NM': 'CN',\n", + " 'BR-MA': 'BR',\n", + " 'CN-GS': 'CN',\n", + " 'BR-MS': 'BR',\n", + " 'US-OH': 'US',\n", + " 'CN-GD': 'CN',\n", + " 'IN-UP': 'IN',\n", + " 'US-IA': 'US',\n", + " 'CA-NS': 'CA',\n", + " 'CN-AH': 'CN',\n", + " 'BR-AL': 'BR',\n", + " 'US-ND': 'US',\n", + " 'BR-PR': 'BR',\n", + " 'CN-FJ': 'CN',\n", + " 'US-HICC': 'US',\n", + " 'IN-PY': 'IN',\n", + " 'US-ASCC': 'US',\n", + " 'IN-Eastern grid': 'IN',\n", + " 'US-CO': 'US',\n", + " 'AU-TAS': 'AU',\n", + " 'CA-AB': 'CA',\n", + " 'CN-HL': 'CN',\n", + " 'IN-DL': 'IN',\n", + " 'CA-PE': 'CA',\n", + " 'US-FL': 'US',\n", + " 'BR-PB': 'BR',\n", + " 'BR-RS': 'BR',\n", + " 'CA-NU': 'CA',\n", + " 'CN-CCG': 'CN',\n", + " 'IN-KA': 'IN',\n", + " 'IN-Southern grid': 'IN',\n", + " 'IN-BR': 'IN',\n", + " 'CN-HN': 'CN',\n", + " 'CN-GZ': 'CN',\n", + " 'BR-RO': 'BR',\n", + " 'CN-TJ': 'CN',\n", + " 'IN-MN': 'IN',\n", + " 'US-OR': 'US',\n", + " 'CN-SH': 'CN',\n", + " 'IN-AP': 'IN',\n", + " 'CA-MB': 'CA',\n", + " 'IN-CT': 'IN',\n", + " 'CN-NCGC': 'CN',\n", + " 'US-WI': 'US',\n", + " 'US-SD': 'US',\n", + " 'BR-MT': 'BR',\n", + " 'IN-GJ': 'IN',\n", + " 'BR-GO': 'BR',\n", + " 'IN-OR': 'IN',\n", + " 'CN-SD': 'CN',\n", + " 'BR-BA': 'BR',\n", + " 'CN-JX': 'CN',\n", + " 'BR-RJ': 'BR',\n", + " 'CN-ZJ': 'CN',\n", + " 'CA-YK': 'CA',\n", + " 'US-IL': 'US',\n", + " 'IN-JH': 'IN',\n", + " 'BR-SP': 'BR',\n", + " 'AU-VIC': 'AU',\n", + " 'IN-DD': 'IN',\n", + " 'BR-AP': 'BR',\n", + " 'US-IN': 'US',\n", + " 'US-RFC': 'US',\n", + " 'IN-HP': 'IN',\n", + " 'BR-MG': 'BR',\n", + " 'BR-RR': 'BR',\n", + " 'IN-Western grid': 'IN',\n", + " 'BR-DF': 'BR',\n", + " 'IN-ML': 'IN',\n", + " 'BR-PI': 'BR',\n", + " 'US-ID': 'US',\n", + " 'BR-ES': 'BR',\n", + " 'IN-North-eastern grid': 'IN',\n", + " 'BR-South-eastern/Mid-western grid': 'BR',\n", + " 'IN-AS': 'IN',\n", + " 'CN-SGCC': 'CN',\n", + " 'IN-DN': 'IN',\n", + " 'CN-XZ': 'CN',\n", + " 'CN-XJ': 'CN',\n", + " 'US-WECC': 'US',\n", + " 'CN-HA': 'CN',\n", + " 'IN-HR': 'IN',\n", + " 'AU-NSW': 'AU',\n", + " 'BR-CE': 'BR',\n", + " 'CA-BC': 'CA',\n", + " 'US-NPCC': 'US',\n", + " 'IN-JK': 'IN',\n", + " 'CN-BJ': 'CN',\n", + " 'IN-MZ': 'IN',\n", + " 'US-TRE': 'US',\n", + " 'CA-ON': 'CA',\n", + " 'CN-NX': 'CN',\n", + " 'CN-JS': 'CN',\n", + " 'BR-SC': 'BR',\n", + " 'CN-HB': 'CN',\n", + " 'BR-RN': 'BR',\n", + " 'US-NE': 'US',\n", + " 'CN-SWG': 'CN',\n", + " 'IN-TR': 'IN',\n", + " 'IN-UT': 'IN',\n", + " 'CN-SX': 'CN',\n", + " 'IN-NL': 'IN',\n", + " 'US-MRO': 'US',\n", + " 'IN-KL': 'IN',\n", + " 'CA-QC': 'CA',\n", + " 'BR-Southern grid': 'BR',\n", + " 'AU-SA': 'AU'}" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "mapping = {\n", + " 'Canada without Quebec': 'CA',\n", + " 'Europe without Austria': 'RER',\n", + " 'Europe without Switzerland and Austria': 'RER',\n", + " 'Europe without Switzerland': 'RER',\n", + " 'Europe, without Russia and Türkiye': 'RER',\n", + " 'IAI Area, Africa': 'RAF',\n", + " 'IAI Area, Asia, without China and GCC': 'RAS',\n", + " 'IAI Area, EU27 & EFTA': 'RER',\n", + " 'IAI Area, Gulf Cooperation Council': 'RME',\n", + " 'IAI Area, North America': 'RNA',\n", + " 'IAI Area, Russia & RER w/o EU27 & EFTA': 'RU',\n", + " 'IAI Area, South America': 'RLA',\n", + " 'NORDEL': 'ENTSO-E',\n", + " 'North America without Quebec': 'RNA',\n", + " 'OCEANIA': 'UN-OCEANIA',\n", + " 'RER w/o CH+DE': 'RER',\n", + " 'RER w/o DE+NL+RU': 'RER',\n", + " 'RER w/o RU': 'RER',\n", + " 'RoE': 'RER',\n", + " 'RoW': 'GLO',\n", + " 'SAS': 'RAS',\n", + " 'UCTE without Germany': 'ENTSO-E',\n", + " 'UCTE': 'ENTSO-E',\n", + " 'WECC': 'US',\n", + " 'WEU': 'RER',\n", + "}\n", + "\n", + "for location in locations:\n", + " if location in mapping:\n", + " continue\n", + " elif len(location) > 3 and location[2] == \"-\" and location[:2] in countries:\n", + " mapping[location] = location[:2]\n", + " else:\n", + " continue\n", + "\n", + "mapping" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "44ea71cf-b21f-4f9d-8ad4-45dafbdaa8ff", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['Water, cooling, unspecified natural origin' (cubic meter, None, ('natural resource', 'in water')),\n", + " 'Water, unspecified natural origin' (cubic meter, None, ('natural resource', 'in water')),\n", + " 'Water, unspecified natural origin' (cubic meter, None, ('natural resource', 'in ground')),\n", + " 'Water, well, in ground' (cubic meter, None, ('natural resource', 'in water')),\n", + " 'Water, turbine use, unspecified natural origin' (cubic meter, None, ('natural resource', 'in water')),\n", + " 'Water, lake' (cubic meter, None, ('natural resource', 'in water')),\n", + " 'Water, in air' (cubic meter, None, ('natural resource', 'in air')),\n", + " 'Water, unspecified natural origin' (cubic meter, None, ('natural resource', 'fossil well')),\n", + " 'Water, river' (cubic meter, None, ('natural resource', 'in water'))]" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "consumption = [\n", + " x \n", + " for x in bd.Database('ecoinvent-3.10-biosphere') \n", + " if x['name'].lower().startswith(\"water\")\n", + " and not x['name'].lower().startswith(\"water, salt\")\n", + " and x['categories'][0] == 'natural resource'\n", + "]\n", + "consumption" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "a4ace76f-8565-462e-90ce-409599fa268f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['Water' (cubic meter, None, ('water', 'ground-')),\n", + " 'Water' (cubic meter, None, ('water', 'ocean')),\n", + " 'Water' (cubic meter, None, ('water',)),\n", + " 'Water' (cubic meter, None, ('water', 'surface water'))]" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "release = [\n", + " x \n", + " for x in bd.Database('ecoinvent-3.10-biosphere') \n", + " if x['name'].lower().startswith(\"water\")\n", + " and not x['name'].lower().startswith(\"water, salt\")\n", + " and x['categories'][0] != 'natural resource'\n", + " and x['categories'][0] != 'air'\n", + " and x['categories'] != ('water', 'ground-, long-term')\n", + " and x['categories'] != ('water', 'fossil well')\n", + "]\n", + "release" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "9744b248-e817-44d8-be46-0a3eb703beae", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['ecoinvent-3.8-biosphere',\n", + " 'ecoinvent-3.8-cutoff',\n", + " 'ecoinvent-3.10-biosphere',\n", + " 'ecoinvent-3.10-cutoff',\n", + " 'generic-regionalized-biosphere-proxies',\n", + " 'generic_simapro_ecoinvent_biosphere_placeholders',\n", + " 'agribalyse-3.1.1-biosphere-placeholders',\n", + " 'agribalyse-3.1.1']" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "list(bd.databases)" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "5e3a0d8a-0df3-49d8-9c08-a1ef705be32a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\u001b[0;31mSignature:\u001b[0m \u001b[0mtempfile\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmkdtemp\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msuffix\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mprefix\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdir\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mDocstring:\u001b[0m\n", + "User-callable function to create and return a unique temporary\n", + "directory. The return value is the pathname of the directory.\n", + "\n", + "Arguments are as for mkstemp, except that the 'text' argument is\n", + "not accepted.\n", + "\n", + "The directory is readable, writable, and searchable only by the\n", + "creating user.\n", + "\n", + "Caller is responsible for deleting the directory when done with it.\n", + "\u001b[0;31mFile:\u001b[0m /opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/tempfile.py\n", + "\u001b[0;31mType:\u001b[0m function" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "url = \"https://wulca-waterlca.org/wordpress/wp-content/uploads/AWARE_watersheds_v12_20240531.xlsx\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "107d7fe5-57ae-4fed-863f-6987223f3b7a", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.10" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/dev/Use simple_regionalize library for LCA.ipynb b/dev/Use simple_regionalize library for LCA.ipynb new file mode 100644 index 0000000..703fe62 --- /dev/null +++ b/dev/Use simple_regionalize library for LCA.ipynb @@ -0,0 +1,33 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "c505513f-59da-4a4e-8204-b7d98c5b134a", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.10" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}