bw2io.modified_database#

Classes#

ModifiedDatabase

Find relationships between foreground data data and background database named ref_database_name.

Module Contents#

class bw2io.modified_database.ModifiedDatabase(data, ref_database_name, from_simapro=False)[source]#

Bases: object

Find relationships between foreground data data and background database named ref_database_name.

Each activity and exchange is summarized in a hash, a small set of letters that summarizes all relevant attributes.

foreground_activities_mapping#

hash: dataset

Type:

dict

foreground_exchanges_mapping#

hash: exchange

Type:

dict

foreground_activities#

activity hash: set of (exchange hash, amount) exchange tuples.

Type:

dict

background_activities_mapping#

hash: Activity

Type:

dict

background_exchanges_mapping#

hash: Exchange

Type:

dict

background_activities#

activity hash: set of (Exchange hash, amount) exchange tuples

Type:

dict

assert_data_fully_linked()[source]#

Assert that all exchanges in data have an input key.

iterate_unmatched()[source]#

Return data on activities in data which can’t be found in ref_database_name.

get_reason(exc_tuple, data)[source]#

Get reason why exc_tuple not in data. Reasons are: 1) Changed amount 2) Missing

iterate_modified()[source]#

Return data on modified activities

load_datasets()[source]#

Determine which datasets are modified by comparing the exchanges values.

add_to_background_exchanges_mapping(exc)[source]#

Add exchange to background_exchanges_mapping.

hash_background_exchanges(activity)[source]#

Hash exchanges in activity and add to background_exchanges_mapping.

hash_foreground_exchanges(activity)[source]#

Hash exchanges in activity and add to foreground_exchanges_mapping.

prune()[source]#

Remove activities from data that are not in ref_database_name.

add_to_background_exchanges_mapping(exc)[source]#
assert_data_fully_linked()[source]#
get_reason(exc_tuple, data)[source]#

Get reason why exc_tuple not in data. Reasons are: 1) Changed amount 2) Missing

Parameters:
  • exc_tuple (tuple) – (exchange hash, amount)

  • data (set) – set of (exchange hash, amount) exchange tuples

Returns:

Reason why exc_tuple not in data

Return type:

str

hash_background_exchanges(activity)[source]#
hash_foreground_exchanges(activity)[source]#
iterate_modified()[source]#

Return data on modified activities

Returns:

(key, value)

Return type:

tuple

iterate_unmatched()[source]#

Return data on activities in data which can’t be found in ref_database_name.

Returns:

(key, value)

Return type:

tuple

load_datasets()[source]#

Determine which datasets are modified by comparing the exchanges values.

Specifically, compare the set of (input activity hashes, amount_as_string) values.

If the name or other important attributes changed, then there won’t be a correspondence at all, so the dataset is treated as modified in any case.

prune()[source]#
data[source]#
fields = None[source]#
ref_database[source]#