Example #1
0
    def new_flow(self, flow=None, name=None, cas=None, quantity=None, comment=None, compartment=None):
        if flow is None:
            name = name or input('Enter flow name: ')
            cas = cas or ifinput('Enter CAS number (or none): ', '')
            print('Choose reference quantity or none to create new: ')
            if quantity is None:
                q = pick_one(self.flow_properties)
                if q is None:
                    q = self.new_quantity()
                quantity = q
            comment = comment or input('Enter flow comment: ')
            if compartment is None:
                print('Choose compartment:')
                compartment = pick_compartment(self.db.compartments).to_list()
            flow = LcFlow.new(name, quantity, CasNumber=cas, Compartment=compartment, Comment=comment)
            # flow.add_characterization(q, reference=True)
        else:
            quantity = flow.reference_entity

        self._catalog[0].add(flow)
        flow.profile()
        while ifinput('Add characterizations for this flow? y/n', 'n') != 'n':
            ch = cyoa('[n]ew or [e]xisting quantity? ', 'en', 'e')
            if ch == 'n':
                cq = self.new_quantity()
            else:
                cq = pick_one(self[0].quantities())
                if cq is None:
                    cq = self.new_quantity()
            val = parse_math(input('Value (1 %s = x %s): ' % (quantity.unit(), cq.unit())))
            flow.add_characterization(cq, value=val)

        return flow
Example #2
0
    def test_add_intflows(self):
        self.cm.set_local(self._test_file)
        f2 = LcFlow.new("Dummy flow", None, Compartment=['Products'])
        self.assertIsNone(
            self.cm.find_matching(f2['Compartment'], interact=False))

        products = self.cm.add_compartment(f2['Compartment'])
        self.assertIs(self.cm.find_matching(f2['Compartment']), products)
Example #3
0
 def create_flow(self):
     name = input('Enter flow name: ')
     cas = ifinput('Enter CAS number (or none): ', '')
     print('Choose reference quantity: ')
     q = pick_one(self._catalog[0].quantities())
     print('Choose compartment:')
     comment = input('Enter comment: ')
     c = pick_compartment(self._flowdb.compartments)
     flow = LcFlow.new(name, q, CasNumber=cas, Compartment=c.to_list(), Comment=comment)
     # flow.add_characterization(q, reference=True)
     self._catalog[0].add(flow)
     return flow
Example #4
0
 def test_elementary(self):
     self.cm.set_local(self._test_file)
     f1 = LcFlow.new("Dummy flow", None, Compartment=['Emissions to air'])
     f2 = LcFlow.new("Dummy flow", None, Compartment=['Products'])
     self.assertTrue(self.cm.is_elementary(f1))
     self.assertFalse(self.cm.is_elementary(f2))