Chris Mutel committed 990d871

Improve group_by_emissions to consider realms like soil, air, etc.

Comments (0)

Files changed (1)


 def group_by_emissions(method):
-    """Group characterization factors by name and unit.
+    """Group characterization factors by name, realm, and unit.
+    **realm** is the general category, e.g. air, soil, water.
     Does not work on regionalized LCIA methods!
         *method* (tuple or Method): LCIA method
-        Dictionary: {(name, unit)}: [cfs... ]
+        Dictionary: {(name, realm, unit)}: [cfs... ]
     if isinstance(method, Method):
             # Alternative biosphere, e.g. Ecoinvent 3. Add new biosphere DB
         flow = biosphere[key]
-        label = (flow["name"], flow["unit"])
+        label = (flow["name"], flow.get("categories", [""])[0], flow["unit"])
         grouped.setdefault(label, []).append(cf)
     return grouped