def find_characterization(self, row): # Doesn't work for regionalized LCIA methods flow = self.rb[row] flow_data = Database(flow[0]).load()[flow] method = Method(self.lca.method) try: cf = [x for x in method.load() if x[0] == flow][0][1] except: raise ValueError("Can't find this CF") return {"flow": {"key": flow, "data": flow_data}, "cf": cf}
def test_combine_methods(self): d = Database("biosphere") d.register(depends=[]) d.write(biosphere) m1 = Method(("test method 1",)) m1.register(unit="p") m1.write([(("biosphere", 1), 1, "GLO"), (("biosphere", 2), 2, "GLO")]) m2 = Method(("test method 2",)) m2.register(unit="p") m2.write([(("biosphere", 2), 10, "GLO")]) combine_methods(("test method 3",), ("test method 1",), ("test method 2",)) cm = Method(("test method 3",)) self.assertEqual( sorted(cm.load()), [(("biosphere", 1), 1, "GLO"), (("biosphere", 2), 12, "GLO")], ) self.assertEqual(methods[["test method 3"]]["unit"], "p")
def patch_lcia_methods(self, new_biosphere): flows = ["PFC (CO2-eq)", "HFC (CO2-eq)"] for flow in flows: assert get_activity((new_biosphere, flow)) new_data = [((new_biosphere, flow), 1) for flow in flows] count = 0 for name, metadata in methods.items(): if metadata.get("unit") == "kg CO2-Eq": count += 1 obj = Method(name) data = obj.load() data.extend(new_data) obj.write(data) print(f"Patched {count} LCIA methods with unit 'kg CO2-Eq'")