diff --git a/dev/subshares.ipynb b/dev/subshares.ipynb index 2368e4a..c84c9ca 100644 --- a/dev/subshares.ipynb +++ b/dev/subshares.ipynb @@ -33,104 +33,50 @@ "Calculating LCA results for image...\n", "--- Calculating LCA results for SSP2-RCP26...\n", "------ Calculating LCA results for 2020...\n", - "2020\n", - "defaultdict(,\n", - " {2020: {'offshore': array([0.04, 0.04, 0.04]),\n", - " 'onshore': array([0.96, 0.96, 0.96])},\n", - " 2050: {'offshore': array([0.07197986, 0.12667779, 0.07491512]),\n", - " 'onshore': array([0.92802014, 0.87332221, 0.92508488])},\n", - " 'iterations': {'offshore': array([0.04, 0.04, 0.04]),\n", - " 'onshore': array([0.96, 0.96, 0.96])}})\n", - "2020\n", - "defaultdict(,\n", - " {2020: {'CdTe': array([1., 1., 1.])},\n", - " 2050: {'CdTe': array([1., 1., 1.])},\n", - " 'iterations': {'CdTe': array([1., 1., 1.])}})\n", - "2020\n", - "defaultdict(,\n", - " {2020: {'Parabolic trough': array([0.9474, 0.9474, 0.9474]),\n", - " 'Solar tower': array([0.0526, 0.0526, 0.0526])},\n", - " 2050: {'Parabolic trough': array([0.63338298, 0.76008786, 0.77731747]),\n", - " 'Solar tower': array([0.36661702, 0.23991214, 0.22268253])},\n", - " 'iterations': {'Parabolic trough': array([0.9474, 0.9474, 0.9474]),\n", - " 'Solar tower': array([0.0526, 0.0526, 0.0526])}})\n", - "2020\n", - "defaultdict(,\n", - " {2020: {'PEMFC': array([0.22229259, 0.22229259, 0.22229259]),\n", - " 'SOFC': array([0.77770741, 0.77770741, 0.77770741])},\n", - " 2050: {'PEMFC': array([0.80505809, 0.73347929, 0.70750135]),\n", - " 'SOFC': array([0.19494191, 0.26652071, 0.29249865])},\n", - " 'iterations': {'PEMFC': array([0.22229259, 0.22229259, 0.22229259]),\n", - " 'SOFC': array([0.77770741, 0.77770741, 0.77770741])}})\n", - "2020\n", - "defaultdict(,\n", - " {2020: {'Alkaline': array([0.5, 0.5, 0.5]),\n", - " 'HTEL': array([0., 0., 0.]),\n", - " 'PEM': array([0.5, 0.5, 0.5])},\n", - " 2050: {'Alkaline': array([0.22181628, 0.14474255, 0.24808046]),\n", - " 'HTEL': array([0.04274038, 0.19890939, 0.16232023]),\n", - " 'PEM': array([0.73544334, 0.65634806, 0.5895993 ])},\n", - " 'iterations': {'Alkaline': array([0.5, 0.5, 0.5]),\n", - " 'HTEL': array([0., 0., 0.]),\n", - " 'PEM': array([0.5, 0.5, 0.5])}})\n", - "2020\n", - "defaultdict(,\n", - " {2020: {'LFP': array([0.1, 0.1, 0.1]),\n", - " 'LiO2': array([0., 0., 0.]),\n", - " 'LiS': array([0., 0., 0.]),\n", - " 'NCA': array([0.15, 0.15, 0.15]),\n", - " 'NMC111': array([0.25, 0.25, 0.25]),\n", - " 'NMC622': array([0.45, 0.45, 0.45]),\n", - " 'NMC811': array([0.05, 0.05, 0.05])},\n", - " 2050: {'LFP': array([0.01490531, 0.03677916, 0.04587964]),\n", - " 'LiO2': array([0.01717775, 0.0336887 , 0.05250553]),\n", - " 'LiS': array([0.04732641, 0.47653196, 0.40347854]),\n", - " 'NCA': array([0.05107914, 0.00352378, 0.02380962]),\n", - " 'NMC111': array([0.01781157, 0.05184884, 0.08362759]),\n", - " 'NMC622': array([0.25666271, 0.14400881, 0.18811953]),\n", - " 'NMC811': array([0.59503711, 0.25361875, 0.20257956])},\n", - " 'iterations': {'LFP': array([0.1, 0.1, 0.1]),\n", - " 'LiO2': array([0., 0., 0.]),\n", - " 'LiS': array([0., 0., 0.]),\n", - " 'NCA': array([0.15, 0.15, 0.15]),\n", - " 'NMC111': array([0.25, 0.25, 0.25]),\n", - " 'NMC622': array([0.45, 0.45, 0.45]),\n", - " 'NMC811': array([0.05, 0.05, 0.05])}})\n", - "2020\n", - "defaultdict(,\n", - " {2020: {'LFP': array([0.42105263, 0.42105263, 0.42105263]),\n", - " 'Lead-Acid': array([0.10526316, 0.10526316, 0.10526316]),\n", - " 'NMC111': array([0.25263158, 0.25263158, 0.25263158]),\n", - " 'NMC622': array([0.13684211, 0.13684211, 0.13684211]),\n", - " 'NMC811': array([0.03157895, 0.03157895, 0.03157895]),\n", - " 'Redox-Flow': array([0.05263158, 0.05263158, 0.05263158])},\n", - " 2050: {'LFP': array([0.3434829 , 0.32235328, 0.23840098]),\n", - " 'Lead-Acid': array([0.07372081, 0.07042809, 0.04798316]),\n", - " 'NMC111': array([0.04479395, 0.05938282, 0.05640826]),\n", - " 'NMC622': array([0.21917672, 0.11116744, 0.0949993 ]),\n", - " 'NMC811': array([0.25823102, 0.32356371, 0.32964067]),\n", - " 'Redox-Flow': array([0.06059459, 0.11310466, 0.23256763])},\n", - " 'iterations': {'LFP': array([0.42105263, 0.42105263, 0.42105263]),\n", - " 'Lead-Acid': array([0.10526316, 0.10526316, 0.10526316]),\n", - " 'NMC111': array([0.25263158, 0.25263158, 0.25263158]),\n", - " 'NMC622': array([0.13684211, 0.13684211, 0.13684211]),\n", - " 'NMC811': array([0.03157895, 0.03157895, 0.03157895]),\n", - " 'Redox-Flow': array([0.05263158, 0.05263158, 0.05263158])}})\n" + "[[( 6304, 165)]\n", + " [(17485, 165)]\n", + " [( 6304, 17141)]\n", + " ...\n", + " [(11306, 35993)]\n", + " [( 9343, 35993)]\n", + " [( 391, 35993)]]\n", + "[[1.14694505e-04 1.14694505e-04 1.14694505e-04]\n", + " [4.77893773e-06 4.77893773e-06 4.77893773e-06]\n", + " [3.24130007e-06 3.24130007e-06 3.24130007e-06]\n", + " ...\n", + " [6.12244921e-10 6.12244921e-10 6.12244921e-10]\n", + " [2.04081640e-09 2.04081640e-09 2.04081640e-09]\n", + " [8.16326562e-09 8.16326562e-09 8.16326562e-09]]\n" ] }, { - "ename": "AttributeError", - "evalue": "'str' object has no attribute 'items'", + "name": "stderr", + "output_type": "stream", + "text": [ + "0% [#] 100% | ETA: 00:00:01\n", + "Total time elapsed: 00:00:00\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "------ Calculating LCA results for 2030...\n" + ] + }, + { + "ename": "ValueError", + "evalue": "Expected 4 filepaths, got 0", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[2], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mnumpy\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mnp\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \u001b[43mp\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcalculate\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 3\u001b[0m \u001b[43m \u001b[49m\u001b[43mmethods\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\n\u001b[1;32m 4\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;66;43;03m#'IPCC 2021 - climate change - GWP 100a, incl. H',\u001b[39;49;00m\n\u001b[1;32m 5\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mIPCC 2021 - climate change - GWP 100a, incl. H and bio CO2\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 6\u001b[0m \u001b[43m \u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m#+ [m for m in p.lcia_methods if \"relics\" in m.lower()][-3:],\u001b[39;49;00m\n\u001b[1;32m 7\u001b[0m \u001b[43m \u001b[49m\u001b[43mregions\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mCH\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 8\u001b[0m \u001b[43m \u001b[49m\u001b[43mscenarios\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\n\u001b[1;32m 9\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;66;43;03m#\"SSP2-Base\",\u001b[39;49;00m\n\u001b[1;32m 10\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mSSP2-RCP26\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 11\u001b[0m \u001b[43m \u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 12\u001b[0m \u001b[43m \u001b[49m\u001b[43mvariables\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\n\u001b[1;32m 13\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhydro_run_of_river\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 14\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhydro (reservoir)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 15\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhydro (pumped storage)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 16\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mnuclear (boiling water)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 17\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mnuclear (pressure water)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 18\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43moil (peak devices)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 19\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43moil (DH CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 20\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43moil (industry CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 21\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (CCGT)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 22\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (OCGT)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 23\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (CCGT CCS)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 24\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (CHP DH)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 25\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (fuel cell DH)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 26\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (CHP industry)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 27\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (CHP CCS industry)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 28\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (CHP fuel cell reformer)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 29\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (CHP single family)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 30\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (single family CHP fuel cell)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 31\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (multi family CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 32\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (multi family CHP fuel cell)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 33\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbiogas (services CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 34\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (services CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 35\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (services CHP fuel cell)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 36\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, fossil\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 37\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, fossil (CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 38\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, fossil (industrial)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 39\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, fossil (CCS)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 40\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, fossil (CHP, CCS)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 41\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, fossil (industrial, CCS)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 42\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, non-fossil\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 43\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, non-fossil (CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 44\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, non-fossil (industrial)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 45\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, non-fossil (CCS)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 46\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, non-fossil (CHP, CCS)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 47\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, non-fossil (industrial, CCS)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 48\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mpv (large scale)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 49\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mpv (industry)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 50\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mpv (services)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 51\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mpv residential (multi family)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 52\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mpv residential (single family)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 53\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwind\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 54\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgeothermal\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 55\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhydrogen fuel cell (DH CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 56\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhydrogen fuel cell (industrial CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 57\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhydrogen fuel cell (services CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 58\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbiomass (DH)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 59\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbiomass (CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 60\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbiomass (CCS, BECCS)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 61\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbiomass (CCS, industrial)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 62\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbattery (large)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 63\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbattery (medium)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 64\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbattery (industry)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 65\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbattery (services)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 66\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbattery (single family)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 67\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbattery (multi family)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 68\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mCAES\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 69\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mimport\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 70\u001b[0m \u001b[43m \u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 71\u001b[0m \u001b[43m \u001b[49m\u001b[43myears\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\n\u001b[1;32m 72\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m2020\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 73\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;66;43;03m#2022,\u001b[39;49;00m\n\u001b[1;32m 74\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;66;43;03m#2030,\u001b[39;49;00m\n\u001b[1;32m 75\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;66;43;03m#2040,\u001b[39;49;00m\n\u001b[1;32m 76\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m2050\u001b[39;49m\n\u001b[1;32m 77\u001b[0m \u001b[43m \u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 78\u001b[0m \u001b[43m \u001b[49m\u001b[43mmultiprocessing\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 79\u001b[0m \u001b[43m \u001b[49m\u001b[43muse_distributions\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m3\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 80\u001b[0m \u001b[43m \u001b[49m\u001b[43msubshares\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\n\u001b[1;32m 81\u001b[0m \u001b[43m)\u001b[49m\n", - "File \u001b[0;32m~/GitHub/pathways/pathways/pathways.py:389\u001b[0m, in \u001b[0;36mPathways.calculate\u001b[0;34m(self, methods, models, scenarios, regions, years, variables, multiprocessing, demand_cutoff, use_distributions, subshares)\u001b[0m\n\u001b[1;32m 379\u001b[0m results\u001b[38;5;241m.\u001b[39mupdate(\n\u001b[1;32m 380\u001b[0m {\n\u001b[1;32m 381\u001b[0m (model, scenario, year): result\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 385\u001b[0m }\n\u001b[1;32m 386\u001b[0m )\n\u001b[1;32m 387\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 388\u001b[0m results\u001b[38;5;241m.\u001b[39mupdate(\n\u001b[0;32m--> 389\u001b[0m \u001b[43m{\u001b[49m\n\u001b[1;32m 390\u001b[0m \u001b[43m \u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mscenario\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43myear\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43m_calculate_year\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 391\u001b[0m \u001b[43m \u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 392\u001b[0m \u001b[43m \u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 393\u001b[0m \u001b[43m \u001b[49m\u001b[43mscenario\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 394\u001b[0m \u001b[43m \u001b[49m\u001b[43myear\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 395\u001b[0m \u001b[43m \u001b[49m\u001b[43mregions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 396\u001b[0m \u001b[43m \u001b[49m\u001b[43mvariables\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 397\u001b[0m \u001b[43m \u001b[49m\u001b[43mmethods\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 398\u001b[0m \u001b[43m \u001b[49m\u001b[43mdemand_cutoff\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 399\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfilepaths\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 400\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmapping\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 401\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43munits\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 402\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlca_results\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 403\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mclassifications\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 404\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mscenarios\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 405\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mreverse_classifications\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 406\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdebug\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 407\u001b[0m \u001b[43m \u001b[49m\u001b[43muse_distributions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 408\u001b[0m \u001b[43m \u001b[49m\u001b[43msubshares\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 409\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 410\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 411\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43myear\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43myears\u001b[49m\n\u001b[1;32m 412\u001b[0m \u001b[43m \u001b[49m\u001b[43m}\u001b[49m\n\u001b[1;32m 413\u001b[0m )\n\u001b[1;32m 415\u001b[0m \u001b[38;5;66;03m# remove None values in results\u001b[39;00m\n\u001b[1;32m 416\u001b[0m results \u001b[38;5;241m=\u001b[39m {k: v \u001b[38;5;28;01mfor\u001b[39;00m k, v \u001b[38;5;129;01min\u001b[39;00m results\u001b[38;5;241m.\u001b[39mitems() \u001b[38;5;28;01mif\u001b[39;00m v \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m}\n", - "File \u001b[0;32m~/GitHub/pathways/pathways/pathways.py:390\u001b[0m, in \u001b[0;36m\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 379\u001b[0m results\u001b[38;5;241m.\u001b[39mupdate(\n\u001b[1;32m 380\u001b[0m {\n\u001b[1;32m 381\u001b[0m (model, scenario, year): result\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 385\u001b[0m }\n\u001b[1;32m 386\u001b[0m )\n\u001b[1;32m 387\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 388\u001b[0m results\u001b[38;5;241m.\u001b[39mupdate(\n\u001b[1;32m 389\u001b[0m {\n\u001b[0;32m--> 390\u001b[0m (model, scenario, year): \u001b[43m_calculate_year\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 391\u001b[0m \u001b[43m \u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 392\u001b[0m \u001b[43m \u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 393\u001b[0m \u001b[43m \u001b[49m\u001b[43mscenario\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 394\u001b[0m \u001b[43m \u001b[49m\u001b[43myear\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 395\u001b[0m \u001b[43m \u001b[49m\u001b[43mregions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 396\u001b[0m \u001b[43m \u001b[49m\u001b[43mvariables\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 397\u001b[0m \u001b[43m \u001b[49m\u001b[43mmethods\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 398\u001b[0m \u001b[43m \u001b[49m\u001b[43mdemand_cutoff\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 399\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfilepaths\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 400\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmapping\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 401\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43munits\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 402\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlca_results\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 403\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mclassifications\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 404\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mscenarios\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 405\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mreverse_classifications\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 406\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdebug\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 407\u001b[0m \u001b[43m \u001b[49m\u001b[43muse_distributions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 408\u001b[0m \u001b[43m \u001b[49m\u001b[43msubshares\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 409\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 410\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 411\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m year \u001b[38;5;129;01min\u001b[39;00m years\n\u001b[1;32m 412\u001b[0m }\n\u001b[1;32m 413\u001b[0m )\n\u001b[1;32m 415\u001b[0m \u001b[38;5;66;03m# remove None values in results\u001b[39;00m\n\u001b[1;32m 416\u001b[0m results \u001b[38;5;241m=\u001b[39m {k: v \u001b[38;5;28;01mfor\u001b[39;00m k, v \u001b[38;5;129;01min\u001b[39;00m results\u001b[38;5;241m.\u001b[39mitems() \u001b[38;5;28;01mif\u001b[39;00m v \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m}\n", - "File \u001b[0;32m~/GitHub/pathways/pathways/lca.py:444\u001b[0m, in \u001b[0;36m_calculate_year\u001b[0;34m(args)\u001b[0m\n\u001b[1;32m 442\u001b[0m logging\u001b[38;5;241m.\u001b[39minfo(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCalculating LCA results with subshares.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 443\u001b[0m shares_indices \u001b[38;5;241m=\u001b[39m find_technology_indices(regions, technosphere_indices, geo)\n\u001b[0;32m--> 444\u001b[0m correlated_arrays \u001b[38;5;241m=\u001b[39m \u001b[43madjust_matrix_based_on_shares\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 445\u001b[0m \u001b[43m \u001b[49m\u001b[43mlca\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mshares_indices\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43muse_distributions\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43myear\u001b[49m\n\u001b[1;32m 446\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 447\u001b[0m bw_correlated \u001b[38;5;241m=\u001b[39m get_subshares_matrix(correlated_arrays)\n\u001b[1;32m 449\u001b[0m lca\u001b[38;5;241m.\u001b[39mpackages\u001b[38;5;241m.\u001b[39mappend(\n\u001b[1;32m 450\u001b[0m get_datapackage(bw_correlated)\n\u001b[1;32m 451\u001b[0m )\n", - "File \u001b[0;32m~/GitHub/pathways/pathways/subshares.py:254\u001b[0m, in \u001b[0;36madjust_matrix_based_on_shares\u001b[0;34m(lca, shares_dict, use_distributions, year)\u001b[0m\n\u001b[1;32m 250\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mTech group\u001b[39m\u001b[38;5;124m\"\u001b[39m, tech_category, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mshares: \u001b[39m\u001b[38;5;124m\"\u001b[39m, group_shares)\n\u001b[1;32m 251\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 252\u001b[0m group_shares \u001b[38;5;241m=\u001b[39m {\n\u001b[1;32m 253\u001b[0m tech: details\u001b[38;5;241m.\u001b[39mget(year, {})\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mvalue\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;241m0\u001b[39m)\n\u001b[0;32m--> 254\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m tech, details \u001b[38;5;129;01min\u001b[39;00m \u001b[43mtech\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mitems\u001b[49m()\n\u001b[1;32m 255\u001b[0m }\n\u001b[1;32m 256\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mTech group\u001b[39m\u001b[38;5;124m\"\u001b[39m, tech_category, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mshares: \u001b[39m\u001b[38;5;124m\"\u001b[39m, group_shares)\n\u001b[1;32m 258\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m product_idx \u001b[38;5;129;01min\u001b[39;00m all_product_indices:\n", - "\u001b[0;31mAttributeError\u001b[0m: 'str' object has no attribute 'items'" + "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[2], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mnumpy\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mnp\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \u001b[43mp\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcalculate\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 3\u001b[0m \u001b[43m \u001b[49m\u001b[43mmethods\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\n\u001b[1;32m 4\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;66;43;03m#'IPCC 2021 - climate change - GWP 100a, incl. H',\u001b[39;49;00m\n\u001b[1;32m 5\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mIPCC 2021 - climate change - GWP 100a, incl. H and bio CO2\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 6\u001b[0m \u001b[43m \u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m#+ [m for m in p.lcia_methods if \"relics\" in m.lower()][-3:],\u001b[39;49;00m\n\u001b[1;32m 7\u001b[0m \u001b[43m \u001b[49m\u001b[43mregions\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mCH\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 8\u001b[0m \u001b[43m \u001b[49m\u001b[43mscenarios\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\n\u001b[1;32m 9\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;66;43;03m#\"SSP2-Base\",\u001b[39;49;00m\n\u001b[1;32m 10\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mSSP2-RCP26\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 11\u001b[0m \u001b[43m \u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 12\u001b[0m \u001b[43m \u001b[49m\u001b[43mvariables\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\n\u001b[1;32m 13\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhydro_run_of_river\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 14\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhydro (reservoir)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 15\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhydro (pumped storage)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 16\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mnuclear (boiling water)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 17\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mnuclear (pressure water)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 18\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43moil (peak devices)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 19\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43moil (DH CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 20\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43moil (industry CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 21\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (CCGT)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 22\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (OCGT)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 23\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (CCGT CCS)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 24\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (CHP DH)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 25\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (fuel cell DH)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 26\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (CHP industry)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 27\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (CHP CCS industry)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 28\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (CHP fuel cell reformer)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 29\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (CHP single family)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 30\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (single family CHP fuel cell)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 31\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (multi family CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 32\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (multi family CHP fuel cell)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 33\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbiogas (services CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 34\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (services CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 35\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgas (services CHP fuel cell)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 36\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, fossil\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 37\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, fossil (CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 38\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, fossil (industrial)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 39\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, fossil (CCS)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 40\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, fossil (CHP, CCS)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 41\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, fossil (industrial, CCS)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 42\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, non-fossil\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 43\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, non-fossil (CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 44\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, non-fossil (industrial)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 45\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, non-fossil (CCS)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 46\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, non-fossil (CHP, CCS)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 47\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwaste incineration, non-fossil (industrial, CCS)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 48\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mpv (large scale)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 49\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mpv (industry)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 50\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mpv (services)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 51\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mpv residential (multi family)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 52\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mpv residential (single family)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 53\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwind\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 54\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgeothermal\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 55\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhydrogen fuel cell (DH CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 56\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhydrogen fuel cell (industrial CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 57\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhydrogen fuel cell (services CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 58\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbiomass (DH)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 59\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbiomass (CHP)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 60\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbiomass (CCS, BECCS)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 61\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbiomass (CCS, industrial)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 62\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbattery (large)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 63\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbattery (medium)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 64\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbattery (industry)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 65\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbattery (services)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 66\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbattery (single family)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 67\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbattery (multi family)\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 68\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mCAES\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 69\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mimport\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 70\u001b[0m \u001b[43m \u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 71\u001b[0m \u001b[43m \u001b[49m\u001b[43myears\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\n\u001b[1;32m 72\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m2020\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 73\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;66;43;03m#2022,\u001b[39;49;00m\n\u001b[1;32m 74\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m2030\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 75\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;66;43;03m#2040,\u001b[39;49;00m\n\u001b[1;32m 76\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m2050\u001b[39;49m\n\u001b[1;32m 77\u001b[0m \u001b[43m \u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 78\u001b[0m \u001b[43m \u001b[49m\u001b[43mmultiprocessing\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 79\u001b[0m \u001b[43m \u001b[49m\u001b[43muse_distributions\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m3\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 80\u001b[0m \u001b[43m \u001b[49m\u001b[43msubshares\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\n\u001b[1;32m 81\u001b[0m \u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/GitHub/pathways/pathways/pathways.py:397\u001b[0m, in \u001b[0;36mPathways.calculate\u001b[0;34m(self, methods, models, scenarios, regions, years, variables, multiprocessing, demand_cutoff, use_distributions, subshares)\u001b[0m\n\u001b[1;32m 387\u001b[0m results\u001b[38;5;241m.\u001b[39mupdate(\n\u001b[1;32m 388\u001b[0m {\n\u001b[1;32m 389\u001b[0m (model, scenario, year): result\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 393\u001b[0m }\n\u001b[1;32m 394\u001b[0m )\n\u001b[1;32m 395\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 396\u001b[0m results\u001b[38;5;241m.\u001b[39mupdate(\n\u001b[0;32m--> 397\u001b[0m \u001b[43m{\u001b[49m\n\u001b[1;32m 398\u001b[0m \u001b[43m \u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mscenario\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43myear\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43m_calculate_year\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 399\u001b[0m \u001b[43m \u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 400\u001b[0m \u001b[43m \u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 401\u001b[0m \u001b[43m \u001b[49m\u001b[43mscenario\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 402\u001b[0m \u001b[43m \u001b[49m\u001b[43myear\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 403\u001b[0m \u001b[43m \u001b[49m\u001b[43mregions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 404\u001b[0m \u001b[43m \u001b[49m\u001b[43mvariables\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 405\u001b[0m \u001b[43m \u001b[49m\u001b[43mmethods\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 406\u001b[0m \u001b[43m \u001b[49m\u001b[43mdemand_cutoff\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 407\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfilepaths\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 408\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmapping\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 409\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43munits\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 410\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlca_results\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 411\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mclassifications\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 412\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mscenarios\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 413\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mreverse_classifications\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 414\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdebug\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 415\u001b[0m \u001b[43m \u001b[49m\u001b[43muse_distributions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 416\u001b[0m \u001b[43m \u001b[49m\u001b[43mshares\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 417\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 418\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 419\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43myear\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43myears\u001b[49m\n\u001b[1;32m 420\u001b[0m \u001b[43m \u001b[49m\u001b[43m}\u001b[49m\n\u001b[1;32m 421\u001b[0m )\n\u001b[1;32m 423\u001b[0m \u001b[38;5;66;03m# remove None values in results\u001b[39;00m\n\u001b[1;32m 424\u001b[0m results \u001b[38;5;241m=\u001b[39m {k: v \u001b[38;5;28;01mfor\u001b[39;00m k, v \u001b[38;5;129;01min\u001b[39;00m results\u001b[38;5;241m.\u001b[39mitems() \u001b[38;5;28;01mif\u001b[39;00m v \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m}\n", + "File \u001b[0;32m~/GitHub/pathways/pathways/pathways.py:398\u001b[0m, in \u001b[0;36m\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 387\u001b[0m results\u001b[38;5;241m.\u001b[39mupdate(\n\u001b[1;32m 388\u001b[0m {\n\u001b[1;32m 389\u001b[0m (model, scenario, year): result\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 393\u001b[0m }\n\u001b[1;32m 394\u001b[0m )\n\u001b[1;32m 395\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 396\u001b[0m results\u001b[38;5;241m.\u001b[39mupdate(\n\u001b[1;32m 397\u001b[0m {\n\u001b[0;32m--> 398\u001b[0m (model, scenario, year): \u001b[43m_calculate_year\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 399\u001b[0m \u001b[43m \u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 400\u001b[0m \u001b[43m \u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 401\u001b[0m \u001b[43m \u001b[49m\u001b[43mscenario\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 402\u001b[0m \u001b[43m \u001b[49m\u001b[43myear\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 403\u001b[0m \u001b[43m \u001b[49m\u001b[43mregions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 404\u001b[0m \u001b[43m \u001b[49m\u001b[43mvariables\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 405\u001b[0m \u001b[43m \u001b[49m\u001b[43mmethods\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 406\u001b[0m \u001b[43m \u001b[49m\u001b[43mdemand_cutoff\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 407\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfilepaths\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 408\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmapping\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 409\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43munits\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 410\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlca_results\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 411\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mclassifications\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 412\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mscenarios\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 413\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mreverse_classifications\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 414\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdebug\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 415\u001b[0m \u001b[43m \u001b[49m\u001b[43muse_distributions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 416\u001b[0m \u001b[43m \u001b[49m\u001b[43mshares\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 417\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 418\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 419\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m year \u001b[38;5;129;01min\u001b[39;00m years\n\u001b[1;32m 420\u001b[0m }\n\u001b[1;32m 421\u001b[0m )\n\u001b[1;32m 423\u001b[0m \u001b[38;5;66;03m# remove None values in results\u001b[39;00m\n\u001b[1;32m 424\u001b[0m results \u001b[38;5;241m=\u001b[39m {k: v \u001b[38;5;28;01mfor\u001b[39;00m k, v \u001b[38;5;129;01min\u001b[39;00m results\u001b[38;5;241m.\u001b[39mitems() \u001b[38;5;28;01mif\u001b[39;00m v \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m}\n", + "File \u001b[0;32m~/GitHub/pathways/pathways/lca.py:371\u001b[0m, in \u001b[0;36m_calculate_year\u001b[0;34m(args)\u001b[0m\n\u001b[1;32m 369\u001b[0m \u001b[38;5;66;03m# Try to load LCA matrices for the given model, scenario, and year\u001b[39;00m\n\u001b[1;32m 370\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 371\u001b[0m bw_datapackage, technosphere_indices, biosphere_indices \u001b[38;5;241m=\u001b[39m \u001b[43mget_lca_matrices\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 372\u001b[0m \u001b[43m \u001b[49m\u001b[43mfilepaths\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mscenario\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43myear\u001b[49m\n\u001b[1;32m 373\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 375\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mFileNotFoundError\u001b[39;00m:\n\u001b[1;32m 376\u001b[0m \u001b[38;5;66;03m# If LCA matrices can't be loaded, skip to the next iteration\u001b[39;00m\n\u001b[1;32m 377\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m debug:\n", + "File \u001b[0;32m~/GitHub/pathways/pathways/lca.py:163\u001b[0m, in \u001b[0;36mget_lca_matrices\u001b[0;34m(filepaths, model, scenario, year)\u001b[0m\n\u001b[1;32m 161\u001b[0m fps \u001b[38;5;241m=\u001b[39m filter_filepaths(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m.csv\u001b[39m\u001b[38;5;124m\"\u001b[39m, [model, scenario, \u001b[38;5;28mstr\u001b[39m(year)])\n\u001b[1;32m 162\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(fps) \u001b[38;5;241m!=\u001b[39m \u001b[38;5;241m4\u001b[39m:\n\u001b[0;32m--> 163\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mExpected 4 filepaths, got \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mlen\u001b[39m(fps)\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 165\u001b[0m fp_technosphere_inds \u001b[38;5;241m=\u001b[39m select_filepath(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mA_matrix_index\u001b[39m\u001b[38;5;124m\"\u001b[39m, fps)\n\u001b[1;32m 166\u001b[0m fp_biosphere_inds \u001b[38;5;241m=\u001b[39m select_filepath(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mB_matrix_index\u001b[39m\u001b[38;5;124m\"\u001b[39m, fps)\n", + "\u001b[0;31mValueError\u001b[0m: Expected 4 filepaths, got 0" ] } ], @@ -208,7 +154,7 @@ " years=[\n", " 2020,\n", " #2022,\n", - " #2030,\n", + " 2030,\n", " #2040,\n", " 2050\n", " ],\n", diff --git a/pathways/lca.py b/pathways/lca.py index d42c4eb..3e05643 100644 --- a/pathways/lca.py +++ b/pathways/lca.py @@ -442,7 +442,7 @@ def _calculate_year(args: tuple): logging.info("Calculating LCA results with subshares.") shares_indices = find_technology_indices(regions, technosphere_indices, geo) correlated_arrays = adjust_matrix_based_on_shares( - lca, shares_indices, use_distributions, year + lca, shares_indices, subshares, use_distributions, year ) bw_correlated = get_subshares_matrix(correlated_arrays) diff --git a/pathways/pathways.py b/pathways/pathways.py index a174470..e0eb330 100644 --- a/pathways/pathways.py +++ b/pathways/pathways.py @@ -31,6 +31,7 @@ load_units_conversion, resize_scenario_data, ) +from .subshares import generate_samples def _get_mapping(data) -> dict: @@ -344,6 +345,13 @@ def calculate( use_distributions=use_distributions > 0, ) + # generate share of sub-technologies + if subshares: + shares = generate_samples( + years=self.scenarios.coords["year"].values.tolist(), + iterations=use_distributions, + ) + # Iterate over each combination of model, scenario, and year results = {} for model in models: @@ -369,7 +377,7 @@ def calculate( self.reverse_classifications, self.debug, use_distributions, - subshares, + shares or None, ) for year in years ] @@ -405,7 +413,7 @@ def calculate( self.reverse_classifications, self.debug, use_distributions, - subshares, + shares or None, ) ) for year in years diff --git a/pathways/subshares.py b/pathways/subshares.py index 69edfe5..969c4f7 100644 --- a/pathways/subshares.py +++ b/pathways/subshares.py @@ -33,7 +33,7 @@ def load_subshares() -> dict: with open(SUBSHARES) as stream: data = yaml.safe_load(stream) - return adjust_subshares(check_uncertainty_params(data)) + return check_subshares(check_uncertainty_params(data)) def check_uncertainty_params(data): @@ -76,7 +76,7 @@ def check_uncertainty_params(data): return data -def adjust_subshares(data: dict) -> dict: +def check_subshares(data: dict) -> dict: """ Adjusts the values in 'data' for each year ensuring the sum equals 1 for each category, excluding technologies without a name. @@ -182,6 +182,7 @@ def get_subshares_matrix( def adjust_matrix_based_on_shares( lca: bw2calc.LCA, shares_dict: dict, + subshares: dict, use_distributions: int, year: int, ): @@ -194,10 +195,6 @@ def adjust_matrix_based_on_shares( :return: """ - modified_data = [] - modified_indices = [] - modified_signs = [] - # get coordinates of nonzero values in the technosphere matrix nz_row, nz_col = lca.technosphere_matrix.nonzero() @@ -212,150 +209,125 @@ def get_nz_col_indices(index): for region, technologies in regions.items(): for technology in technologies.values(): technology["consumer_idx"] = get_nz_col_indices(technology['idx']) - correlated_samples(ranges=technologies, year=year, iterations=use_distributions) + + list_indices, list_amounts = [], [] for tech_category, regions in shares_dict.items(): for region, technologies in regions.items(): - for tech in technologies.values(): + for name, tech in technologies.items(): for consumer in tech["consumer_idx"]: - logging.debug(f"Consumer: {consumer} receiving from {tech['idx']}: {lca.technosphere_matrix[tech['idx'], consumer]}") - total_amount = lca.technosphere_matrix[np.ix_( - np.array([tech["idx"] for tech in technologies.values()]), - np.hstack([tech["consumer_idx"] for tech in technologies.values()]), - )].sum() + initial_amount = lca.technosphere_matrix[tech["idx"], consumer] + amounts = initial_amount * subshares[tech_category][year][name] + list_indices.append([(tech["idx"], consumer)]) + list_amounts.append(amounts * -1) + for other_supplier, other_supplier_tech in technologies.items(): + if other_supplier != name: + amounts = initial_amount * subshares[tech_category][year][other_supplier] + list_indices.append([(other_supplier_tech["idx"], consumer)]) + list_amounts.append(amounts * -1) - logging.debug(f"Tech: {technologies}, Total amount: {total_amount}") + indices = np.array(list_indices, dtype=bwp.INDICES_DTYPE) + data = np.array(list_amounts) + signs = np.ones_like(indices, dtype=bool) + return data, indices, signs - for tech, details in tech.items(): - if year != 2020: - if details[2050]["distribution"] == "uniform": - tech_group_ranges[tech] = ( - details[2050]["min"], - details[year]["max"], - ) - tech_group_defaults[tech] = details.get(2020, {}).get( - "value", 0 - ) - else: - print( - "At this point, only uniform distributions are supported. Exiting." - ) - exit(1) - - if year != 2020 and tech_group_ranges: - group_shares = correlated_samples( - tech_group_ranges, tech_group_defaults - ) - print("Tech group", tech_category, "shares: ", group_shares) - else: - group_shares = { - tech: details.get(year, {}).get("value", 0) - for tech, details in tech.items() - } - print("Tech group", tech_category, "shares: ", group_shares) - - for product_idx in all_product_indices: - relevant_indices = [ - lca.dicts.product[idx] - for idx in all_tech_indices - if lca.dicts.product[idx] is not None - ] - total_output = np.sum( - lca.technosphere_matrix[product_idx, relevant_indices] - ) - - for tech, share in group_shares.items(): - if ( - tech in tech - and "idx" in tech[tech] - and tech[tech]["idx"] is not None - ): - idx = tech[tech]["idx"] - - if year == 2020: - share_value = details.get(year, {}).get("value", 0) - new_amounts = np.array( - [total_output * share_value] - ).reshape((1, -1)) - else: - new_amounts = np.array( - [total_output * share for _ in range(use_distributions)] - ).reshape((1, -1)) - index = find_index(idx, product_idx) - - if ( - index is not None - and product_idx not in unique_product_indices_from_dict - ): - modified_indices.append((idx, product_idx)) - modified_data.append(new_amounts) - modified_signs.append(sign_array[index]) - elif ( - index is None - and product_idx not in unique_product_indices_from_dict - ): - modified_data.append(new_amounts) - modified_indices.append((idx, product_idx)) - modified_signs.append(True) - - # modified_data_array = np.array(modified_data, dtype=object) - modified_data_array = np.concatenate(modified_data, axis=0) - modified_indices_array = np.array(modified_indices, dtype=bwp.INDICES_DTYPE) - modified_signs_array = np.array(modified_signs, dtype=bool) - - return [modified_data_array, modified_indices_array, modified_signs_array] - - -def correlated_samples(ranges: dict, year: int, iterations=10): - """ - Adjusts randomly selected shares for parameters to sum to 1 - while respecting their specified ranges. - :param ranges: Dict with parameter names as keys and (min, max) tuples as values. - :param defaults: Dict with default values for each parameter. - :param iterations: Number of iterations to attempt to find a valid distribution. - :return: A dict with the adjusted shares for each parameter. +def load_and_normalize_shares(ranges: dict, iterations: int) -> dict: + """ + Load and normalize shares for parameters to sum to 1 while respecting their specified ranges. + :param ranges: A dictionary with categories, technologies and market shares data. + :param iterations: Number of iterations for random generation. + :return: A dict with normalized shares for each technology and year. """ + shares = defaultdict(lambda: defaultdict(dict)) + for technology_group, technologies in ranges.items(): + for technology, params in technologies.items(): + for y, share in params["share"].items(): + uncertainty_base = UncertaintyBase.from_dicts(share) + random_generator = MCRandomNumberGenerator(uncertainty_base) + shares[technology_group][y][technology] = np.squeeze(np.array([random_generator.next() for _ in range(iterations)])) + + totals = defaultdict(lambda: np.array([])) + + for technology_group, years in shares.items(): + for year, technologies in years.items(): + arrays = [shares[technology_group][year][technology] for technology in technologies] + if len(arrays) > 0: + if year not in totals[(technology_group, year)]: + totals[(technology_group, year)] = np.sum(arrays, axis=0) + else: + totals[(technology_group, year)] += np.sum(arrays, axis=0) - shares = defaultdict(dict) - for technology, params in ranges.items(): - for y, share in params["share"].items(): - u = UncertaintyBase.from_dicts(share) - r = MCRandomNumberGenerator(u) - shares[y][technology] = np.array([r.next() for _ in range(iterations)]) - - for y in shares: - total = np.hstack([shares[y][technology] for technology in shares[y]]) - # normalize by the sum of all shares - shares[y] = {technology: np.clip( - np.squeeze(share) / total.sum(axis=1), - ranges[technology]["share"].get("min", 0), - ranges[technology]["share"].get("max", 1), - ) for technology, share in shares[y].items()} - - # interpolate the values to `year` - # find the lowest year - lowest_year = min(shares.keys()) - # find the highest year - highest_year = max(shares.keys()) - - # update the ranges with the new values - for technology, params in ranges.items(): - if year == lowest_year: - shares["iterations"][technology] = shares[lowest_year][technology] - elif year == highest_year: - shares["iterations"][technology] = shares[highest_year][technology] - else: - interpolator = interp1d( - [lowest_year, highest_year], - np.array([ - shares[lowest_year][technology], - shares[highest_year][technology] - ]), - axis=0 - ) - shares["iterations"][technology] = interpolator(year) + for technology_group, technologies in ranges.items(): + for technology, params in technologies.items(): + for y, share in params["share"].items(): + normalized = shares[technology_group][y][technology] / totals[(technology_group, y)] + normalized = np.clip( + normalized, + ranges[technology_group][technology]["share"][y].get("minimum", 0), + ranges[technology_group][technology]["share"][y].get("maximum", 1) + ) + shares[technology_group][y][technology] = normalized return shares + +def interpolate_shares(shares: dict, years: list) -> None: + """ + Interpolates missing years in the shares data. + :param shares: A dictionary with categories, technologies and market shares data. + :param years: List of years for which to interpolate shares. + :return: None + """ + for technology_group in shares: + all_years = sorted(shares[technology_group]) + for year in years: + if year in shares[technology_group]: + continue + lower_year = max((y for y in all_years if y <= year), default=None) + upper_year = min((y for y in all_years if y >= year), default=None) + if lower_year and upper_year: + interpolate_for_year(shares, technology_group, lower_year, upper_year, year) + + +def interpolate_for_year(shares: dict, technology_group: str, lower_year: int, upper_year: int, target_year: int) -> None: + """ + Interpolates shares for a specific year. + :param shares: A dictionary with categories, technologies and market shares data. + :param technology_group: A string representing the technology group. + :param lower_year: An integer representing the lower year. + :param upper_year: An integer representing the upper year. + :param target_year: An integer representing the target year. + :return: None + """ + for technology in shares[technology_group][lower_year]: + + shares_lower = shares[technology_group][lower_year][technology] + shares_upper = shares[technology_group][upper_year][technology] + + if shares_lower.ndim == 1: + shares_lower = shares_lower.reshape(1, -1) + if shares_upper.ndim == 1: + shares_upper = shares_upper.reshape(1, -1) + + # Stack arrays vertically and ensure it is 2xN (2 rows, N columns) + s = np.vstack((shares_lower, shares_upper)).T + + f = interp1d([lower_year, upper_year], s, kind='linear') + shares[technology_group][target_year][technology] = f(target_year) + + +def generate_samples(years: list, iterations: int = 10) -> dict: + """ + Generates and adjusts randomly selected shares for parameters to sum to 1 + while respecting their specified ranges, and interpolates missing years. + + :param years: List of years for which to generate/interpolate shares. + :param iterations: Number of iterations for random generation. + :return: A dict with adjusted and interpolated shares for each technology and year. + """ + ranges = load_subshares() + shares = load_and_normalize_shares(ranges, iterations) + interpolate_shares(shares, years) + return shares