Skip to content

Commit

Permalink
timing.py
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed May 14, 2024
1 parent b8c3ddd commit 24be753
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
13 changes: 13 additions & 0 deletions dev/timing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from unfold import Unfold
import bw2io, bw2data, bw2calc
bw2data.projects.set_current("ei39")
fp = "/Users/romain/Documents/datapackage_IMAGE_SSP2_Ammonia.zip"
u = Unfold(fp)
u.unfold(
scenarios=[0, 1],
superstructure=True,
dependencies={
"biosphere3": "biosphere3",
"ecoinvent": "ecoinvent 3.9.1 cutoff",
}
)
49 changes: 49 additions & 0 deletions dev/unfold_test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,55 @@
"u = Unfold(fp)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "c4d0b301-1ab9-4dc0-ad7c-38940e5a9969",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\u001b[0;31mSignature:\u001b[0m\n",
"\u001b[0mu\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0munfold\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mscenarios\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mList\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mint\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mdependencies\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mdict\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0msuperstructure\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mbool\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mexport_dir\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mstr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mstr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mDocstring:\u001b[0m\n",
"unfold() is a method of the Unfold class, which extracts specific scenarios from the input LCA database and writes them as new databases.\n",
"\n",
":param scenarios: A list of integers indicating the indices of the scenarios to extract. If None, all scenarios are extracted. Default is None.\n",
":param dependencies: A dictionary containing additional inventory databases that may be needed for extraction. Default is None.\n",
":param superstructure: A boolean indicating whether to generate a scenario difference file and a superstructure database. Default is False.\n",
":param name: A string indicating the name of the superstructure database. Default is None.\n",
":param export_dir: A string indicating the directory to which the scenario difference file should be exported. Default is current working directory.\n",
":return: None\n",
"\n",
"Behavior:\n",
"\n",
"Calls the check_dependencies() method to ensure that all required inventory databases are present.\n",
"Calls the extract_source_database() method to extract the original LCA database.\n",
"Calls the extract_additional_inventories() method to extract any additional inventory databases required.\n",
"Calls the format_dataframe() method to format the scenario data into a Pandas DataFrame.\n",
"Calls the generate_factors() method to generate the factors for the scenarios.\n",
"If superstructure is False, calls the generate_single_databases() method to generate a separate LCA database for each scenario, and stores them in the databases_to_export dictionary.\n",
"If superstructure is True, calls the format_superstructure_dataframe() method to generate a scenario difference file and a superstructure database.\n",
"Calls write() method to write the databases to disk.\n",
"\u001b[0;31mFile:\u001b[0m ~/GitHub/unfold/unfold/unfold.py\n",
"\u001b[0;31mType:\u001b[0m method"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"u.unfold?"
]
},
{
"cell_type": "code",
"execution_count": 5,
Expand Down

0 comments on commit 24be753

Please sign in to comment.