I made several changes to my lci database using the Wurst python package. I then re-wrote my database using write_brightway2_database()
.
Obtaining 16718 datasets, 462812 exchanges and 0 unlinked exchanges.
Then once, I try to calculate LCA score with the modified database, I obtain a technosphere matrix that is not square, with the following dimension: 16718 activities (columns) and 16717 products (rows).
This is how I attempt to calculate an LCA score:
lca = LCA({db.random(): 1}, method=lcia_methods['CC'])
lca.lci()
lca.lcia()
print(lca.score)
The error message that I get:
NonsquareTechnosphere: Technosphere matrix is not square: 16718 activities (columns) and 16717 products (rows). Use LeastSquaresLCA to solve this system, or fix the input data
Then, I tried the following, plus some variations as recommended here :
for a in Database("database"):
assert len(a.production()) == 1
But there is no dataset poping-up.
I also tried before re-writing my database from Wurst in BW2 format to do the following:
producion = {}
for ds in db:
key = ds['code']
producion[key] = []
for exc in ds['exchanges']:
if exc['type'] == 'production':
producion[key].append(exc['name'])
for v in producion.values():
if len(v) != 1:
print(v)
But again, I cannot identify any problematic dataset doing this.
Is there a simple way to identify which activity or which product is leading to a non-square technosphere matrix in order to fix my input data?