def _create_flow(self, exch): """ An ecospold01 exchange is really just a long attribute list, plus an inputGroup or outputGroup (ignored here) :param exch: :return: """ number = int(exch.get('number')) uid = self._key_to_nsuuid(number) try_f = self[uid] if try_f is not None: f = try_f assert f.entity_type == 'flow', "Expected flow, found %s" % f.entity_type else: # generate flow n = exch.get("name") q = self._create_quantity(exch.get("unit")) c = not_none(exch.get("generalComment")) cas = not_none(exch.get("CASNumber")) cat = [exch.get('category'), exch.get('subCategory')] f = LcFlow(uid, Name=n, CasNumber=cas, Comment=c, Compartment=cat) f.add_characterization(q, reference=True) f.set_external_ref(number) self.add(f) if exch.get("unit") != f.unit(): local_q = self._create_quantity(exch.get("unit")) if not f.has_characterization(local_q): if (f.unit(), local_q.unit()) in conversion_dict: val = conversion_dict[(f.unit(), local_q.unit())] elif (local_q.unit(), f.unit()) in conversion_dict: val = 1.0 / conversion_dict[(local_q.unit(), f.unit())] else: print('Flow %s needs characterization for unit %s' % (f, local_q)) val = parse_math(input('Enter conversion factor 1 %s = x %s' % (f.unit(), local_q))) f.add_characterization(local_q, value=val) return f
def _create_flow(self, exch): """ An ecospold01 exchange is really just a long attribute list, plus an inputGroup or outputGroup (ignored here) :param exch: :return: """ number = int(exch.get('number')) uid = self._key_to_id(number) try_f = self[uid] if try_f is not None: f = try_f assert f.entity_type == 'flow', "Expected flow, found %s" % f.entity_type else: # generate flow n = exch.get("name") q = self._create_quantity(exch.get("unit")) c = not_none(exch.get("generalComment")) cas = not_none(exch.get("CASNumber")) cat = [exch.get('category'), exch.get('subCategory')] f = LcFlow(uid, Name=n, CasNumber=cas, Comment=c, Compartment=cat) f.add_characterization(q, reference=True) f.set_external_ref(number) self.add(f) if exch.get("unit") != f.unit(): local_q = self._create_quantity(exch.get("unit")) if not f.has_characterization(local_q): if (f.unit(), local_q.unit()) not in conversion_dict: print('Flow %s needs characterization for unit %s' % (f, local_q)) val = parse_math(input('Enter conversion factor 1 %s = x %s' % (f.unit(), local_q))) else: val = conversion_dict[(f.unit(), local_q.unit())] f.add_characterization(local_q, value=val) return f