Skip to content

Commit

Permalink
Version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed May 16, 2024
1 parent 074592b commit f34d894
Show file tree
Hide file tree
Showing 4 changed files with 195 additions and 13 deletions.
135 changes: 135 additions & 0 deletions dev/Untitled.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,140 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 9,
"id": "9072abc3-ba48-4b33-945e-7696686bb30d",
"metadata": {},
"outputs": [],
"source": [
"import bw2data\n",
"bw2data.projects.set_current(\"ei39\")"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "fbe36131-cd47-4a6a-ba7c-bf85b170740c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Brightway2 projects manager with 3 objects:\n",
"\tdefault\n",
"\tei39\n",
"\tnew4\n",
"Use `projects.report()` to get a report on all projects."
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bw2data.projects"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "2969f3c0-1073-44ef-9beb-5e31989b2c2b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n",
"Vacuuming database \n"
]
}
],
"source": [
"import bw2data\n",
"bw2data.projects.set_current(\"ei39\")\n",
"\n",
"dbs = [\n",
" db for db in bw2data.databases if db not in [\n",
" \"biosphere3\",\n",
" \"ecoinvent 3.9.1 cutoff\"\n",
" ]\n",
"]\n",
"for db in dbs:\n",
" del bw2data.databases[db]"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "c23776c7-6f4b-4d34-bb2a-fa148340c62c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['biosphere3', 'ecoinvent 3.9.1 cutoff']"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list(bw2data.databases)"
]
},
{
"cell_type": "code",
"execution_count": 1,
Expand Down
53 changes: 41 additions & 12 deletions dev/test_premise.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 1,
"id": "df75ca49-bab1-486b-9a5e-4bf7e4259180",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -74,7 +74,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"premise v.(2, 1, 0, 'dev2')\n",
"premise v.(2, 1, 0)\n",
"+------------------------------------------------------------------+\n",
"| Warning |\n",
"+------------------------------------------------------------------+\n",
Expand Down Expand Up @@ -116,7 +116,12 @@
"- Importing additional inventories\n",
"\n",
"//////////////// IMPORTING USER-DEFINED INVENTORIES ////////////////\n",
"Extracted 1 worksheets in 0.81 seconds\n",
"Extracted 1 worksheets in 0.36 seconds\n",
"Migrating to 3.8 first\n",
"Applying strategy: migrate_datasets\n",
"Applying strategy: migrate_exchanges\n",
"Applying strategy: migrate_datasets\n",
"Applying strategy: migrate_exchanges\n",
"Applying strategy: migrate_datasets\n",
"Applying strategy: migrate_exchanges\n",
"The following datasets to import already exist in the source database. They will not be imported\n",
Expand Down Expand Up @@ -246,19 +251,42 @@
"| electricity production, photov | electricity, low voltage | GB | lci-PV.xlsx |\n",
"| electricity production, photov | electricity, low voltage | US | lci-PV.xlsx |\n",
"+--------------------------------+--------------------------------+----------+-------------+\n",
"Migrating to 3.8 first\n",
"Applying strategy: migrate_datasets\n",
"Applying strategy: migrate_exchanges\n",
"Applying strategy: migrate_datasets\n",
"Applying strategy: migrate_exchanges\n",
"Applying strategy: migrate_datasets\n",
"Applying strategy: migrate_exchanges\n",
"- Fetching IAM data\n",
"Done!\n",
"#############################################################################################################\n",
"3.8 brightway superstructure\n"
"3.9.1 brightway matrices\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Updating: fuels: 38%|██████▌ | 5/13 [00:50<01:20, 10.04s/it]"
"Processing scenarios: 100%|█████████████| 2/2 [03:16<00:00, 98.22s/it]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Done!\n",
"\n",
"Write new database(s) to matrix.\n",
"Running all checks...\n",
"Minor anomalies found: check the change report.\n",
"Matrices saved in /Users/romain/GitHub/premise/dev/export/remind/SSP2-Base/2050.\n",
"Running all checks...\n",
"Minor anomalies found: check the change report.\n",
"Matrices saved in /Users/romain/GitHub/premise/dev/export/image/SSP2-RCP19/2048.\n",
"Generate scenario report.\n",
"Report saved under /Users/romain/GitHub/premise/dev/export/scenario_report.\n",
"Generate change report.\n"
]
}
],
Expand All @@ -277,14 +305,14 @@
" #\"3.6\",\n",
" #\"3.7\",\n",
" #\"3.7.1\",\n",
" \"3.8\",\n",
" #\"3.8\",\n",
" #\"3.9\",\n",
" \"3.9.1\"\n",
"\n",
" ]:\n",
" \n",
" if ei not in [\"3.9\", \"3.9.1\"]:\n",
" bw2data.projects.set_current(\"ei38\")\n",
" bw2data.projects.set_current(\"new4\")\n",
" else:\n",
" bw2data.projects.set_current(\"ei39\")\n",
"\n",
Expand All @@ -294,8 +322,8 @@
" ]:\n",
" for export in [\n",
" #\"brightway\",\n",
" \"superstructure\",\n",
" \"simapro\",\n",
" #\"superstructure\",\n",
" #\"simapro\",\n",
" \"matrices\",\n",
" \"datapackage\"\n",
" ]:\n",
Expand All @@ -309,7 +337,6 @@
" key='tUePmX_S5B8ieZkkM7WUU2CnO8SmShwmAeWK9x2rTFo=',\n",
" system_model=model,\n",
" system_args=combinations[0],\n",
" use_multiprocessing=False,\n",
" additional_inventories= [ # <-- this is NEW\n",
" {\"filepath\": \"/Users/romain/GitHub/premise/premise/data/additional_inventories/lci-PV.xlsx\", \"ecoinvent version\": \"3.7\"}, # <-- this is NEW\n",
" ] # <-- this is NEW\n",
Expand Down Expand Up @@ -341,7 +368,9 @@
" else:\n",
" ndb.write_datapackage(name=\"test\")\n",
" u = Unfold(\"export/datapackage/test.zip\")\n",
" u.unfold(dependencies={\"ecoinvent\": f\"ecoinvent {ei} {model}\", \"biosphere3\": \"biosphere3\"}, superstructure=True)"
" u.unfold(dependencies={\"ecoinvent\": f\"ecoinvent {ei} {model}\", \"biosphere3\": \"biosphere3\"}, superstructure=True)\n",
"\n",
" del ndb"
]
},
{
Expand Down Expand Up @@ -401,7 +430,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion premise/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__all__ = ("NewDatabase", "clear_cache", "get_regions_definition")
__version__ = (2, 1, 0, "dev8")
__version__ = (2, 1, 0)


from premise.new_database import NewDatabase
Expand Down
18 changes: 18 additions & 0 deletions premise/new_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,9 @@ def write_superstructure_db_to_brightway(
for scenario in self.scenarios:
del scenario["database"]

if "applied functions" in scenario:
del scenario["applied functions"]

def write_db_to_brightway(self, name: [str, List[str]] = None):
"""
Register the new database into an open brightway project.
Expand Down Expand Up @@ -1023,6 +1026,9 @@ def write_db_to_brightway(self, name: [str, List[str]] = None):
# delete the database from the scenario
del scenario["database"]

if "applied functions" in scenario:
del scenario["applied functions"]

# generate scenario report
self.generate_scenario_report()
# generate change report from logs
Expand Down Expand Up @@ -1083,6 +1089,9 @@ def scenario_name(scenario):
)
Export(scenario, filepath[s], self.version).export_db_to_matrices()

if "applied functions" in scenario:
del scenario["applied functions"]

# generate scenario report
self.generate_scenario_report()
# generate change report from logs
Expand Down Expand Up @@ -1115,6 +1124,9 @@ def write_db_to_simapro(self, filepath: str = None):
Export(scenario, filepath, self.version).export_db_to_simapro()
del scenario["database"]

if "applied functions" in scenario:
del scenario["applied functions"]

# generate scenario report
self.generate_scenario_report()
# generate change report from logs
Expand Down Expand Up @@ -1149,6 +1161,9 @@ def write_db_to_olca(self, filepath: str = None):
)
del scenario["database"]

if "applied functions" in scenario:
del scenario["applied functions"]

# generate scenario report
self.generate_scenario_report()
# generate change report from logs
Expand Down Expand Up @@ -1189,6 +1204,9 @@ def write_datapackage(
for scenario in self.scenarios:
del scenario["database"]

if "applied functions" in scenario:
del scenario["applied functions"]

cached_inventories.extend(extra_inventories)

list_scenarios = ["original"] + list_scenarios
Expand Down

0 comments on commit f34d894

Please sign in to comment.