From 24be75397446fb2b07075f1e512a8b0adb197053 Mon Sep 17 00:00:00 2001 From: romainsacchi Date: Tue, 14 May 2024 10:58:49 +0200 Subject: [PATCH] timing.py --- dev/timing.py | 13 ++++++++++++ dev/unfold_test.ipynb | 49 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 dev/timing.py diff --git a/dev/timing.py b/dev/timing.py new file mode 100644 index 0000000..dc5c855 --- /dev/null +++ b/dev/timing.py @@ -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", + } +) \ No newline at end of file diff --git a/dev/unfold_test.ipynb b/dev/unfold_test.ipynb index a4bb42f..5622090 100644 --- a/dev/unfold_test.ipynb +++ b/dev/unfold_test.ipynb @@ -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,