Importing a IO table in Brightway2.5 with IOTableBackend.
.write()
works but I can’t figure out .write_exchanges()
. Documentation says: Technosphere and biosphere data has format (row id, col id, value, flip)
.
Example:
data = {
("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"),
},
}
bedb = bd.backends.iotable.IOTableBackend('bedb')
bedb.write(data) # all good
I have then tried various types of technosphere formats like:
technosphere = [
(("bedb", "act1"), ("bedb", "act1"), 1.0, False),
(("bedb", "act1"), ("bedb", "act2"), 0.5, True),
(("bedb", "act2"), ("bedb", "act2"), 1.0, False),
(("bedb", "act2"), ("bedb", "act1"), 0.5, True),
]
technosphere_ = [
(("bedb", 0), ("bedb", 0), 1.0, False),
(("bedb", 1), ("bedb", 0), 0.5, True),
(("bedb", 1), ("bedb", 1), 1.0, False),
(("bedb", 1), ("bedb", 0), 0.5, True),
]
technosphere = [(0, 0, 1.0, False),
(0, 1, 0.5, True),
(1, 1, 1.0, False),
(1, 0, 0.5, True)]
(Same for biosphere, I tried similar formats. For the reproducible example here: biosphere = []
and dependents = []
)
None of them seems to work with bedb.write_exchanges(technosphere, biosphere, dependents)
I always get a TypeError: tuple indices must be integers or slices, not str
What is the right format?