|
17 | 17 | "execution_count": 1,
|
18 | 18 | "id": "5d3622ff",
|
19 | 19 | "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": {}, |
84 | 20 | "outputs": [
|
85 | 21 | {
|
86 | 22 | "name": "stderr",
|
87 | 23 | "output_type": "stream",
|
88 | 24 | "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" |
90 | 26 | ]
|
91 | 27 | },
|
92 | 28 | {
|
|
101 | 37 | "name": "stderr",
|
102 | 38 | "output_type": "stream",
|
103 | 39 | "text": [
|
104 |
| - "100%|██████████| 1/1 [00:00<00:00, 12985.46it/s]" |
| 40 | + "100%|██████████| 1/1 [00:00<00:00, 18808.54it/s]" |
105 | 41 | ]
|
106 | 42 | },
|
107 | 43 | {
|
|
120 | 56 | }
|
121 | 57 | ],
|
122 | 58 | "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 | + ")" |
124 | 111 | ]
|
125 | 112 | },
|
126 | 113 | {
|
|
0 commit comments