bw2io.utils
#
Module Contents#
Classes#
Functions#
|
Generate unique ID for ecoinvent3 dataset. |
|
|
|
|
|
Rescale exchanges, including formulas and uncertainty values, by a constant factor. |
|
Standardize an LCIA method name to a length 3 tuple. |
Attributes#
- class bw2io.utils.ExchangeLinker[source]#
-
- classmethod activity_hash(act, fields=DEFAULT_FIELDS, case_insensitive=True, strip=True)[source]#
Hash an activity dataset.
Used to import data formats like ecospold 1 (ecoinvent v1-2) and SimaPro, where no unique attributes for datasets are given. This is clearly an imperfect and brittle solution, but there is no other obvious approach at this time.
The fields used can be optionally specified in
fields
.No fields are required; an empty string is used if a field isn’t present. All fields are cast to lower case.
- By default, uses the following, in order:
name
categories
unit
reference product
location
- Parameters
data (*) – The activity dataset data.
fields (*) – Optional list of fields to hash together. Default is
('name', 'categories', 'unit', 'reference product', 'location')
.case_insensitive (*) – Cast everything to lowercase before computing hash. Default is
True
.
- Returns
A MD5 hash string, hex-encoded.
- classmethod link_activities_to_database(activities, other=None, fields=DEFAULT_FIELDS, relink=False)[source]#
- classmethod link_iterable_by_fields(unlinked, other=None, fields=DEFAULT_FIELDS, kind=None, internal=False, relink=False)[source]#
Generic function to link objects in
unlinked
to objects inother
using fieldsfields
.The database to be linked must have uniqueness for each object for the given
fields
.If
kind
, limit objects inunlinked
of typekind
.If
relink
, link to objects which already have aninput
. Otherwise, skip already linked objects.If
internal
, linkedunlinked
to other objects inunlinked
. Each object must have the attributesdatabase
andcode
.
- bw2io.utils.es2_activity_hash(activity, flow)[source]#
Generate unique ID for ecoinvent3 dataset.
Despite using a million UUIDs, there is actually no unique ID in an ecospold2 dataset. Datasets are uniquely identified by the combination of activity and flow UUIDs.
- bw2io.utils.rescale_exchange(exc, factor)[source]#
Rescale exchanges, including formulas and uncertainty values, by a constant factor.
No generally recommended, but needed for use in unit conversions. Not well tested.
- bw2io.utils.standardize_method_to_len_3(name, padding='--', joiner=',')[source]#
Standardize an LCIA method name to a length 3 tuple.
name
is the current name.padding
is the string to use for missing fields.