In brightway2 I am trying to understand how to use the IOTableBackend.write method
the source code documentation says that:
products
is a dictionary of product datasets in the normal format.
exchanges
is a list of exchanges with the format(input code, output code, type, value)
I think the second is clear but the first is not. What is a "product dataset" and what is "normal format"? For example, this code returns an error.
import bw2data as bd
products = {('bedb', 'act1'): { 'name':'sadkj', 'unit': 'aaa'},
('bedb', 'act2'): { 'name':'askdj', 'unit': 'bbb'}}
exchanges = [('act1', 'act1', 'production', 1),
('act1', 'act2', 'technosphere', 0.567),
('act2', 'act2', 'production', 1),
('act2', 'act1', 'technosphere', 0.601)]
bedb = bd.backends.iotable.IOTableBackend('bedb')
bedb.write(products, exchanges)
I have also tried using a dictionary that can be normally written as a brightway database without using the backend option, but that did not work either.
Can anybody specify what is the right format for both the "products" and "exchanges" arguments and provide an example?
I found this: https://docs.brightway.dev/en/legacy/_modules/bw2io/importers/exiobase3_hiot.html where the IO table is implemented so we can see how things should look like
products = {
("bedb", "act1"): {
"name": "sadkj",
"unit": "aaa",
"location": "GLO",
"type": "product",
"format": "some_format",
"key": ("bedb", "act1"),
},
("bedb", "act2"): {
"name": "askdj",
"unit": "bbb",
"location": "GLO",
"type": "product",
"format": "some_format",
"key": ("bedb", "act2"),
},
}
exchanges = [
(("bedb", "act1"), ("bedb", "act1"), "production", 1),
(("bedb", "act1"), ("bedb", "act2"), "technosphere", 0.567),
(("bedb", "act2"), ("bedb", "act2"), "production", 1),
(("bedb", "act2"), ("bedb", "act1"), "technosphere", 0.601),
]