new_cats={}
new_cat_refs=[]
for franken_cat in franken_categories.keys():
impact_factor_list = []
if new_cats.get(franken_cat) is None:
print(f"Creating ImpactCategory for {franken_cat}")
new_cats[franken_cat]=olca.ImpactCategory()
new_cats[franken_cat].olca_type=olca.schema.ImpactCategory.__name__
new_cats[franken_cat].id=str(uuid4())
new_cats[franken_cat].reference_unit_name=None
new_cats[franken_cat].name=franken_cat
for orig_cat in impact_cats_list:
if orig_cat.name in franken_categories[franken_cat]:
print(f"{orig_cat.name} is in {franken_cat}")
if new_cats[franken_cat].reference_unit_name is None:
print(f"Copying reference info from {orig_cat.name}")
new_cats[franken_cat].reference_unit_name=orig_cat.reference_unit_name
new_ref=olca.ImpactCategoryRef()
new_ref.ref_unit=orig_cat.reference_unit_name
new_ref.name=franken_cat
new_ref.id=new_cats[franken_cat].id
#print(f"{franken_categories[franken_cat]} - {orig_cat.name}")
for impact_factor in orig_cat.impact_factors:
#print(f"{impact_factor.flow.name}")
impact_factor.olca_type=olca.schema.ImpactFactor.__name__
impact_factor_list.append(impact_factor)
new_cats[franken_cat].impact_factors=impact_factor_list
#client.insert(new_cats[franken_cat])
new_cat_refs.append(new_ref)
#creating a new impact method in openLCA.
impact_method=olca.ImpactMethod()
#change the name of your method to whatever you want
impact_method.name="Combined impacts"
impact_method.id=str(uuid4())
impact_method.impact_categories=new_cat_refs
impact_method.olca_type=olca.schema.ImpactMethod.__name__
client.insert(impact_method)