bw2io.modified_database
#
Module Contents#
Classes#
Find relationships between foreground data |
- class bw2io.modified_database.ModifiedDatabase(data, ref_database_name, from_simapro=False)[source]#
Bases:
object
Find relationships between foreground data
data
and background database namedref_database_name
.Each activity and exchange is summarized in a hash, a small set of letters that summarizes all relevant attributes.
Attributes#
- foreground_activities_mappingdict
hash: dataset
- foreground_exchanges_mappingdict
hash: exchange
- foreground_activitiesdict
activity hash: set of (exchange hash, amount) exchange tuples.
- background_activities_mappingdict
hash: Activity
- background_exchanges_mappingdict
hash: Exchange
- background_activitiesdict
activity hash: set of (Exchange hash, amount) exchange tuples
Methods#
- assert_data_fully_linked()
Assert that all exchanges in
data
have aninput
key.- iterate_unmatched()
Return data on activities in
data
which can’t be found inref_database_name
.- get_reason(exc_tuple, data)
Get reason why exc_tuple not in data. Reasons are: 1) Changed amount 2) Missing
- iterate_modified()
Return data on modified activities
- load_datasets()
Determine which datasets are modified by comparing the exchanges values.
- add_to_background_exchanges_mapping(exc)
Add exchange to
background_exchanges_mapping
.- hash_background_exchanges(activity)
Hash exchanges in
activity
and add tobackground_exchanges_mapping
.- hash_foreground_exchanges(activity)
Hash exchanges in
activity
and add toforeground_exchanges_mapping
.- prune()
Remove activities from
data
that are not inref_database_name
.
- get_reason(exc_tuple, data)[source]#
Get reason why exc_tuple not in data. Reasons are: 1) Changed amount 2) Missing
Parameters#
- exc_tupletuple
(exchange hash, amount)
- dataset
set of (exchange hash, amount) exchange tuples
Returns#
- str
Reason why exc_tuple not in data
- iterate_unmatched()[source]#
Return data on activities in
data
which can’t be found inref_database_name
.Returns#
- tuple
(key, value)
- 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.