technologydata 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- technologydata/__init__.py +41 -0
- technologydata/constants/__init__.py +12 -0
- technologydata/constants/energy_density.py +324 -0
- technologydata/datapackage.py +145 -0
- technologydata/package_data/dea_energy_storage/dea_energy_storage.py +691 -0
- technologydata/package_data/dea_energy_storage/sources.json +12 -0
- technologydata/package_data/dea_energy_storage/technologies.json +17508 -0
- technologydata/package_data/raw/Technology_datasheet_for_energy_storage.xlsx +0 -0
- technologydata/parameter.py +662 -0
- technologydata/source.py +430 -0
- technologydata/source_collection.py +243 -0
- technologydata/technologies/__init__.py +5 -0
- technologydata/technologies/growth_models.py +503 -0
- technologydata/technology.py +191 -0
- technologydata/technology_collection.py +466 -0
- technologydata/utils/__init__.py +13 -0
- technologydata/utils/carriers.txt +33 -0
- technologydata/utils/commons.py +310 -0
- technologydata/utils/heating_values.txt +17 -0
- technologydata/utils/units.py +519 -0
- technologydata-0.1.0.dist-info/METADATA +135 -0
- technologydata-0.1.0.dist-info/RECORD +25 -0
- technologydata-0.1.0.dist-info/WHEEL +5 -0
- technologydata-0.1.0.dist-info/licenses/LICENSE +18 -0
- technologydata-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: technologydata contributors
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
5
|
+
"""technologydata: A package for managing and analyzing technology data used for energy system models."""
|
|
6
|
+
|
|
7
|
+
from technologydata.datapackage import DataPackage
|
|
8
|
+
from technologydata.parameter import Parameter
|
|
9
|
+
from technologydata.source import Source
|
|
10
|
+
from technologydata.source_collection import SourceCollection
|
|
11
|
+
from technologydata.technology import Technology
|
|
12
|
+
from technologydata.technology_collection import TechnologyCollection
|
|
13
|
+
from technologydata.utils.commons import Commons, DateFormatEnum, FileExtensionEnum
|
|
14
|
+
from technologydata.utils.units import (
|
|
15
|
+
CURRENCY_UNIT_PATTERN,
|
|
16
|
+
creg,
|
|
17
|
+
extract_currency_units,
|
|
18
|
+
get_conversion_rate,
|
|
19
|
+
get_iso3_from_currency_code,
|
|
20
|
+
hvreg,
|
|
21
|
+
ureg,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"Commons",
|
|
26
|
+
"DateFormatEnum",
|
|
27
|
+
"DataPackage",
|
|
28
|
+
"FileExtensionEnum",
|
|
29
|
+
"Parameter",
|
|
30
|
+
"Source",
|
|
31
|
+
"SourceCollection",
|
|
32
|
+
"Technology",
|
|
33
|
+
"TechnologyCollection",
|
|
34
|
+
"CURRENCY_UNIT_PATTERN",
|
|
35
|
+
"creg",
|
|
36
|
+
"extract_currency_units",
|
|
37
|
+
"get_conversion_rate",
|
|
38
|
+
"get_iso3_from_currency_code",
|
|
39
|
+
"hvreg",
|
|
40
|
+
"ureg",
|
|
41
|
+
]
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: technologydata contributors
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
5
|
+
"""Provide classes and utilities for handling techno-economic data for energy system modeling."""
|
|
6
|
+
|
|
7
|
+
from technologydata.constants.energy_density import EnergyDensityHHV, EnergyDensityLHV
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"EnergyDensityHHV",
|
|
11
|
+
"EnergyDensityLHV",
|
|
12
|
+
]
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: technologydata contributors
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
Energy density parameters for various carriers.
|
|
7
|
+
|
|
8
|
+
This module defines dictionaries containing energy density parameters
|
|
9
|
+
for different fuel carriers, specifically focusing on lower heating value (LHV)
|
|
10
|
+
and higher heating value (HHV). Each entry maps a carrier name to a `Parameter`
|
|
11
|
+
object that includes magnitude, unit, and carrier type.
|
|
12
|
+
|
|
13
|
+
Attributes
|
|
14
|
+
----------
|
|
15
|
+
EnergyDensityLHV : dict[str, Parameter]
|
|
16
|
+
Dictionary mapping carrier names to their lower heating value (LHV)
|
|
17
|
+
parameters.
|
|
18
|
+
- Key: carrier name (e.g., 'hydrogen', 'methane')
|
|
19
|
+
- Value: Parameter object with magnitude, unit, and carrier info.
|
|
20
|
+
|
|
21
|
+
EnergyDensityHHV : dict[str, Parameter]
|
|
22
|
+
Dictionary mapping carrier names to their higher heating value (HHV)
|
|
23
|
+
parameters.
|
|
24
|
+
- Key: carrier name (e.g., 'hydrogen', 'methane')
|
|
25
|
+
- Value: Parameter object with magnitude, unit, and carrier info.
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
from technologydata import Parameter, Source, SourceCollection
|
|
30
|
+
|
|
31
|
+
EnergyDensityLHV: dict[str, Parameter] = dict(
|
|
32
|
+
hydrogen=Parameter(
|
|
33
|
+
magnitude=120,
|
|
34
|
+
units="MJ/kg",
|
|
35
|
+
carrier="hydrogen",
|
|
36
|
+
sources=SourceCollection(
|
|
37
|
+
sources=[
|
|
38
|
+
Source(
|
|
39
|
+
title="Higher Calorific Values of Common Fuels: Reference & Data",
|
|
40
|
+
authors="The Engineering ToolBox (2003)",
|
|
41
|
+
url="https://www.engineeringtoolbox.com/fuels-higher-calorific-values-d_169.html",
|
|
42
|
+
url_date="2025-09-06",
|
|
43
|
+
),
|
|
44
|
+
],
|
|
45
|
+
),
|
|
46
|
+
),
|
|
47
|
+
methane=Parameter(
|
|
48
|
+
magnitude=50.0,
|
|
49
|
+
units="MJ/kg",
|
|
50
|
+
carrier="methane",
|
|
51
|
+
sources=SourceCollection(
|
|
52
|
+
sources=[
|
|
53
|
+
Source(
|
|
54
|
+
title="Higher Calorific Values of Common Fuels: Reference & Data",
|
|
55
|
+
authors="The Engineering ToolBox (2003)",
|
|
56
|
+
url="https://www.engineeringtoolbox.com/fuels-higher-calorific-values-d_169.html",
|
|
57
|
+
url_date="2025-09-06",
|
|
58
|
+
),
|
|
59
|
+
],
|
|
60
|
+
),
|
|
61
|
+
),
|
|
62
|
+
natural_gas=Parameter(
|
|
63
|
+
magnitude=47.1,
|
|
64
|
+
units="MJ/kg",
|
|
65
|
+
carrier="natural_gas",
|
|
66
|
+
note="Value for natural gas in the US market",
|
|
67
|
+
sources=SourceCollection(
|
|
68
|
+
sources=[
|
|
69
|
+
Source(
|
|
70
|
+
title="Higher Calorific Values of Common Fuels: Reference & Data",
|
|
71
|
+
authors="The Engineering ToolBox (2003)",
|
|
72
|
+
url="https://www.engineeringtoolbox.com/fuels-higher-calorific-values-d_169.html",
|
|
73
|
+
url_date="2025-09-06",
|
|
74
|
+
),
|
|
75
|
+
],
|
|
76
|
+
),
|
|
77
|
+
),
|
|
78
|
+
ammonia=Parameter(
|
|
79
|
+
magnitude=18.646,
|
|
80
|
+
units="MJ/kg",
|
|
81
|
+
carrier="ammonia",
|
|
82
|
+
sources=SourceCollection(
|
|
83
|
+
sources=[
|
|
84
|
+
Source(
|
|
85
|
+
title="Heat of combustion",
|
|
86
|
+
authors="Wikipedia contributors",
|
|
87
|
+
url="https://en.wikipedia.org/w/index.php?title=Heat_of_combustion&oldid=1307512525",
|
|
88
|
+
url_date="2025-09-09",
|
|
89
|
+
),
|
|
90
|
+
],
|
|
91
|
+
),
|
|
92
|
+
),
|
|
93
|
+
wood=Parameter(
|
|
94
|
+
magnitude=15.4,
|
|
95
|
+
units="MJ/kg",
|
|
96
|
+
carrier="wood",
|
|
97
|
+
sources=SourceCollection(
|
|
98
|
+
sources=[
|
|
99
|
+
Source(
|
|
100
|
+
title="Higher Calorific Values of Common Fuels: Reference & Data",
|
|
101
|
+
authors="The Engineering ToolBox (2003)",
|
|
102
|
+
url="https://www.engineeringtoolbox.com/fuels-higher-calorific-values-d_169.html",
|
|
103
|
+
url_date="2025-09-06",
|
|
104
|
+
),
|
|
105
|
+
],
|
|
106
|
+
),
|
|
107
|
+
),
|
|
108
|
+
carbon=Parameter(
|
|
109
|
+
magnitude=32.8,
|
|
110
|
+
units="MJ/kg",
|
|
111
|
+
carrier="carbon",
|
|
112
|
+
note="For pure carbon we assume LHV=HHV",
|
|
113
|
+
sources=SourceCollection(
|
|
114
|
+
sources=[
|
|
115
|
+
Source(
|
|
116
|
+
title="Higher Calorific Values of Common Fuels: Reference & Data",
|
|
117
|
+
authors="The Engineering ToolBox (2003)",
|
|
118
|
+
url="https://www.engineeringtoolbox.com/fuels-higher-calorific-values-d_169.html",
|
|
119
|
+
url_date="2025-09-06",
|
|
120
|
+
),
|
|
121
|
+
],
|
|
122
|
+
),
|
|
123
|
+
),
|
|
124
|
+
methanol=Parameter(
|
|
125
|
+
magnitude=19.9,
|
|
126
|
+
units="MJ/kg",
|
|
127
|
+
carrier="methanol",
|
|
128
|
+
sources=SourceCollection(
|
|
129
|
+
sources=[
|
|
130
|
+
Source(
|
|
131
|
+
title="Higher Calorific Values of Common Fuels: Reference & Data",
|
|
132
|
+
authors="The Engineering ToolBox (2003)",
|
|
133
|
+
url="https://www.engineeringtoolbox.com/fuels-higher-calorific-values-d_169.html",
|
|
134
|
+
url_date="2025-09-06",
|
|
135
|
+
),
|
|
136
|
+
],
|
|
137
|
+
),
|
|
138
|
+
),
|
|
139
|
+
gasoline=Parameter(
|
|
140
|
+
magnitude=43.4,
|
|
141
|
+
units="MJ/kg",
|
|
142
|
+
carrier="gasoline",
|
|
143
|
+
sources=SourceCollection(
|
|
144
|
+
sources=[
|
|
145
|
+
Source(
|
|
146
|
+
title="Higher Calorific Values of Common Fuels: Reference & Data",
|
|
147
|
+
authors="The Engineering ToolBox (2003)",
|
|
148
|
+
url="https://www.engineeringtoolbox.com/fuels-higher-calorific-values-d_169.html",
|
|
149
|
+
url_date="2025-09-06",
|
|
150
|
+
),
|
|
151
|
+
],
|
|
152
|
+
),
|
|
153
|
+
),
|
|
154
|
+
# Add more energy densities as needed
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
EnergyDensityHHV: dict[str, Parameter] = dict(
|
|
158
|
+
hydrogen=Parameter(
|
|
159
|
+
magnitude=141.7,
|
|
160
|
+
units="MJ/kg",
|
|
161
|
+
carrier="hydrogen",
|
|
162
|
+
sources=SourceCollection(
|
|
163
|
+
sources=[
|
|
164
|
+
Source(
|
|
165
|
+
title="The Engineering ToolBox",
|
|
166
|
+
authors="The Engineering ToolBox (2003). Higher Calorific Values of Common Fuels: Reference & Data. [online] Available at:https://www.engineeringtoolbox.com/fuels-higher-calorific-values-d_169.html [Accessed 6 September 2025].",
|
|
167
|
+
url="https://www.engineeringtoolbox.com/fuels-higher-calorific-values-d_169.html",
|
|
168
|
+
),
|
|
169
|
+
],
|
|
170
|
+
),
|
|
171
|
+
),
|
|
172
|
+
methane=Parameter(
|
|
173
|
+
magnitude=55.5,
|
|
174
|
+
units="MJ/kg",
|
|
175
|
+
carrier="methane",
|
|
176
|
+
sources=SourceCollection(
|
|
177
|
+
sources=[
|
|
178
|
+
Source(
|
|
179
|
+
title="Higher Calorific Values of Common Fuels: Reference & Data",
|
|
180
|
+
authors="The Engineering ToolBox (2003)",
|
|
181
|
+
url="https://www.engineeringtoolbox.com/fuels-higher-calorific-values-d_169.html",
|
|
182
|
+
url_date="2025-09-06",
|
|
183
|
+
),
|
|
184
|
+
],
|
|
185
|
+
),
|
|
186
|
+
),
|
|
187
|
+
natural_gas=Parameter(
|
|
188
|
+
magnitude=52.2,
|
|
189
|
+
units="MJ/kg",
|
|
190
|
+
carrier="natural_gas",
|
|
191
|
+
note="Value for natural gas in the US market",
|
|
192
|
+
sources=SourceCollection(
|
|
193
|
+
sources=[
|
|
194
|
+
Source(
|
|
195
|
+
title="Higher Calorific Values of Common Fuels: Reference & Data",
|
|
196
|
+
authors="The Engineering ToolBox (2003)",
|
|
197
|
+
url="https://www.engineeringtoolbox.com/fuels-higher-calorific-values-d_169.html",
|
|
198
|
+
url_date="2025-09-06",
|
|
199
|
+
),
|
|
200
|
+
],
|
|
201
|
+
),
|
|
202
|
+
),
|
|
203
|
+
ammonia=Parameter(
|
|
204
|
+
magnitude=22.5,
|
|
205
|
+
units="MJ/kg",
|
|
206
|
+
carrier="ammonia",
|
|
207
|
+
sources=SourceCollection(
|
|
208
|
+
sources=[
|
|
209
|
+
Source(
|
|
210
|
+
title="Higher Calorific Values of Common Fuels: Reference & Data",
|
|
211
|
+
authors="The Engineering ToolBox (2003)",
|
|
212
|
+
url="https://www.engineeringtoolbox.com/fuels-higher-calorific-values-d_169.html",
|
|
213
|
+
url_date="2025-09-06",
|
|
214
|
+
),
|
|
215
|
+
],
|
|
216
|
+
),
|
|
217
|
+
),
|
|
218
|
+
wood=Parameter(
|
|
219
|
+
magnitude=16.2,
|
|
220
|
+
units="MJ/kg",
|
|
221
|
+
carrier="wood",
|
|
222
|
+
sources=SourceCollection(
|
|
223
|
+
sources=[
|
|
224
|
+
Source(
|
|
225
|
+
title="Higher Calorific Values of Common Fuels: Reference & Data",
|
|
226
|
+
authors="The Engineering ToolBox (2003)",
|
|
227
|
+
url="https://www.engineeringtoolbox.com/fuels-higher-calorific-values-d_169.html",
|
|
228
|
+
url_date="2025-09-06",
|
|
229
|
+
),
|
|
230
|
+
],
|
|
231
|
+
),
|
|
232
|
+
),
|
|
233
|
+
carbon=Parameter(
|
|
234
|
+
magnitude=32.8,
|
|
235
|
+
units="MJ/kg",
|
|
236
|
+
carrier="carbon",
|
|
237
|
+
sources=SourceCollection(
|
|
238
|
+
sources=[
|
|
239
|
+
Source(
|
|
240
|
+
title="Higher Calorific Values of Common Fuels: Reference & Data",
|
|
241
|
+
authors="The Engineering ToolBox (2003)",
|
|
242
|
+
url="https://www.engineeringtoolbox.com/fuels-higher-calorific-values-d_169.html",
|
|
243
|
+
url_date="2025-09-06",
|
|
244
|
+
),
|
|
245
|
+
],
|
|
246
|
+
),
|
|
247
|
+
),
|
|
248
|
+
lignite=Parameter(
|
|
249
|
+
magnitude=14.0,
|
|
250
|
+
units="MJ/kg",
|
|
251
|
+
carrier="lignite",
|
|
252
|
+
sources=SourceCollection(
|
|
253
|
+
sources=[
|
|
254
|
+
Source(
|
|
255
|
+
title="Higher Calorific Values of Common Fuels: Reference & Data",
|
|
256
|
+
authors="The Engineering ToolBox (2003)",
|
|
257
|
+
url="https://www.engineeringtoolbox.com/fuels-higher-calorific-values-d_169.html",
|
|
258
|
+
url_date="2025-09-06",
|
|
259
|
+
),
|
|
260
|
+
],
|
|
261
|
+
),
|
|
262
|
+
),
|
|
263
|
+
coal=Parameter(
|
|
264
|
+
magnitude=32.6,
|
|
265
|
+
units="MJ/kg",
|
|
266
|
+
carrier="coal",
|
|
267
|
+
sources=SourceCollection(
|
|
268
|
+
sources=[
|
|
269
|
+
Source(
|
|
270
|
+
title="Higher Calorific Values of Common Fuels: Reference & Data",
|
|
271
|
+
authors="The Engineering ToolBox (2003)",
|
|
272
|
+
url="https://www.engineeringtoolbox.com/fuels-higher-calorific-values-d_169.html",
|
|
273
|
+
url_date="2025-09-06",
|
|
274
|
+
),
|
|
275
|
+
],
|
|
276
|
+
),
|
|
277
|
+
),
|
|
278
|
+
methanol=Parameter(
|
|
279
|
+
magnitude=23.0,
|
|
280
|
+
units="MJ/kg",
|
|
281
|
+
carrier="methanol",
|
|
282
|
+
sources=SourceCollection(
|
|
283
|
+
sources=[
|
|
284
|
+
Source(
|
|
285
|
+
title="Higher Calorific Values of Common Fuels: Reference & Data",
|
|
286
|
+
authors="The Engineering ToolBox (2003)",
|
|
287
|
+
url="https://www.engineeringtoolbox.com/fuels-higher-calorific-values-d_169.html",
|
|
288
|
+
url_date="2025-09-06",
|
|
289
|
+
),
|
|
290
|
+
],
|
|
291
|
+
),
|
|
292
|
+
),
|
|
293
|
+
jet_fuel_a1=Parameter(
|
|
294
|
+
magnitude=46.2,
|
|
295
|
+
units="MJ/kg",
|
|
296
|
+
carrier="jet_fuel_a1",
|
|
297
|
+
sources=SourceCollection(
|
|
298
|
+
sources=[
|
|
299
|
+
Source(
|
|
300
|
+
title="Jet fuel",
|
|
301
|
+
authors="Wikipedia contributors",
|
|
302
|
+
url="https://en.wikipedia.org/w/index.php?title=Jet_fuel&oldid=1310114781",
|
|
303
|
+
url_date="2025-09-07",
|
|
304
|
+
),
|
|
305
|
+
],
|
|
306
|
+
),
|
|
307
|
+
),
|
|
308
|
+
gasoline=Parameter(
|
|
309
|
+
magnitude=46.4,
|
|
310
|
+
units="MJ/kg",
|
|
311
|
+
carrier="gasoline",
|
|
312
|
+
sources=SourceCollection(
|
|
313
|
+
sources=[
|
|
314
|
+
Source(
|
|
315
|
+
title="Higher Calorific Values of Common Fuels: Reference & Data",
|
|
316
|
+
authors="The Engineering ToolBox (2003)",
|
|
317
|
+
url="https://www.engineeringtoolbox.com/fuels-higher-calorific-values-d_169.html",
|
|
318
|
+
url_date="2025-09-06",
|
|
319
|
+
),
|
|
320
|
+
],
|
|
321
|
+
),
|
|
322
|
+
),
|
|
323
|
+
# Add more energy densities as needed
|
|
324
|
+
)
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: technologydata contributors
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
DataPackage class for managing collections of Technology objects and batch operations.
|
|
7
|
+
|
|
8
|
+
Examples
|
|
9
|
+
--------
|
|
10
|
+
>>> dp = DataPackage.from_json("path/to/data_package.json")
|
|
11
|
+
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import logging
|
|
15
|
+
import pathlib
|
|
16
|
+
from typing import Annotated, Self
|
|
17
|
+
|
|
18
|
+
import pydantic
|
|
19
|
+
|
|
20
|
+
from technologydata.source_collection import SourceCollection
|
|
21
|
+
from technologydata.technology_collection import TechnologyCollection
|
|
22
|
+
|
|
23
|
+
logger = logging.getLogger(__name__)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class DataPackage(pydantic.BaseModel):
|
|
27
|
+
"""
|
|
28
|
+
Container for a collection of Technology objects and/or Source objects, with batch operations and loading utilities.
|
|
29
|
+
|
|
30
|
+
Attributes
|
|
31
|
+
----------
|
|
32
|
+
technologies : Optional[TechnologyCollection]
|
|
33
|
+
List of Technology objects.
|
|
34
|
+
sources : Optional[SourceCollection]
|
|
35
|
+
List of Source objects.
|
|
36
|
+
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
technologies: Annotated[
|
|
40
|
+
TechnologyCollection | None,
|
|
41
|
+
pydantic.Field(description="List of Technology objects."),
|
|
42
|
+
] = None
|
|
43
|
+
sources: Annotated[
|
|
44
|
+
SourceCollection | None, pydantic.Field(description="List of Source objects.")
|
|
45
|
+
] = None
|
|
46
|
+
|
|
47
|
+
def get_source_collection(self) -> None:
|
|
48
|
+
"""
|
|
49
|
+
Get the SourceCollection associated with this DataPackage from the TechnologyCollection.
|
|
50
|
+
|
|
51
|
+
Returns
|
|
52
|
+
-------
|
|
53
|
+
SourceCollection
|
|
54
|
+
The SourceCollection instance.
|
|
55
|
+
|
|
56
|
+
"""
|
|
57
|
+
sources_set = set()
|
|
58
|
+
if self.sources is None:
|
|
59
|
+
if self.technologies is not None:
|
|
60
|
+
for technology in self.technologies:
|
|
61
|
+
for parameter in technology.parameters.values():
|
|
62
|
+
for source in parameter.sources:
|
|
63
|
+
sources_set.add(source)
|
|
64
|
+
else:
|
|
65
|
+
raise ValueError(
|
|
66
|
+
"No technologies available to extract a sources collection from."
|
|
67
|
+
)
|
|
68
|
+
else:
|
|
69
|
+
logger.info("The data package already has a sources collection.")
|
|
70
|
+
self.sources = SourceCollection(sources=list(sources_set))
|
|
71
|
+
|
|
72
|
+
@classmethod
|
|
73
|
+
def from_json(cls, path_to_folder: pathlib.Path | str) -> Self:
|
|
74
|
+
"""
|
|
75
|
+
Load a DataPackage from a JSON file.
|
|
76
|
+
|
|
77
|
+
Parameters
|
|
78
|
+
----------
|
|
79
|
+
path_to_folder : pathlib.Path or str
|
|
80
|
+
Path to the data package folder.
|
|
81
|
+
|
|
82
|
+
Returns
|
|
83
|
+
-------
|
|
84
|
+
DataPackage
|
|
85
|
+
The loaded DataPackage instance.
|
|
86
|
+
|
|
87
|
+
"""
|
|
88
|
+
# Load technologies
|
|
89
|
+
technologies_path = pathlib.Path(path_to_folder, "technologies.json")
|
|
90
|
+
technologies = TechnologyCollection.from_json(technologies_path)
|
|
91
|
+
|
|
92
|
+
# Create DataPackage instance
|
|
93
|
+
data_package = cls(
|
|
94
|
+
path=path_to_folder,
|
|
95
|
+
technologies=technologies,
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
# Generate sources collection from technologies if sources is None
|
|
99
|
+
data_package.get_source_collection()
|
|
100
|
+
|
|
101
|
+
return data_package
|
|
102
|
+
|
|
103
|
+
def to_json(self, folder_path: pathlib.Path) -> None:
|
|
104
|
+
"""
|
|
105
|
+
Export the Datapackage to JSON files.
|
|
106
|
+
|
|
107
|
+
The files are:
|
|
108
|
+
- the 'technologies' attribute is exported to technologies.json, together with the corresponding data schema
|
|
109
|
+
- the 'sources' attribute is exported to sources.json, together with the corresponding data schema
|
|
110
|
+
|
|
111
|
+
Parameters
|
|
112
|
+
----------
|
|
113
|
+
folder_path : pathlib.Path
|
|
114
|
+
The path to the folder where the JSON files are created
|
|
115
|
+
|
|
116
|
+
"""
|
|
117
|
+
if self.technologies is not None:
|
|
118
|
+
technologies_path = pathlib.Path(folder_path, "technologies.json")
|
|
119
|
+
self.technologies.to_json(technologies_path)
|
|
120
|
+
|
|
121
|
+
if self.sources is not None:
|
|
122
|
+
sources_path = pathlib.Path(folder_path, "sources.json")
|
|
123
|
+
self.sources.to_json(sources_path)
|
|
124
|
+
|
|
125
|
+
def to_csv(self, folder_path: pathlib.Path) -> None:
|
|
126
|
+
"""
|
|
127
|
+
Export the Datapackage to CSV files.
|
|
128
|
+
|
|
129
|
+
The files are:
|
|
130
|
+
- the 'technologies' attribute is exported to technologies.csv
|
|
131
|
+
- the 'sources' attribute is exported to sources.csv
|
|
132
|
+
|
|
133
|
+
Parameters
|
|
134
|
+
----------
|
|
135
|
+
folder_path : pathlib.Path
|
|
136
|
+
The path to the folder where the CSV files are created
|
|
137
|
+
|
|
138
|
+
"""
|
|
139
|
+
if self.technologies is not None:
|
|
140
|
+
technologies_path = pathlib.Path(folder_path, "technologies.csv")
|
|
141
|
+
self.technologies.to_csv(path_or_buf=technologies_path)
|
|
142
|
+
|
|
143
|
+
if self.sources is not None:
|
|
144
|
+
sources_path = pathlib.Path(folder_path, "sources.csv")
|
|
145
|
+
self.sources.to_csv(path_or_buf=sources_path)
|