Skip to content

Commit

Permalink
EODC
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Oct 4, 2023
1 parent 28894a8 commit 261bfe6
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 17 deletions.
2 changes: 1 addition & 1 deletion conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ requirements:
- pycountry
- cryptography
- pyYaml
- sparse
- sparse>=0.14.0
- schema
- datapackage
- requests
Expand Down
75 changes: 65 additions & 10 deletions dev/Untitled1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"source": [
"from premise import *\n",
"from datapackage import Package\n",
"import brightway2 as bw"
"import bw2io as bw"
]
},
{
Expand Down Expand Up @@ -41,8 +41,8 @@
"metadata": {},
"outputs": [],
"source": [
"import brightway2 as bw\n",
"bw.projects.set_current(\"new4\")"
"import bw2data\n",
"bw2data.projects.set_current(\"ei39\")"
]
},
{
Expand All @@ -55,7 +55,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"premise v.(1, 5, 0, 'beta', 3)\n",
"premise v.(1, 7, 1)\n",
"+------------------------------------------------------------------+\n",
"| Warning |\n",
"+------------------------------------------------------------------+\n",
Expand Down Expand Up @@ -87,6 +87,9 @@
"Keep uncertainty data?\n",
"NewDatabase(..., keep_uncertainty_data=True)\n",
"\n",
"Disable multiprocessing?\n",
"NewDatabase(..., use_multiprocessing=False)\n",
"\n",
"Hide these messages?\n",
"NewDatabase(..., quiet=True)\n",
"\n",
Expand All @@ -104,16 +107,68 @@
"source": [
"ndb = NewDatabase(\n",
" scenarios=[\n",
" {\"model\":\"image\", \"pathway\":\"SSP1-Base\", \"year\":2050},\n",
" {\"model\":\"image\", \"pathway\":\"SSP2-RCP19\", \"year\":2050},\n",
" {\"model\":\"remind\", \"pathway\":\"SSP2-PkBudg500\", \"year\":2050},\n",
" {\"model\":\"image\", \"pathway\":\"SSP2-RCP26\", \"year\":2050},\n",
" {\"model\":\"image\", \"pathway\":\"SSP2-Base\", \"year\":2050},\n",
" ],\n",
" source_db=\"ecoinvent 3.8 cutoff\", # <-- name of the database in the BW2 project. Must be a string.\n",
" source_version=\"3.8\", # <-- version of ecoinvent. Can be \"3.5\", \"3.6\", \"3.7\" or \"3.8\". Must be a string.\n",
" key=\"tUePmX_S5B8ieZkkM7WUU2CnO8SmShwmAeWK9x2rTFo=\"\n",
" # to be requested from the library maintainers if you want ot use default scenarios included in `premise`\n",
" source_db=\"ecoinvent 3.9.1 cutoff\", # <-- name of the database in the BW2 project. Must be a string.\n",
" source_version=\"3.9\", # <-- version of ecoinvent. Can be \"3.5\", \"3.6\", \"3.7\" or \"3.8\". Must be a string.\n",
" key=\"tUePmX_S5B8ieZkkM7WUU2CnO8SmShwmAeWK9x2rTFo=\",\n",
" use_multiprocessing=False\n",
" # to be requested from the library maintainers if you want to use default scenarios included in `premise`\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "13c42083-25c6-4203-8bd9-733ef6f70344",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"/////////////////////////// ELECTRICITY ////////////////////////////\n",
"Warning: No activities found for Biomass CHP CCS -- revise mapping.\n",
"Warning: No activities found for Coal CHP CCS -- revise mapping.\n",
"Warning: No activities found for Gas CHP CCS -- revise mapping.\n",
"Warning: No activities found for Gas ST -- revise mapping.\n",
"Warning: No activities found for Oil CC CCS -- revise mapping.\n",
"Warning: No activities found for Oil CHP CCS -- revise mapping.\n",
"Warning: No activities found for Biomass CHP CCS -- revise mapping.\n",
"Warning: No activities found for Coal CHP CCS -- revise mapping.\n",
"Warning: No activities found for Gas CHP CCS -- revise mapping.\n",
"Warning: No activities found for Oil CC CCS -- revise mapping.\n",
"Warning: No activities found for Oil CHP CCS -- revise mapping.\n"
]
},
{
"ename": "IndexError",
"evalue": "Couldn't find suppliers for Oil CHP CCS when looking for set().",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)",
"File \u001b[0;32m~/GitHub/premise/premise/electricity.py:931\u001b[0m, in \u001b[0;36mElectricity.create_new_markets_high_voltage\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 927\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(suppliers) \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m0\u001b[39m:\n\u001b[1;32m 928\u001b[0m suppliers \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlist\u001b[39m(\n\u001b[1;32m 929\u001b[0m get_suppliers_of_a_region(\n\u001b[1;32m 930\u001b[0m database\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdatabase,\n\u001b[0;32m--> 931\u001b[0m locations\u001b[38;5;241m=\u001b[39m\u001b[43mpossible_locations\u001b[49m\u001b[43m[\u001b[49m\u001b[43mcounter\u001b[49m\u001b[43m]\u001b[49m,\n\u001b[1;32m 932\u001b[0m names\u001b[38;5;241m=\u001b[39mecoinvent_technologies[technology],\n\u001b[1;32m 933\u001b[0m reference_prod\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124melectricity\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 934\u001b[0m unit\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mkilowatt hour\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 935\u001b[0m )\n\u001b[1;32m 936\u001b[0m )\n\u001b[1;32m 937\u001b[0m counter \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1\u001b[39m\n",
"\u001b[0;31mIndexError\u001b[0m: list index out of range",
"\nDuring handling of the above exception, another exception occurred:\n",
"\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[5], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mndb\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mupdate_electricity\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m~/GitHub/premise/premise/ecoinvent_modification.py:859\u001b[0m, in \u001b[0;36mNewDatabase.update_electricity\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 857\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 858\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m scenario \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mscenarios:\n\u001b[0;32m--> 859\u001b[0m scenario, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmodified_datasets, _ \u001b[38;5;241m=\u001b[39m \u001b[43m_update_electricity\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 860\u001b[0m \u001b[43m \u001b[49m\u001b[43mscenario\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mscenario\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 861\u001b[0m \u001b[43m \u001b[49m\u001b[43mversion\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mversion\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 862\u001b[0m \u001b[43m \u001b[49m\u001b[43msystem_model\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msystem_model\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 863\u001b[0m \u001b[43m \u001b[49m\u001b[43mmodified_datasets\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmodified_datasets\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 864\u001b[0m \u001b[43m \u001b[49m\u001b[43muse_absolute_efficiency\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43muse_absolute_efficiency\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 865\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 867\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mDone!\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n",
"File \u001b[0;32m~/GitHub/premise/premise/electricity.py:202\u001b[0m, in \u001b[0;36m_update_electricity\u001b[0;34m(scenario, version, system_model, modified_datasets, use_absolute_efficiency, cache)\u001b[0m\n\u001b[1;32m 199\u001b[0m electricity\u001b[38;5;241m.\u001b[39mcreate_region_specific_power_plants()\n\u001b[1;32m 201\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m scenario[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124miam data\u001b[39m\u001b[38;5;124m\"\u001b[39m]\u001b[38;5;241m.\u001b[39melectricity_markets \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\u001b[0;32m--> 202\u001b[0m \u001b[43melectricity\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mupdate_electricity_markets\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 203\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 204\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mNo electricity markets found in IAM data. Skipping.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
"File \u001b[0;32m~/GitHub/premise/premise/electricity.py:2138\u001b[0m, in \u001b[0;36mElectricity.update_electricity_markets\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 2120\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39madd_new_entry_to_cache(\n\u001b[1;32m 2121\u001b[0m location\u001b[38;5;241m=\u001b[39mdataset[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mlocation\u001b[39m\u001b[38;5;124m\"\u001b[39m],\n\u001b[1;32m 2122\u001b[0m exchange\u001b[38;5;241m=\u001b[39mdataset,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 2133\u001b[0m ],\n\u001b[1;32m 2134\u001b[0m )\n\u001b[1;32m 2136\u001b[0m \u001b[38;5;66;03m# We then need to create high voltage IAM electricity markets\u001b[39;00m\n\u001b[1;32m 2137\u001b[0m \u001b[38;5;66;03m# print(\"Create high voltage markets.\")\u001b[39;00m\n\u001b[0;32m-> 2138\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcreate_new_markets_high_voltage\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 2139\u001b[0m \u001b[38;5;66;03m# print(\"Create medium voltage markets.\")\u001b[39;00m\n\u001b[1;32m 2140\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcreate_new_markets_medium_voltage()\n",
"File \u001b[0;32m~/GitHub/premise/premise/electricity.py:964\u001b[0m, in \u001b[0;36mElectricity.create_new_markets_high_voltage\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 962\u001b[0m \u001b[38;5;28;01mcontinue\u001b[39;00m\n\u001b[1;32m 963\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 964\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mIndexError\u001b[39;00m(\n\u001b[1;32m 965\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCouldn\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mt find suppliers for \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mtechnology\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m when looking for \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mecoinvent_technologies[technology]\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 966\u001b[0m )\n\u001b[1;32m 968\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msystem_model \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mconsequential\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[1;32m 969\u001b[0m periods \u001b[38;5;241m=\u001b[39m [\n\u001b[1;32m 970\u001b[0m \u001b[38;5;241m0\u001b[39m,\n\u001b[1;32m 971\u001b[0m ]\n",
"\u001b[0;31mIndexError\u001b[0m: Couldn't find suppliers for Oil CHP CCS when looking for set()."
]
}
],
"source": [
"ndb.update_electricity()"
]
},
{
"cell_type": "code",
"execution_count": 4,
Expand Down Expand Up @@ -2023,7 +2078,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion premise/data/iam_output_files/image_SSP1-Base.csv

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions premise/data/iam_output_files/image_SSP1-Base_old.csv

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion premise/data/iam_output_files/image_SSP2-Base.csv

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions premise/data/iam_output_files/image_SSP2-Base_old.csv

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion premise/data/iam_output_files/image_SSP2-RCP19.csv

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions premise/data/iam_output_files/image_SSP2-RCP19_old.csv

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion premise/data/iam_output_files/image_SSP2-RCP26.csv

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions premise/data/iam_output_files/image_SSP2-RCP26_old.csv

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pycountry
cryptography
premise_gwp
pyYaml
sparse
sparse>=0.14.0
schema
datapackage
requests
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def package_files(directory):
"cryptography",
"premise_gwp",
"pyYaml",
"sparse",
"sparse>=0.14.0",
"schema",
"datapackage",
"requests",
Expand Down

0 comments on commit 261bfe6

Please sign in to comment.