bw2io.strategies.generic#
Attributes#
Functions#
|
Add database name to datasets |
|
Goes through the database and assigns activity locations where they are missing. |
Assign only product as reference product. |
|
Convert activity parameters from dictionary to list of dictionaries |
|
Generic number conversion function convert to floats. Return to integers. |
|
Drop fields like '' but keep zero and NaN. |
|
|
This is the nuclear option - use at your own risk! |
|
|
|
Link technosphere exchanges using |
|
Normalize units in datasets and their exchanges |
|
Use |
|
Split unlinked exchanges in |
Module Contents#
- bw2io.strategies.generic.assign_default_location(activities, default_loc='GLO', overwrite=False)[source]#
Goes through the database and assigns activity locations where they are missing. :param activities: iterable of dicts describing activities :param default_loc: the default location to assign :param overwrite: whether or not to overwrite existing location values :return: modified iterable of activities
- bw2io.strategies.generic.assign_only_product_as_production(db)[source]#
Assign only product as reference product.
Skips datasets that already have a reference product or no production exchanges. Production exchanges must have a
nameand an amount.Will replace the following activity fields, if not already specified:
‘name’ - name of reference product
‘unit’ - unit of reference product
‘production amount’ - amount of reference product
- bw2io.strategies.generic.convert_activity_parameters_to_list(data)[source]#
Convert activity parameters from dictionary to list of dictionaries
- bw2io.strategies.generic.convert_uncertainty_types_to_integers(db)[source]#
Generic number conversion function convert to floats. Return to integers.
- bw2io.strategies.generic.drop_falsey_uncertainty_fields_but_keep_zeros(db)[source]#
Drop fields like ‘’ but keep zero and NaN.
Note that this doesn’t strip False, which behaves exactly like 0.
- bw2io.strategies.generic.drop_unlinked(db)[source]#
This is the nuclear option - use at your own risk!
- bw2io.strategies.generic.link_technosphere_by_activity_hash(db, external_db_name=None, fields=None)[source]#
Link technosphere exchanges using
activity_hashfunction.If
external_db_name, link against a different database; otherwise link internally.If
fields, link using only certain fields.
- bw2io.strategies.generic.normalize_units(db)[source]#
Normalize units in datasets and their exchanges
- bw2io.strategies.generic.set_code_by_activity_hash(db, overwrite=False)[source]#
Use
activity_hashto set dataset code.By default, won’t overwrite existing codes, but will if
overwriteisTrue.
- bw2io.strategies.generic.split_exchanges(data, filter_params, changed_attributes, allocation_factors=None)[source]#
Split unlinked exchanges in
datawhich satisfyfilter_paramsinto new exchanges with changed attributes.changed_attributesis a list of dictionaries with the attributes that should be changed.allocation_factorsis an optional list of floats to allocate the original exchange amount to the respective copies defined inchanged_attributes. They don’t have to sum to one. Ifallocation_factorsare not defined, then exchanges are split equally.Resets uncertainty to
UndefinedUncertainty(0).To use this function as a strategy, you will need to curry it first using
functools.partial.Example usage:
split_exchanges( [ {'exchanges': [{ 'name': 'foo', 'location': 'bar', 'amount': 20 }, { 'name': 'food', 'location': 'bar', 'amount': 12 }]} ], {'name': 'foo'}, [{'location': 'A'}, {'location': 'B', 'cat': 'dog'} ] >>> [ {'exchanges': [{ 'name': 'food', 'location': 'bar', 'amount': 12 }, { 'name': 'foo', 'location': 'A', 'amount': 12., 'uncertainty_type': 0 }, { 'name': 'foo', 'location': 'B', 'amount': 8., 'uncertainty_type': 0, 'cat': 'dog', }]} ]