Skip to content

Commit 4d6afa7

Browse files
committed
update notebook project setup
1 parent ea96777 commit 4d6afa7

File tree

2 files changed

+63
-72
lines changed

2 files changed

+63
-72
lines changed

notebooks/example_setac.ipynb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@
2424
"source": [
2525
"import bw2data as bd\n",
2626
"\n",
27-
"bd.projects.set_current(\"bw25_premise\")"
27+
"project_name = \"timex_example_electric_vehicle\"\n",
28+
"if project_name in bd.projects:\n",
29+
" bd.projects.delete_project(project_name)\n",
30+
" bd.projects.purge_deleted_directories()\n",
31+
"\n",
32+
"bd.projects.set_current(project_name)"
2833
]
2934
},
3035
{
@@ -33,7 +38,7 @@
3338
"source": [
3439
"## Prospective databases\n",
3540
"\n",
36-
"Created using [Ecoinvent v3.9](https://ecoinvent.org/) and [`premise`](https://github.com/polca/premise), with projections for the future electricity sectors using the SSP2-RCP19 pathway from the IAM IMAGE.\n"
41+
"Using [Ecoinvent v3.9](https://ecoinvent.org/) and [`premise`](https://github.com/polca/premise), we created a set of prospective databases with projections for the future electricity sectors using the SSP2-RCP19 pathway from the IAM IMAGE.\n"
3742
]
3843
},
3944
{
@@ -58,7 +63,7 @@
5863
"cell_type": "markdown",
5964
"metadata": {},
6065
"source": [
61-
"Let's make sure we start from scratch:\n"
66+
"Let's create a new foreground database to store the EV process:\n"
6267
]
6368
},
6469
{
@@ -67,9 +72,8 @@
6772
"metadata": {},
6873
"outputs": [],
6974
"source": [
70-
"del bd.databases[\"foreground\"]\n",
7175
"foreground = bd.Database(\"foreground\")\n",
72-
"foreground.write({})"
76+
"foreground.write({}) # to make sure we start from scratch"
7377
]
7478
},
7579
{

notebooks/example_simple_dynamic_characterization.ipynb

Lines changed: 54 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -17,76 +17,12 @@
1717
"execution_count": 1,
1818
"id": "5d3622ff",
1919
"metadata": {},
20-
"outputs": [],
21-
"source": [
22-
"import bw2data as bd\n",
23-
"import numpy as np\n",
24-
"from bw_temporalis import TemporalDistribution\n",
25-
"\n",
26-
"\n",
27-
"def write_test_database():\n",
28-
"\n",
29-
" project_name = \"__test_database__\"\n",
30-
" if project_name in bd.projects:\n",
31-
" bd.projects.delete_project(project_name)\n",
32-
" bd.projects.purge_deleted_directories()\n",
33-
"\n",
34-
" bd.projects.set_current(project_name)\n",
35-
"\n",
36-
" bd.Database(\"temporalis-bio\").write(\n",
37-
" {\n",
38-
" (\"temporalis-bio\", \"CH4\"): { # only biosphere flow is CH4\n",
39-
" \"type\": \"emission\",\n",
40-
" \"name\": \"methane\",\n",
41-
" \"temporalis code\": \"ch4\",\n",
42-
" },\n",
43-
" }\n",
44-
" )\n",
45-
"\n",
46-
" bd.Database(\"test\").write( # dummy system containing 1 activity\n",
47-
" {\n",
48-
" (\"test\", \"A\"): {\n",
49-
" \"name\": \"A\",\n",
50-
" \"location\": \"somewhere\",\n",
51-
" \"reference product\": \"a\",\n",
52-
" \"exchanges\": [\n",
53-
" {\n",
54-
" \"amount\": 1,\n",
55-
" \"type\": \"production\",\n",
56-
" \"input\": (\"test\", \"A\"),\n",
57-
" },\n",
58-
" {\n",
59-
" \"amount\": 1,\n",
60-
" \"type\": \"biosphere\",\n",
61-
" \"input\": (\"temporalis-bio\", \"CH4\"),\n",
62-
" \"temporal_distribution\": TemporalDistribution(\n",
63-
" date=np.array([10], dtype=\"timedelta64[Y]\"),\n",
64-
" amount=np.array([1]),\n",
65-
" ), # emission of CH4 10 years after execution of process A\n",
66-
" },\n",
67-
" ],\n",
68-
" },\n",
69-
" }\n",
70-
" )\n",
71-
"\n",
72-
" bd.Method((\"GWP\", \"example\")).write(\n",
73-
" [\n",
74-
" ((\"temporalis-bio\", \"CH4\"), 29.8), # GWP100 from IPCC AR6\n",
75-
" ]\n",
76-
" )"
77-
]
78-
},
79-
{
80-
"cell_type": "code",
81-
"execution_count": 2,
82-
"id": "e1134948",
83-
"metadata": {},
8420
"outputs": [
8521
{
8622
"name": "stderr",
8723
"output_type": "stream",
8824
"text": [
89-
"100%|██████████| 1/1 [00:00<00:00, 1938.22it/s]\n"
25+
"100%|██████████| 1/1 [00:00<00:00, 12985.46it/s]\n"
9026
]
9127
},
9228
{
@@ -101,7 +37,7 @@
10137
"name": "stderr",
10238
"output_type": "stream",
10339
"text": [
104-
"100%|██████████| 1/1 [00:00<00:00, 12985.46it/s]"
40+
"100%|██████████| 1/1 [00:00<00:00, 18808.54it/s]"
10541
]
10642
},
10743
{
@@ -120,7 +56,58 @@
12056
}
12157
],
12258
"source": [
123-
"write_test_database()"
59+
"import bw2data as bd\n",
60+
"import numpy as np\n",
61+
"from bw_temporalis import TemporalDistribution\n",
62+
"\n",
63+
"project_name = \"timex_example_dynamic_characterization\"\n",
64+
"if project_name in bd.projects:\n",
65+
" bd.projects.delete_project(project_name)\n",
66+
" bd.projects.purge_deleted_directories()\n",
67+
"\n",
68+
"bd.projects.set_current(project_name)\n",
69+
"\n",
70+
"bd.Database(\"temporalis-bio\").write(\n",
71+
" {\n",
72+
" (\"temporalis-bio\", \"CH4\"): { # only biosphere flow is CH4\n",
73+
" \"type\": \"emission\",\n",
74+
" \"name\": \"methane\",\n",
75+
" \"temporalis code\": \"ch4\",\n",
76+
" },\n",
77+
" }\n",
78+
")\n",
79+
"\n",
80+
"bd.Database(\"test\").write( # dummy system containing 1 activity\n",
81+
" {\n",
82+
" (\"test\", \"A\"): {\n",
83+
" \"name\": \"A\",\n",
84+
" \"location\": \"somewhere\",\n",
85+
" \"reference product\": \"a\",\n",
86+
" \"exchanges\": [\n",
87+
" {\n",
88+
" \"amount\": 1,\n",
89+
" \"type\": \"production\",\n",
90+
" \"input\": (\"test\", \"A\"),\n",
91+
" },\n",
92+
" {\n",
93+
" \"amount\": 1,\n",
94+
" \"type\": \"biosphere\",\n",
95+
" \"input\": (\"temporalis-bio\", \"CH4\"),\n",
96+
" \"temporal_distribution\": TemporalDistribution(\n",
97+
" date=np.array([10], dtype=\"timedelta64[Y]\"),\n",
98+
" amount=np.array([1]),\n",
99+
" ), # emission of CH4 10 years after execution of process A\n",
100+
" },\n",
101+
" ],\n",
102+
" },\n",
103+
" }\n",
104+
")\n",
105+
"\n",
106+
"bd.Method((\"GWP\", \"example\")).write(\n",
107+
" [\n",
108+
" ((\"temporalis-bio\", \"CH4\"), 29.8), # GWP100 from IPCC AR6\n",
109+
" ]\n",
110+
")"
124111
]
125112
},
126113
{

0 commit comments

Comments
 (0)