Skip to content

Commit

Permalink
Markets creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Jul 15, 2023
1 parent 1fc12a5 commit cd709af
Show file tree
Hide file tree
Showing 7 changed files with 461 additions and 15 deletions.
146 changes: 144 additions & 2 deletions dev/Untitled.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"premise v.(1, 5, 3)\n",
"premise v.(1, 5, 8)\n",
"+------------------------------------------------------------------+\n",
"| Warning |\n",
"+------------------------------------------------------------------+\n",
Expand Down Expand Up @@ -96,6 +96,148 @@
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c7996c75-e3e7-42ba-9ecb-c016b6462109",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"////////////////////////////// METALS ///////////////////////////////\n",
"Creating metal markets\n",
"... for Bauxite.\n",
"... for Beryl.\n",
"... for Cadmium.\n",
"... for Chromium ores and concentrate.\n",
"... for Cobalt, mine.\n",
"... for Cobalt, refined.\n",
"... for Copper, mine.\n",
"... for Copper, smelter.\n",
"... for Copper, refined.\n",
"... for Gallium.\n",
"... for Germanium metal.\n",
"... for Gold, mine.\n",
"Multiple locations found for France (French Guiana). Using first one.\n",
"Multiple locations found for France (French Guiana). Using first one.\n",
"Multiple locations found for France (French Guiana). Using first one.\n",
"Multiple locations found for France (French Guiana). Using first one.\n",
"Multiple locations found for France (French Guiana). Using first one.\n",
"... for graphite, purified.\n",
"... for graphite, spherical.\n",
"... for graphite ore, concentrated.\n",
"... for Graphite, natural.\n",
"... for Indium.\n",
"... for Indium, from zinc.\n",
"... for Iron, ore.\n",
"... for Iron, pig.\n",
"... for Lead, mine.\n",
"... for Lead, refined.\n",
"... for Lithium.\n",
"... for spodumene.\n",
"... for Magnesite.\n",
"... for Magnesium metal.\n",
"... for Manganese, ore.\n",
"... for Molybdenum, mine.\n",
"... for Molybdenum, refining.\n",
"... for Nickel, mine.\n",
"... for Nickel, smelter-refiner.\n",
"... for Phosphate rock.\n",
"New location CX for Christmas Island not found\n",
"... for Palladium .\n",
"... for Platinum .\n",
"... for REE oxides.\n",
"... for Rhenium.\n",
"... for Selenium, refined.\n",
"... for Silver, mine.\n"
]
}
],
"source": [
"#ndb.update_electricity()\n",
"ndb.update_metals()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "a85ca090-8d49-42c2-8b21-ffc69fabc12d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Write new database(s) to Brightway2.\n",
"Prepare database 1.\n",
"- check for duplicates...\n",
"- check for values format...\n",
"- relinking exchanges...\n",
"Done!\n",
"Database metal_test already exists: it will be overwritten.\n",
"Vacuuming database \n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Writing activities to SQLite3 database:\n",
"0% [##############################] 100% | ETA: 00:00:00\n",
"Total time elapsed: 00:00:19\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Title: Writing activities to SQLite3 database:\n",
" Started: 07/15/2023 11:22:08\n",
" Finished: 07/15/2023 11:22:27\n",
" Total time elapsed: 00:00:19\n",
" CPU %: 98.20\n",
" Memory %: 13.00\n",
"Created database: metal_test\n",
"Generate scenario report.\n",
"Report saved under /Users/romain/GitHub/premise/dev/export/scenario_report.\n",
"Generate change report.\n",
"Report saved under /Users/romain/GitHub/premise/dev.\n"
]
}
],
"source": [
"ndb.write_db_to_brightway(\"metal_test\")"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "64ed127c-8fe5-4c6a-853d-b889b91cbc07",
"metadata": {},
"outputs": [],
"source": [
"for ds in ndb.scenarios[0][\"database\"]:\n",
" for e in ds[\"exchanges\"]:\n",
" if e[\"name\"] == \"market group for municipal solid waste\" and e[\"location\"] == \"AL\":\n",
" print(ds[\"name\"], ds[\"location\"])"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "d751e8eb-0534-445c-b034-f3f338d62c36",
"metadata": {},
"outputs": [],
"source": [
"import pprint\n",
"for ds in ndb.scenarios[0][\"database\"]:\n",
" if ds[\"name\"].lower() == \"lithium carbonate, precipitated\":\n",
" print(ds[\"name\"], ds[\"location\"])"
]
},
{
"cell_type": "code",
"execution_count": 4,
Expand Down Expand Up @@ -841,7 +983,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.15"
"version": "3.9.12"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion dev/test_premise.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.15"
"version": "3.9.12"
}
},
"nbformat": 4,
Expand Down
Binary file added premise/data/metals/BGS_mapping.xlsx
Binary file not shown.
22 changes: 11 additions & 11 deletions premise/data/metals/post-allocation correction/corrections.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
location: ZA
unit: kilogram
additional flow:
name: Palladium, in ground
name: Palladium
categories: natural resource::in ground
amount: 0.8848
unit: kilogram
Expand All @@ -12,7 +12,7 @@
location: RU
unit: kilogram
additional flow:
name: Palladium, in ground
name: Palladium
categories: natural resource::in ground
amount: 0.9067
unit: kilogram
Expand All @@ -21,7 +21,7 @@
location: ZA
unit: kilogram
additional flow:
name: Platinum, in ground
name: Platinum
categories: natural resource::in ground
amount: 0.2886
unit: kilogram
Expand All @@ -30,7 +30,7 @@
location: RU
unit: kilogram
additional flow:
name: Platinum, in ground
name: Platinum
categories: natural resource::in ground
amount: 0.8833
unit: kilogram
Expand All @@ -39,7 +39,7 @@
location: ZA
unit: kilogram
additional flow:
name: Rhodium, in ground
name: Rhodium
categories: natural resource::in ground
amount: 0.8907
unit: kilogram
Expand All @@ -48,7 +48,7 @@
location: RU
unit: kilogram
additional flow:
name: Rhodium, in ground
name: Rhodium
categories: natural resource::in ground
amount: 0.9893
unit: kilogram
Expand All @@ -57,7 +57,7 @@
location: RU
unit: kilogram
additional flow:
name: Copper, in ground
name: Copper
categories: natural resource::in ground
amount: 0.7391
unit: kilogram
Expand All @@ -66,7 +66,7 @@
location: RU
unit: kilogram
additional flow:
name: Nickel, in ground
name: Nickel
categories: natural resource::in ground
amount: 0.3663
unit: kilogram
Expand All @@ -75,7 +75,7 @@
location: ZA
unit: kilogram
additional flow:
name: Copper, in ground
name: Copper
categories: natural resource::in ground
amount: 0.9519
unit: kilogram
Expand All @@ -84,7 +84,7 @@
location: ZA
unit: kilogram
additional flow:
name: Nickel, in ground
name: Nickel
categories: natural resource::in ground
amount: 0.9288
unit: kilogram
Expand All @@ -93,7 +93,7 @@
location: ZA
unit: kilogram
additional flow:
name: Gold, in ground
name: Gold
categories: natural resource::in ground
amount: 0.9632
unit: kilogram
2 changes: 1 addition & 1 deletion premise/ecoinvent_modification.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ def update_metals(self) -> None:
modified_datasets=self.modified_datasets,
)

metals.update_metals_use_in_database()
metals.create_metal_markets()
scenario["database"] = metals.database

def update_cars(self) -> None:
Expand Down
Loading

0 comments on commit cd709af

Please sign in to comment.