PET from US LCI (foreground)

  • Build fragment from US LCI foreground
  • encapsulate in an enclosing fragment
  • terminate IO flows to ecoinvent background (since we don't have matrix inversion yet)

The purpose of this exercise is to develop the model-building software, so everything should be done with interactive scripts.


In [1]:
import re
import os
import sys
import json

sys.path.append('../..')

import lcatools

In [204]:
from lcatools.foreground.fragment_flows import LcFragment
from lcatools.entities import LcFlow, LcQuantity
from lcatools.exchanges import Exchange, comp_dir
from lcatools.catalog import ExchangeRef

In [3]:
F = lcatools.ForegroundManager('pet')


ForegroundArchive archive added in position 0
IlcdLcia archive added in position 1
JSON archive added in position 2
JSON archive added in position 3
JSON archive added in position 4
JSON archive added in position 5
JSON archive added in position 6
JSON archive added in position 7
JSON archive added in position 8
JSON archive added in position 9
JSON archive added in position 10
Setup Catalog and FlowDB... (0.84 s)
Loading JSON data from /data/GitHub/lca-tools-datafiles/catalogs/uslci_ecospold.json.gz:
Found Extension: zip
19 new quantity entities added (19 total)
4176 new flow entities added (4176 total)
701 new process entities added (701 total)
Fragments loaded... (2.55 s)
finished... (2.55 s)

In [4]:
F.show_all()


LCA Catalog with the following archives:
X [ 0] FG     : ForegroundArchive with 167 entities at pet
  [ 1] ELCD   : /data/LCI/ELCD/ELCD3.2.zip
  [ 2] LCIA   : /data/GitHub/lca-tools-datafiles/catalogs/elcd_lcia_all.json.gz
  [ 3] EI-LCIA: /data/GitHub/lca-tools-datafiles/catalogs/ei_lcia.json.gz
  [ 4] EI-U   : /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_undefined_xlsx.json.gz
  [ 5] EI_A   : /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_apos_xlsx.json.gz
  [ 6] EI_Q   : /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_consequential_xlsx.json.gz
  [ 7] EI_C   : /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_cut-off_xlsx.json.gz
X [ 8] USLCI  : EcospoldV1Archive with 4896 entities at /home/b/Dropbox/data/USLCI/USLCI_Processes_ecospold1.zip
  [ 9] GaBi-P : /data/GitHub/lca-tools-datafiles/catalogs/gabi_2016_professional-database-2016.json.gz
  [10] GaBi-X : /data/GitHub/lca-tools-datafiles/catalogs/gabi_2016_all-extensions.json.gz

In [5]:
[str(q) for q in F[0].lcia_methods()]


Out[5]:
['ILCD2011; Eutrophication freshwater; midpoint; P equivalents; ReCiPe [LCIA]',
 'ILCD2011; Eutrophication marine; midpoint; N equivalents; ReCiPe [LCIA]',
 'ILCD2011; Eutrophication terrestrial; midpoint; Accumulated Exceedance; Seppala et al 2006, Posch et al 2008 [LCIA]',
 'ILCD2011; Respiratory inorganics; midpoint; PM2.5eq; Rabl and Spadaro 2004-Greco et al 2007 [LCIA]',
 'ILCD2011; Photochemical ozone formation; midpoint - human health; POCP; Van Zelm et al. (2008) [LCIA]',
 'ILCD2011; Climate change; midpoint; GWP100; IPCC2007 [LCIA]',
 'ILCD2011; Acidification terrestrial and freshwater; midpoint; Accumulated Exceedance; Seppälä et al. 2006, Posch et al. 2008 [LCIA]',
 'ILCD2011; Land use; midpoint; SOM loss; Mila i Canals et al. (2007) [LCIA]']

In [6]:
F.load_lcia_cfs('LCIA')


Loading JSON data from /data/GitHub/lca-tools-datafiles/catalogs/elcd_lcia_all.json.gz:
Found Extension: zip
55 new quantity entities added (55 total)
33902 new flow entities added (33902 total)
0 new process entities added (0 total)
0 unmatched flows found from source LCIA... 


In [7]:
['%s %-70.70s' % (x.get_uuid(), x) for x in F['LCIA'].lcia_methods() if re.search('midpoint', x['Name'])]


Out[7]:
['40054970-5936-477c-9bec-29fa23b1cb77 ILCD2011; Eutrophication terrestrial; midpoint; Accumulated Exceedance',
 '8b723200-3d8f-4eec-9e10-444edb029476 ILCD2011; Ozone depletion; midpoint; ODP; WMO1999 [LCIA]              ',
 '370960f4-0a3a-415d-bf3e-e5ce63160bb9 ILCD2011; Climate change; midpoint; GWP100; IPCC2007 [LCIA]           ',
 '5296e2be-060b-4e50-b033-d45f85f6ac92 ILCD2011; Eutrophication marine; midpoint; N equivalents; ReCiPe [LCIA',
 'a6f4cbc8-5388-44d6-9a67-53d05684f93e ILCD2011; Ionising radiation; midpoint - human health; ionising radiat',
 'f4602cba-f746-4351-b4da-e91181853e33 ILCD2011; Land use; midpoint; SOM loss; Mila i Canals et al. (2007) [L',
 'f6cbd466-253f-4145-a4bb-8dae7d266e89 ILCD2011; Acidification terrestrial and freshwater; midpoint; Accumula',
 'b7d61a6f-cb2f-4a46-b511-39c3e4cc31d3 ILCD2011; Resource depletion- mineral, fossils and renewables; midpoin',
 'b49c662d-4662-4944-a80a-093dd03d3f4f ILCD2011; Ecotoxicity freshwater; midpoint; CTUe; USEtox [LCIA]       ',
 '4120d283-c81a-495e-bb02-9b5a041f3f98 ILCD2011; Ionising radiation; midpoint - ecosystem; CTUe; Garnier-Lapl',
 'bac8c45b-e778-479e-838c-7c2f54b45610 ILCD2011; Cancer human health effects; midpoint; CTUh; USEtox [LCIA]  ',
 '324d2515-5985-4563-87d8-f59053db774d ILCD2011; Non-cancer human health effects; midpoint; CTUh; USEtox [LCI',
 'a4630d5b-df2f-48ae-b3f2-5e5257606d68 ILCD2011; Eutrophication freshwater; midpoint; P equivalents; ReCiPe [',
 'ec7836be-83eb-41da-bcda-1a6a3fe2d149 ILCD2011; Photochemical ozone formation; midpoint - human health; POCP',
 '9e456c6b-2cb3-45cd-91ec-40681ab2b2e9 ILCD2011; Resource depletion - water; midpoint; freshwater scarcity; S',
 '72ce3013-f678-4c6a-935b-f4752ff8901b ILCD2011; Respiratory inorganics; midpoint; PM2.5eq; Rabl and Spadaro ']

In [82]:
ilcd_qs = ('ec7836be-83eb-41da-bcda-1a6a3fe2d149', 'f6cbd466-253f-4145-a4bb-8dae7d266e89', 
           'f4602cba-f746-4351-b4da-e91181853e33', 'a4630d5b-df2f-48ae-b3f2-5e5257606d68',
           '72ce3013-f678-4c6a-935b-f4752ff8901b', '370960f4-0a3a-415d-bf3e-e5ce63160bb9',
           '5296e2be-060b-4e50-b033-d45f85f6ac92', '40054970-5936-477c-9bec-29fa23b1cb77'
          )

In [83]:
for q in ilcd_qs:
    F.add_to_foreground(F['LCIA'][q])


Add to foreground: ILCD2011; Photochemical ozone formation; midpoint - human health; POCP; Van Zelm et al. (2008) [LCIA]
Add to foreground: ILCD2011; Acidification terrestrial and freshwater; midpoint; Accumulated Exceedance; Seppälä et al. 2006, Posch et al. 2008 [LCIA]
Add to foreground: ILCD2011; Land use; midpoint; SOM loss; Mila i Canals et al. (2007) [LCIA]
Add to foreground: ILCD2011; Eutrophication freshwater; midpoint; P equivalents; ReCiPe [LCIA]
Add to foreground: ILCD2011; Respiratory inorganics; midpoint; PM2.5eq; Rabl and Spadaro 2004-Greco et al 2007 [LCIA]
Add to foreground: ILCD2011; Climate change; midpoint; GWP100; IPCC2007 [LCIA]
Add to foreground: ILCD2011; Eutrophication marine; midpoint; N equivalents; ReCiPe [LCIA]
Add to foreground: ILCD2011; Eutrophication terrestrial; midpoint; Accumulated Exceedance; Seppala et al 2006, Posch et al 2008 [LCIA]

In [6]:
F.load_lcia_cfs('EI-LCIA')


Loading JSON data from /data/GitHub/lca-tools-datafiles/catalogs/ei_lcia.json.gz:
**Upstream reference encountered: /data/LCI/Ecoinvent/3.2/undefined

710 new quantity entities added (710 total)
3255 new flow entities added (3255 total)
0 new process entities added (0 total)
92 unmatched flows found from source EI-LCIA... 


In [7]:
F.db.factors_for_quantity('f6cbd466-253f-4145-a4bb-8dae7d266e89')


f6cbd466-253f-4145-a4bb-8dae7d266e89
Characterization Factors
 
CAS Number   |   C0   |   C1   |   C2   |   C3    Flowable
----------------------------------------------------------
007664-41-7      3.02   --         3.02     3.02  Ammonia
007446-09-5      1.31   {{==}}    1.31     1.31  Sulfur dioxide
          .      1.31              1.31     1.31  
007446-11-9      1.05   --         1.05     1.05  Sulfur trioxide
       None      3.02   --       --       --      ammonia
       None    --       --       --         3.02  ammonia
       None    --       --         3.02   --      ammonia
010102-44-0      0.74   {{==}}    0.74     0.74  nitrogen dioxide
010102-43-9      1.13   --         1.13     1.13  nitrogen monoxide
CAS Number   |   C0   |   C1   |   C2   |   C3    Flowable

Columns:
C0: Emissions to air
C1: Emissions to air, unspecified (long-term)
C2: Emissions to non-urban air or from high stacks
C3: Emissions to urban air close to ground

In [8]:
F.load(8)


Archive already loaded; specify reload=True to rewrite

In [9]:
from lcatools.interact import pick_one, cyoa, ifinput, pick_list, _pick_list

In [10]:
def find_flow(name, index=None, elementary=False):
    if name is None:
        name = input('Enter flow name search string: ')
    res = F.search(index, 'flow', Name=name)
    if elementary is not None:
        res = list(filter(lambda x: F.db.is_elementary(x.entity()) == elementary, res))
    pick = pick_one(res)
    print('Picked: %s' % pick)
    return pick

In [203]:
current_archive = None

def select_archive():
    F.show_all()
    ch1 = input('Search which catalog? or blank to search all loaded catalogs')
    if len(ch1) == 0:
        index = None
    else:
        try:
            index = int(ch1)
        except ValueError:
            index = F._catalog.get_index(ch1)
    current_archive = index
    return index

def create_fragment(parent=None):
    ch = cyoa('(N)ew flow or (S)earch for flow? ', 'ns')
    if ch == 'n':
        flow = F.new_flow()
    elif ch == 's':
        index = current_archive or select_archive()
        elem = {'i': False,
               'e': True, 
               'a': None}[cyoa('(I)ntermediate, (E)lementary, or (A)ll flows? ', 'aei', 'I').lower()]
        flow = find_flow(None, index=index, elementary=elem)
        if flow is None:
            return None
    else:
        raise ValueError
    direction = { 'i': 'Input', 'o': 'Output'}[cyoa('flow is (I)nput or (O)utput?', 'IO').lower()]
    comment = ifinput('Enter comment: ', '')
    if parent is None:
        # direction reversed for UX! user inputs direction w.r.t. fragment, not w.r.t. parent
        frag = F.new_fragment(flow, comp_dir(direction), Comment=comment)
    else:
        frag = F[0].add_child_fragment_flow(parent, flow.entity(), direction, Comment=comment)
    return frag

In [11]:
current_archive = select_archive()


LCA Catalog with the following archives:
X [ 0] FG     : ForegroundArchive with 167 entities at pet
  [ 1] ELCD   : /data/LCI/ELCD/ELCD3.2.zip
X [ 2] LCIA   : IlcdLcia with 1310 entities at /home/b/Dropbox/data/ELCD/ELCD3.2.zip
  [ 3] EI-LCIA: /data/GitHub/lca-tools-datafiles/catalogs/ei_lcia.json.gz
  [ 4] EI-U   : /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_undefined_xlsx.json.gz
  [ 5] EI_A   : /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_apos_xlsx.json.gz
  [ 6] EI_Q   : /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_consequential_xlsx.json.gz
  [ 7] EI_C   : /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_cut-off_xlsx.json.gz
X [ 8] USLCI  : EcospoldV1Archive with 4896 entities at /home/b/Dropbox/data/USLCI/USLCI_Processes_ecospold1.zip
  [ 9] GaBi-P : /data/GitHub/lca-tools-datafiles/catalogs/gabi_2016_professional-database-2016.json.gz
  [10] GaBi-X : /data/GitHub/lca-tools-datafiles/catalogs/gabi_2016_all-extensions.json.gz
Search which catalog? or blank to search all loaded catalogs8

In [12]:
frag = create_fragment()


---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
/home/b/.virtualenvs/lca-tools/lib/python3.5/site-packages/ipykernel/kernelbase.py in _input_request(self, prompt, ident, parent, password)
    713             try:
--> 714                 ident, reply = self.session.recv(self.stdin_socket, 0)
    715             except Exception:

/home/b/.virtualenvs/lca-tools/lib/python3.5/site-packages/jupyter_client/session.py in recv(self, socket, mode, content, copy)
    738         try:
--> 739             msg_list = socket.recv_multipart(mode, copy=copy)
    740         except zmq.ZMQError as e:

/home/b/.virtualenvs/lca-tools/lib/python3.5/site-packages/zmq/sugar/socket.py in recv_multipart(self, flags, copy, track)
    357         """
--> 358         parts = [self.recv(flags, copy=copy, track=track)]
    359         # have first part already, only loop while more to receive

zmq/backend/cython/socket.pyx in zmq.backend.cython.socket.Socket.recv (zmq/backend/cython/socket.c:6971)()

zmq/backend/cython/socket.pyx in zmq.backend.cython.socket.Socket.recv (zmq/backend/cython/socket.c:6763)()

zmq/backend/cython/socket.pyx in zmq.backend.cython.socket._recv_copy (zmq/backend/cython/socket.c:1931)()

/home/b/.virtualenvs/lca-tools/lib/python3.5/site-packages/zmq/backend/cython/checkrc.pxd in zmq.backend.cython.checkrc._check_rc (zmq/backend/cython/socket.c:7222)()

KeyboardInterrupt: 

During handling of the above exception, another exception occurred:

KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-12-b7c7b7273f1a> in <module>()
----> 1 frag = create_fragment()

<ipython-input-10-f18ed428c804> in create_fragment(parent)
     15 
     16 def create_fragment(parent=None):
---> 17     ch = cyoa('(N)ew flow or (S)earch for flow? ', 'ns')
     18     if ch == 'n':
     19         flow = F.new_flow()

/data/GitHub/lca-tools/lcatools/interact.py in cyoa(prompt, valid, default)
     41             i = ifinput('%s [%s]' % (prompt, valid), default)
     42         else:
---> 43             i = input(prompt)
     44         if i.lower() in valid.lower():
     45             break

/home/b/.virtualenvs/lca-tools/lib/python3.5/site-packages/ipykernel/kernelbase.py in raw_input(self, prompt)
    687             self._parent_ident,
    688             self._parent_header,
--> 689             password=False,
    690         )
    691 

/home/b/.virtualenvs/lca-tools/lib/python3.5/site-packages/ipykernel/kernelbase.py in _input_request(self, prompt, ident, parent, password)
    717             except KeyboardInterrupt:
    718                 # re-raise KeyboardInterrupt, to truncate traceback
--> 719                 raise KeyboardInterrupt
    720             else:
    721                 break

KeyboardInterrupt: 

In [13]:
def find_termination(ref, index=None, direction=None):
    if isinstance(ref, LcFragment):
        if index is None:
            index = current_archive or select_archive()
        terms = F._catalog.terminate_fragment(index, ref)
    else:
        if direction is None:
            direction = { 'i': 'Input', 'o': 'Output'}[cyoa('(I)nput or (O)utput?', 'IO').lower()]
        terms = F._catalog.terminate_flow(flow_ref, direction)
    pick = pick_one(terms)
    print('Picked: %s' % pick)
    return pick

In [14]:
def add_termination(frag, term, scenario=None):
    if isinstance(term, ExchangeRef):
        frag.term_from_exch(term, scenario=scenario)
    else:
        frag.terminate(term, scenario=scenario)
    F.build_child_flows(frag, background_children=True)

In [15]:
def auto_terminate(frag, index=None):
    ex = find_termination(frag, index=index)
    add_termination(frag, ex)

In [16]:
def foreground(frag, index=None):
    F.fragment_to_foreground(frag)
    auto_terminate(frag)

In [15]:
auto_terminate(frag)


(selecting only choice)
Picked: (USLCI) Polyethylene terephthalate, resin, at plant [Chemical Manufacturing, Petrochemical Manufacturing] <- Polyethylene terephthalate, resin, at plant [RNA]
LcFragment - Name: Acetic acid, at plant:
BG: ((B) ref) -<- d002717 -<- ---:  Acetic acid, at plant
created null termination in background
LcFragment - Name: CUTOFF Disposal, solid waste, unspecified, to municipal incineration:
BG: ((B) ref) -<- a628321 -<- ---:  CUTOFF Disposal, solid waste, unspecified, to municipal incineration
created null termination in background
LcFragment - Name: Methanol, at plant:
BG: ((B) ref) -<- f892bf8 -<- ---:  Methanol, at plant
created null termination in background
LcFragment - Name: Transport, pipeline, natural gas:
BG: ((B) ref) -<- 1b76dbd -<- ---:  Transport, pipeline, natural gas
created null termination in background
LcFragment - Name: CUTOFF Ethylene glycol, at plant:
BG: ((B) ref) -<- f83a957 -<- ---:  CUTOFF Ethylene glycol, at plant
created null termination in background
LcFragment - Name: Bituminous coal, combusted in industrial boiler:
BG: ((B) ref) -<- 1a565cd -<- ---:  Bituminous coal, combusted in industrial boiler
created null termination in background
LcFragment - Name: Diesel, combusted in industrial equipment:
BG: ((B) ref) -<- 0b263db -<- ---:  Diesel, combusted in industrial equipment
created null termination in background
LcFragment - Name: Transport, barge, diesel powered:
BG: ((B) ref) -<- cd48c3a -<- ---:  Transport, barge, diesel powered
created null termination in background
LcFragment - Name: Paraxylene, at plant:
BG: ((B) ref) -<- 01540c2 -<- ---:  Paraxylene, at plant
created null termination in background
LcFragment - Name: Residual fuel oil, combusted in industrial boiler:
BG: ((B) ref) -<- 733b5c4 -<- ---:  Residual fuel oil, combusted in industrial boiler
created null termination in background
LcFragment - Name: Electricity, at cogen, for natural gas turbine:
BG: ((B) ref) -<- 0435524 -<- ---:  Electricity, at cogen, for natural gas turbine
created null termination in background
LcFragment - Name: Transport, barge, residual fuel oil powered:
BG: ((B) ref) -<- 0a4588e -<- ---:  Transport, barge, residual fuel oil powered
created null termination in background
LcFragment - Name: Natural gas, combusted in industrial boiler:
BG: ((B) ref) -<- 4c9f8c6 -<- ---:  Natural gas, combusted in industrial boiler
created null termination in background
LcFragment - Name: CUTOFF Disposal, solid waste, unspecified, to sanitary landfill:
BG: ((B) ref) -<- 3976649 -<- ---:  CUTOFF Disposal, solid waste, unspecified, to sanitary landfill
created null termination in background
LcFragment - Name: CUTOFF Disposal, solid waste, unspecified, to waste-to-energy:
BG: ((B) ref) -<- 6f3a5da -<- ---:  CUTOFF Disposal, solid waste, unspecified, to waste-to-energy
created null termination in background
LcFragment - Name: Transport, train, diesel powered:
BG: ((B) ref) -<- e7ace8c -<- ---:  Transport, train, diesel powered
created null termination in background
LcFragment - Name: Electricity, at grid, US, 2008:
BG: ((B) ref) -<- 8430bad -<- ---:  Electricity, at grid, US, 2008
created null termination in background
LcFragment - Name: Recovered energy:
BG: ((B) ref) =>= 4241562 =>= ---:  Recovered energy
created null termination in background

In [208]:
def del_orphans(self, for_real=False):
    """
    self is a foreground archive
    """
    for f in self.fragments(show_all=True):
        if f.reference_entity is not None:
            continue
        try:
            next(_find_links(self, f))
            print('Found a link for %s' % f)
        except StopIteration:
            print('Deleting %s' % f)
            if for_real:
                del self._entities[f._uuid]


def _find_links(self, frag):
    for i in self.fragments(show_all=True):
        if i.reference_entity is frag:
            yield i
        else:
            for v in i._terminations.values():
                if v.term_node is frag:
                    yield i

In [211]:
del_orphans(F[0])


Found a link for ( ** ref) -<- d002717 -<- -*    Acetic acid, at plant
Found a link for ( ** ref) -<- 410a96e -<- -O    something that requires gas transport
Found a link for ( ** ref) -<- cd48c3a -<- -*    Transport, barge, diesel powered
Found a link for ( ** ref) -<- e7ace8c -<- -*    Transport, train, diesel powered
Found a link for ( ** ref) -<- 2c8ba87 -<- -*    Transport, barge, average fuel mix
Found a link for ( ** ref) -<- 114c1d5 -<- -*    Transport, combination truck, diesel powered
Found a link for ( ** ref) -<- 0a4588e -<- -*    Transport, barge, residual fuel oil powered
Found a link for ( ** ref) -<- 1b76dbd -<- -*    Transport, pipeline, natural gas
Found a link for ( ** ref) -<- 68d264d -<- -*    Transport, combination truck, average fuel mix
Found a link for ( ** ref) -<- f2118f0 -<- -*    Transport, pipeline, unspecified petroleum products
Found a link for ( ** ref) -<- 0c44dc5 -<- -*    Polyethylene terephthalate, resin, at plant
Found a link for ((B) ref) -<- 5dfdb2f -<- ---:  Bituminous coal, at mine
Found a link for ((B) ref) -<- 0f4d896 -<- ---:  CUTOFF Transport, pipeline, coal slurry
Found a link for ((B) ref) -<- a8a990e -<- ---:  CUTOFF Disposal, solid waste, unspecified, to unspecified treatment
Found a link for ((B) ref) -<- 6f3a5da -<- ---:  CUTOFF Disposal, solid waste, unspecified, to waste-to-energy
Found a link for ((B) ref) -<- 0435524 -<- ---:  Electricity, at cogen, for natural gas turbine
Found a link for ((B) ref) =>= 5d4787c =>= ---:  Recovered energy, at acetic acid production
Found a link for ((B) ref) =>= 4241562 =>= ---:  Recovered energy
Found a link for ((B) ref) -<- 3976649 -<- ---:  CUTOFF Disposal, solid waste, unspecified, to sanitary landfill
Found a link for ((B) ref) -<- e436896 -<- ---:  Diesel, at refinery
Found a link for ((B) ref) -<- 86c34c7 -<- ---:  Electricity, at grid, US, 2000
Found a link for ((B) ref) -<- 4d264ea -<- ---:  Residual fuel oil, at refinery
Found a link for ((B) ref) -<- f892bf8 -<- ---:  Methanol, at plant
Found a link for ((B) ref) -<- 8430bad -<- ---:  Electricity, at grid, US, 2008
Found a link for ((B) ref) -<- 7b2c550 -<- ---:  CUTOFF Disposal, ash and flue gas desulfurization sludge, to unspecified reuse
Found a link for ((B) ref) -<- a628321 -<- ---:  CUTOFF Disposal, solid waste, unspecified, to municipal incineration
Found a link for ((B) ref) -<- 278d2e1 -<- ---:  Natural gas, processed, at plant

In [12]:
F.draw_fragment(F.frag('1b7'))


-<--*   1b76dbd (      1) Transport, pipeline, natural gas
    | -<--*   b78ac6f (  0.012) Natural gas, combusted in industrial equipment
    |     | -<----: 9ca8b7d (    1.2) Transport, pipeline, natural gas
    |     | -<--#   78a3212 (    0.2) Transport, combination truck, average fuel mix
    |     | -<--#   dc450e8 (  0.012) Transport, train, diesel powered
    |     | -<---C  e038531 (      1) Natural gas, processed, at plant
    |     x 
    x 

In [54]:
F.frag('b14').terminate(None)

In [30]:
[str(x) for x in F[0].fragments(show_all=True, background=False, match='combust')]


Out[30]:
['(0c44dc5) -<- 4f772f2 -<- -*    Residual fuel oil, combusted in industrial boiler',
 '(0c44dc5) -<- 1a7d38d -<- -*    Natural gas, combusted in industrial boiler',
 '(0c44dc5) -<- a95908c -<- -*    Bituminous coal, combusted in industrial boiler',
 '(1b76dbd) -<- b78ac6f -<- -*    Natural gas, combusted in industrial equipment',
 '(0c44dc5) -<- 4083ab8 -<- -*    Diesel, combusted in industrial equipment']

In [18]:
F.show_fragments(show_all=False, background=False)


( ** ref) -<- d002717 -<- -*    Acetic acid, at plant
( ** ref) -<- cd48c3a -<- -*    Transport, barge, diesel powered
( ** ref) -<- e7ace8c -<- -*    Transport, train, diesel powered
( ** ref) -<- 2c8ba87 -<- -*    Transport, barge, average fuel mix
( ** ref) -<- 114c1d5 -<- -*    Transport, combination truck, diesel powered
( ** ref) -<- 0a4588e -<- -*    Transport, barge, residual fuel oil powered
( ** ref) -<- 1b76dbd -<- -*    Transport, pipeline, natural gas
( ** ref) -<- 68d264d -<- -*    Transport, combination truck, average fuel mix
( ** ref) -<- f2118f0 -<- -*    Transport, pipeline, unspecified petroleum products
( ** ref) -<- 0c44dc5 -<- -*    Polyethylene terephthalate, resin, at plant

In [13]:
F.compute_unit_scores()

In [14]:
F.show_all()


LCA Catalog with the following archives:
X [ 0] FG     : ForegroundArchive with 167 entities at pet
  [ 1] ELCD   : /data/LCI/ELCD/ELCD3.2.zip
X [ 2] LCIA   : IlcdLcia with 33957 entities at /home/b/Dropbox/data/ELCD/ELCD3.2-a.zip
  [ 3] EI-LCIA: /data/GitHub/lca-tools-datafiles/catalogs/ei_lcia.json.gz
  [ 4] EI-U   : /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_undefined_xlsx.json.gz
  [ 5] EI_A   : /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_apos_xlsx.json.gz
  [ 6] EI_Q   : /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_consequential_xlsx.json.gz
  [ 7] EI_C   : /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_cut-off_xlsx.json.gz
X [ 8] USLCI  : EcospoldV1Archive with 4896 entities at /home/b/Dropbox/data/USLCI/USLCI_Processes_ecospold1.zip
  [ 9] GaBi-P : /data/GitHub/lca-tools-datafiles/catalogs/gabi_2016_professional-database-2016.json.gz
  [10] GaBi-X : /data/GitHub/lca-tools-datafiles/catalogs/gabi_2016_all-extensions.json.gz

In [15]:
frag = F.frag('0c4')

In [224]:
_qs = (x for x in F[0].lcia_methods())

In [223]:
results = F.fg_lcia(frag.term.term_node)

In [225]:
q = next(_qs)
str(q)


Out[225]:
'ILCD2011; Climate change; midpoint; GWP100; IPCC2007 [LCIA]'

In [242]:
F.db.flowables.synonyms_for('010102-44-0')


Out[242]:
{'010102-44-0',
 '08a91e70-3ddc-11dd-96e5-0050c2490048',
 '08a91e70-3ddc-11dd-96e6-0050c2490048',
 '08a91e70-3ddc-11dd-96e7-0050c2490048',
 '08a91e70-3ddc-11dd-96e8-0050c2490048',
 '08a91e70-3ddc-11dd-96e9-0050c2490048',
 '08a91e70-3ddc-11dd-96ea-0050c2490048',
 '08a91e70-3ddc-11dd-96eb-0050c2490048',
 '08a91e70-3ddc-11dd-96ec-0050c2490048',
 '08a91e70-3ddc-11dd-96ed-0050c2490048',
 '29063b80-6556-11dd-ad8b-0800200c9a66',
 '29063b81-6556-11dd-ad8b-0800200c9a66',
 '29063b82-6556-11dd-ad8b-0800200c9a66',
 '2fb4ca68-6eb1-3f0b-b907-70cdc6f050f2',
 'AC1MHUB8',
 'Dinitrogen tetroxide',
 'NITROGEN TETROXIDE',
 'ac1mhub8',
 'dinitrogen tetroxide',
 'nitrogen dioxide',
 'nitrogen tetroxide'}

In [69]:
[x.flow.get_uuid() for x in frag.term.term_node.entity().exchanges() if x.flow['Name'] == 'Nitrogen oxides ']


Out[69]:
['2fb4ca68-6eb1-3f0b-b907-70cdc6f050f2']

In [240]:
F.db.flowables.add_synonym('010102-44-0', '2fb4ca68-6eb1-3f0b-b907-70cdc6f050f2')


Out[240]:
1839

In [226]:
results[q.get_uuid()].show_details(show_all=True)


ILCD2011; Climate change; midpoint; GWP100; IPCC2007 [LCIA] kg
------------------------------------------------------------
    0.0724 x          1 =     0.0724 [GLO] Carbon dioxide, fossil  [air, unspecified]
   0.00016 x         25 =      0.004 [GLO] Methane  [air, unspecified]
   9.7e-10 x       ---- =          0 [GLO] Aluminum [water, unspecified]
   0.00011 x       ---- =          0 [GLO] Ammonia [water, unspecified]
   5.1e-05 x       ---- =          0 [GLO] Acetic acid [air, unspecified]
   4.4e-05 x       ---- =          0 [GLO] TOC, Total Organic Carbon [water, unspecified]
   0.00568 x       ---- =          0 [GLO] Carbon monoxide [air, unspecified]
     4e-05 x       ---- =          0 [GLO] Methyl acetate [air, unspecified]
    0.0003 x       ---- =          0 [GLO] BOD5, Biological Oxygen Demand [water, unspecified]
   7.9e-05 x       ---- =          0 [GLO] Bromine [air, unspecified]
   9.7e-10 x       ---- =          0 [GLO] Iron [water, unspecified]
   0.00015 x       ---- =          0 [GLO] Particulates, unspecified [air, unspecified]
   5.5e-06 x       ---- =          0 [GLO] Zinc [water, unspecified]
   0.00028 x       ---- =          0 [GLO] NMVOC, non-methane volatile organic compounds, unspecified  [Elementary Flows]
   1.3e-06 x       ---- =          0 [GLO] Ammonium ion [water, unspecified]
   0.00076 x       ---- =          0 [GLO] COD, Chemical Oxygen Demand [water, unspecified]
  0.000244 x       ---- =          0 [GLO] Water, process, unspecified natural origin/m3 [water, unspecified]
   0.00094 x       ---- =          0 [GLO] Organic substances, unspecified [air, unspecified]
     3e-05 x       ---- =          0 [GLO] Dissolved solids [water, unspecified]
   9.7e-10 x       ---- =          0 [GLO] Antimony [water, unspecified]
   4.5e-09 x       ---- =          0 [GLO] Metallic ions, unspecified [water, unspecified]
   9.4e-05 x       ---- =          0 [GLO] Aldehydes [Elementary Flows]
   4.1e-05 x       ---- =          0 [GLO] Xylene [air, unspecified]
   5.2e-05 x       ---- =          0 [GLO] Nitrogen oxides  [air, unspecified]
   5.4e-05 x       ---- =          0 [GLO] Suspended solids, unspecified [water, unspecified]
   3.6e-09 x       ---- =          0 [GLO] Phenol compounds, unspecified [water, unspecified]
   5.1e-07 x       ---- =          0 [GLO] Phosphates [water, unspecified]
============================================================
             Total score: 0.0764 
    0.0764 ILCD2011; Climate change; midpoint; GWP100; IPCC2007 [LCIA]

In [227]:
F.db.factors_for_quantity(q)


ILCD2011; Climate change; midpoint; GWP100; IPCC2007 [LCIA]
Characterization Factors
 
CAS Number   |   C0   |   C1   |   C2   |   C3   |   C4   |   C5   |   C6   |   C7   |   C8   |   C9    Flowable
----------------------------------------------------------------------------------------------------------------
000431-89-0  3.22e+03 3.22e+03   --     3.22e+03 3.22e+03   --       --       --       --       --      1,1,1,2,3,3,3-heptafluoropropane
000431-63-0  1.37e+03 1.37e+03   --     1.37e+03 1.37e+03   --       --       --       --       --      1,1,1,2,3,3-hexafluoropropane
000378-16-5        11       11   --           11       11   --       --       --       --       --      2,2,3,3,3-Pentafluoropropyl methyl ether
000076-15-3  7.37e+03 7.37e+03 7.37e+03 7.37e+03 7.37e+03   --       --       --       --       --      CFC-115
000075-72-9  1.44e+04 1.44e+04 1.44e+04 1.44e+04 1.44e+04   --       --       --       --       --      CFC-13
000420-46-2  4.47e+03 4.47e+03   --     4.47e+03 4.47e+03   --       --       --       --       --      CFC-143a
000124-38-9     -0.01        1        1        1        1   --       --       --       --           -1  Carbon dioxide, fossil
          .         1        1        1        1        1                                               
          .         1        1        1        1        1                                               
          .     -0.01                                                                                   
          .         1                                                                                   
000067-66-3        31       31       31       31       31   --       --       --       --       --      Chloroform
010024-97-2       298      298      298      298      298   --       --       --       --       --      Dinitrogen monoxide
          .     -2.98                                                                                   
000811-97-2  1.43e+03 1.43e+03 1.43e+03 1.43e+03 1.43e+03   --       --       --       --       --      Ethane, 1,1,1,2-tetrafluoro-, HFC-134a
000071-55-6       146      146      146      146      146   --       --       --       --       --      Ethane, 1,1,1-trichloro-, HCFC-140
000076-13-1  6.13e+03 6.13e+03   --     6.13e+03 6.13e+03   --       --       --       --       --      Ethane, 1,1,2-trichloro-1,2,2-trifluoro-, CFC-113
000075-37-6       124      124      124      124      124   --       --       --       --       --      Ethane, 1,1-difluoro-, HFC-152a
000076-14-2     1e+04    1e+04    1e+04    1e+04    1e+04   --       --       --       --       --      Ethane, 1,2-dichloro-1,1,2,2-tetrafluoro-, CFC-114
002837-89-0       609      609      609      609      609   --       --       --       --       --      Ethane, 2-chloro-1,1,1,2-tetrafluoro-, HCFC-124
000076-16-4  1.22e+04 1.22e+04 1.22e+04 1.22e+04 1.22e+04   --       --       --       --       --      Ethane, hexafluoro-, HFC-116
000115-25-3  1.03e+04 1.03e+04 1.03e+04 1.03e+04 1.03e+04   --       --       --       --       --      FC-318
000306-83-2        77       77       77       77       77   --       --       --       --       --      HCFC-123
001717-00-6       725      725      725      725      725   --       --       --       --       --      HCFC-141b
000075-68-3  2.31e+03 2.31e+03   --     2.31e+03 2.31e+03   --       --       --       --       --      HCFC-142
000422-56-0       122      122      122      122      122   --       --       --       --       --      HCFC-225ca
000507-55-1       595      595      595      595      595   --       --       --       --       --      HCFC-225cb
026675-46-7       350      350      350      350      350   --       --       --       --       --      HCFE-235da2
000354-33-6   3.5e+03  3.5e+03  3.5e+03  3.5e+03  3.5e+03   --       --       --       --       --      HFC-125
000359-35-3   1.1e+03  1.1e+03  1.1e+03  1.1e+03  1.1e+03   --       --       --       --       --      HFC-134
000430-66-0       353      353      353      353      353   --       --       --       --       --      HFC-143
000624-72-6        53       53       53       53       53   --       --       --       --       --      HFC-152
000353-36-6        12       12       12       12       12   --       --       --       --       --      HFC-161
       None    --       --       --       --     1.34e+03   --       --       --       --       --      HFC-236cb
       None    --       --       --     1.34e+03   --       --       --       --       --       --      HFC-236cb
000677-56-5  1.34e+03 1.34e+03 1.34e+03 1.34e+03 1.34e+03   --       --       --       --       --      HFC-236cb
       None    --     1.34e+03   --       --       --       --       --       --       --       --      HFC-236cb
       None    --       --     1.34e+03   --       --       --       --       --       --       --      HFC-236cb
000690-39-1  9.81e+03 9.81e+03 9.81e+03 9.81e+03 9.81e+03   --       --       --       --       --      HFC-236fa
000679-86-7       693      693      693      693      693   --       --       --       --       --      HFC-245ca
000460-73-1  1.03e+03 1.03e+03 1.03e+03 1.03e+03 1.03e+03   --       --       --       --       --      HFC-245fa
000075-10-5       675      675      675      675      675   --       --       --       --       --      HFC-32
000406-58-6       794      794      794      794      794   --       --       --       --       --      HFC-365mfc
000593-53-3        92       92       92       92       92   --       --       --       --       --      HFC-41
138495-42-8  1.64e+03 1.64e+03   --     1.64e+03 1.64e+03   --       --       --       --       --      HFC-4310mee
003822-68-2  1.49e+04 1.49e+04 1.49e+04 1.49e+04 1.49e+04   --       --       --       --       --      HFE-125
001691-17-4  6.32e+03 6.32e+03 6.32e+03 6.32e+03 6.32e+03   --       --       --       --       --      HFE-134
       None  1.54e+03 1.54e+03   --     1.54e+03 1.54e+03   --       --       --       --       --      HFE-227EA
       None   2.8e+03  2.8e+03   --      2.8e+03  2.8e+03   --       --       --       --       --      HFE-236ca12 (HG-10)
084011-06-3       989      989   --          989      487   --       --       --       --       --      HFE-236ea2
          .       487      487               487      989                                               
001885-48-9       286      286      659      286      708   --       --       --       --       --      HFE-245fa1
          .       708      659      708      659      286                                               
          .       659      708               708      659                                               
000425-88-7       359      359      359      359      359   --       --       --       --       --      HFE-254cb2
       None        11       11   --           11       11   --       --       --       --       --      HFE-263fb2
       None       919      919   --          919      919   --       --       --       --       --      HFE-329mcc2
       None       552      552   --          552      552   --       --       --       --       --      HFE-338mcf2
       None   1.5e+03  1.5e+03   --      1.5e+03  1.5e+03   --       --       --       --       --      HFE-338pcc13 (HG-01)
000406-78-0       575      374      575      374      374   --       --       --       --       --      HFE-347mcf2
          .       374      575               575      575                                               
       None       580      580   --          580      580   --       --       --       --       --      HFE-347pcf2
000382-34-3       502      265      502      110      110   --       --       --       --       --      HFE-356pcf2
          .       101      101               265      265                                               
          .       265      110               101      101                                               
          .       110      502               502      502                                               
000512-51-6       557      557      557      557      557   --       --       --       --       --      HFE-374pc2
       None  1.87e+03 1.87e+03   --     1.87e+03 1.87e+03   --       --       --       --       --      HFE-43-10pccc124 (H-Galden1040x)
163702-05-4        59       59   --           59       59   --       --       --       --       --      HFE-569sf2
014117-17-0       297      297      297      297      297   --       --       --       --       --      HFE-7100
001511-62-2       404      404      404      404      404   --       --       --       --       --      Halon-1201
000124-73-2  1.64e+03 1.64e+03 1.64e+03 1.64e+03 1.64e+03   --       --       --       --       --      Halon-2402
       None        25       25       25       25       25   --       --       --       --       --      Methane
000074-83-9         5        5        5        5        5   --       --       --       --       --      Methane, bromo-, Halon 1001
000353-59-3  1.89e+03 1.89e+03 1.89e+03 1.89e+03 1.89e+03   --       --       --       --       --      Methane, bromochlorodifluoro-, Halon 1211
000075-63-8  7.14e+03 7.14e+03 7.14e+03 7.14e+03 7.14e+03   --       --       --       --       --      Methane, bromotrifluoro-, Halon 1301
000075-45-6  1.81e+03 1.81e+03 1.81e+03 1.81e+03 1.81e+03   --       --       --       --       --      Methane, chlorodifluoro-, HCFC-22
000075-09-2       8.7      8.7      8.7      8.7      8.7      8.7      8.7      8.7      8.7   --      Methane, dichloro-, HCC-30
000075-71-8  1.09e+04 1.09e+04 1.09e+04 1.09e+04 1.09e+04   --       --       --       --       --      Methane, dichlorodifluoro-, CFC-12
000075-43-4       151      151      151      151      151   --       --       --       --       --      Methane, dichlorofluoro-, HCFC-21
000074-82-8        25       25       25       25       25   --       --       --       --       --      Methane, fossil
          .     -0.25       25       25       25       25                                               
          .        25       25       25       25       25                                               
          .        25                                                                                   
          .     -0.25                                                                                   
000074-87-3        13       13       13       13       13   --       --       --       --       --      Methane, monochloro-, R-40
000056-23-5   1.4e+03  1.4e+03  1.4e+03  1.4e+03  1.4e+03  1.4e+03  1.4e+03  1.4e+03  1.4e+03   --      Methane, tetrachloro-, R-10
000075-73-0  7.39e+03 7.39e+03 7.39e+03 7.39e+03 7.39e+03   --       --       --       --       --      Methane, tetrafluoro-, R-14
000075-69-4  4.75e+03 4.75e+03 4.75e+03 4.75e+03 4.75e+03   --       --       --       --       --      Methane, trichlorofluoro-, CFC-11
000075-46-7  1.48e+04 1.48e+04 1.48e+04 1.48e+04 1.48e+04   --       --       --       --       --      Methane, trifluoro-, HFC-23
000421-14-7       756      756   --          756      756   --       --       --       --       --      Methyl trifluoromethyl ether
007783-54-2  1.72e+04 1.72e+04   --     1.72e+04 1.72e+04   --       --       --       --       --      Nitrogen fluoride
       None   7.5e+03  7.5e+03   --      7.5e+03  7.5e+03   --       --       --       --       --      PFC-9-1-18
       None  1.03e+04 1.03e+04   --     1.03e+04 1.03e+04   --       --       --       --       --      PFPMIE
002551-62-4  2.28e+04 2.28e+04 2.28e+04 2.28e+04 2.28e+04   --       --       --       --       --      Sulfur hexafluoride
          .      -228                                                                                   
000074-95-3      1.54     1.54     1.54     1.54     1.54   --       --       --       --       --      dibromomethane
000678-26-2  9.16e+03 9.16e+03 9.16e+03 9.16e+03 9.16e+03   --       --       --       --       --      dodecafluoropentane
002314-97-8       0.4      0.4      0.4      0.4      0.4   --       --       --       --       --      iodotrifluoromethane
       None        25   --       --       --       --       --       --       --       --       --      methane
       None    --           25   --       --       --       --       --       --       --       --      methane
       None    --       --       --       --           25   --       --       --       --       --      methane
       None    --       --       --           25   --       --       --       --       --       --      methane
       None    --       --           25   --       --       --       --       --       --       --      methane
       None        25       25       25       25       25   --       --       --       --       --      methane (biogenic)
       None        25   --       --       --       --       --       --       --       --       --      methane (biogenic)
       None    --           25   --       --       --       --       --       --       --       --      methane (biogenic)
       None    --       --       --       --           25   --       --       --       --       --      methane (biogenic)
       None    --       --       --           25   --       --       --       --       --       --      methane (biogenic)
       None    --       --           25   --       --       --       --       --       --       --      methane (biogenic)
       None        25       25       25       25       25   --       --       --       --       --      methane (fossil)
       None    --           25   --       --       --       --       --       --       --       --      methane (fossil)
       None    --       --       --       --           25   --       --       --       --       --      methane (fossil)
       None    --       --       --           25   --       --       --       --       --       --      methane (fossil)
       None    --       --           25   --       --       --       --       --       --       --      methane (fossil)
000115-10-6         1        1        1        1        1   --       --       --       --       --      methyl ether
010024-97-3    --       --          298   --       --       --       --       --       --       --      nitrous oxide
000355-25-9  8.86e+03 8.86e+03 8.86e+03 8.86e+03 8.86e+03   --       --       --       --       --      perfluorobutane
000355-42-0   9.3e+03  9.3e+03  9.3e+03  9.3e+03  9.3e+03   --       --       --       --       --      perfluorohexane
000076-19-7  8.83e+03 8.83e+03 8.83e+03 8.83e+03 8.83e+03   --       --       --       --       --      perfluoropropane
000373-80-8  1.77e+04 1.77e+04   --     1.77e+04 1.77e+04   --       --       --       --       --      sulphur, trifluoromethyl pentafluoride
CAS Number   |   C0   |   C1   |   C2   |   C3   |   C4   |   C5   |   C6   |   C7   |   C8   |   C9    Flowable

Columns:
C0: Emissions to air
C1: Emissions to air, unspecified (long-term)
C2: Emissions to lower stratosphere and upper troposphere
C3: Emissions to non-urban air or from high stacks
C4: Emissions to urban air close to ground
C5: water
C6: Emissions to fresh water
C7: Emissions to water, unspecified (long-term)
C8: ocean
C9: Resources from air

In [233]:
for fb in F.db.flowables.search('chromium III'):
    print(F.db.flowables.synonym_set(fb))


{'016065-83-1', 'cr+3', 'cr3+', 'CR+3', '08a91e70-3ddc-11dd-9f79-0050c2490048', 'chromium, ion (cr3+)', 'chromium (iii) ion', 'Cr3+', 'Chromic ion', 'chromium(3+)ion', 'Chromium(III) compounds, n.o.s', 'chromium(iii), chromium(iii) insoluble salts, chromic ion, chromium ion, trivalent chromium', 'chromium iii', 'Chromium, ion (Cr 3+)', 'chromium ion(cr3+)', 'Chromium (III), insoluble salts', 'chromium(3+)', 'Cr(3+)', 'Chromium, ion(Cr3+)', 'chromium(3+) ions', '4d9a8790-3ddd-11dd-8fd2-0050c2490048', '4d9a8790-3ddd-11dd-8fd1-0050c2490048', 'Chromium (III) ion', 'chromium, ion(cr3+)', '08a91e70-3ddc-11dd-9f7c-0050c2490048', 'Chromium (3+)', 'Chromium(III), Chromium(III) insoluble salts, Chromic ion, Chromium ion, trivalent Chromium', 'chromium (iii), insoluble salts', 'Chromium(III) compounds, n.o.s.', 'ac1l1dpd', '4d9a8790-3ddd-11dd-8fd0-0050c2490048', 'Chromium ion (3+)', '4d9a8790-3ddd-11dd-8fd4-0050c2490048', 'CHROMIUM (III)', 'Chromium ion(Cr3+)', '3e4c8d2d-6556-11dd-ad8b-0800200c9a66', 'cr(3+)', 'chromium, ion', '08a91e70-3ddc-11dd-9f7b-0050c2490048', '08a91e70-3ddc-11dd-9f7a-0050c2490048', 'chromium III', 'chromium(iii) compounds, n.o.s.', '4d9a8790-3ddd-11dd-8fcf-0050c2490048', 'chromium(iii) cation', '4d9a8790-3ddd-11dd-8fce-0050c2490048', 'cr(iii)', 'chromium ion (3+)', 'Chromium(3+)ion', 'chromium (iii)', 'Chromium(3+) ions', 'Cr(III)', 'chromium (3+)', 'chromium(iii) compounds, n.o.s', 'chromium(iii)', 'Chromium(III) cation', 'Chromium(III)', '4d9a8790-3ddd-11dd-8fd3-0050c2490048', 'chromic ion', 'AC1L1DPD', 'Chromium, ion', 'chromium, ion (cr 3+)', 'Chromium, ion (cr3+)'}

In [234]:
for fb in F.db.flowables.search('chromium VI'):
    print(F.db.flowables.synonym_set(fb))


{'Chromium(VI) compounds', 'chromium (hexavalent compounds)', 'chromium VI', 'chromium compounds, hexavalent', 'Chromium(VI) compounds, n.o.s', 'fe0acd60-3ddc-11dd-a70d-0050c2490048', '018540-29-9', 'CR+6', '08a91e70-3ddc-11dd-950b-0050c2490048', 'Chromium(6+)', 'chromium(6+)ion', 'Chromium, hexavalent', 'Chromium VI', '4d9a8790-3ddd-11dd-8fd7-0050c2490048', '4d9a8790-3ddd-11dd-8fd5-0050c2490048', '3e4c8d50-6556-11dd-ad8b-0800200c9a66', 'chromium(VI) cation', 'fe0acd60-3ddc-11dd-a70c-0050c2490048', 'cr(6+)', 'Chromium, ion (Cr6+)', 'Chromium, ion (Cr 6+)', 'Chromium(6+)ion', 'chromium, ion(cr6+)', 'chromium(vi)', '4d9a8790-3ddd-11dd-9c1f-0050c2490048', 'Chromium(6+)ions', 'hexavalent chromium', 'chromium (cr(sup 6+))', 'Cr6+', 'ac1l1gta', 'Chromium (hexavalent compounds)', 'chromium(vi) ions', 'NCI-C04273', 'Chromium compounds, hexavalent', 'AC1L1GTA', '(51cr)chromium(6+)', '4d9a8790-3ddd-11dd-8fd6-0050c2490048', '4d9a8790-3ddd-11dd-8fd8-0050c2490048', 'fe0acd60-3ddc-11dd-a70b-0050c2490048', 'Chromium hexavalent ion', 'Chromium, hexavalent (Cr(VI))', 'chromium(vi) compounds, n.o.s', 'Chromium (cr(sup 6+))', 'Chromium(6+) ion', 'chromium(vi) cation', 'chromium hexavalent ion', 'chromium(6+)ions', 'chromium, hexavalent (cr(vi))', '4d9a8790-3ddd-11dd-9c1d-0050c2490048', 'chromium, ion (cr 6+)', 'chromium(vi) compounds', 'Cr(VI)', 'chromium(6+) ions', 'chromium, ion (cr6+)', 'Chromium, ion(Cr6+)', 'kst-1a4572', '4d9a8790-3ddd-11dd-9c1e-0050c2490048', 'cr+6', 'Chromium(VI) compounds, n.o.s.', 'chromium, hexavalent', 'chromium(vi) compounds, n.o.s.', 'cr(vi)', 'chromium(6+) ion', 'Hexavalent chromium', 'nci-c04273', 'Cr(6+)', 'chromium(6+)', 'Chromium(VI) ions', 'chromium vi', 'Chromium(6+) ions', 'KST-1A4572', 'Chromium(VI)', 'cr6+'}

In [111]:
F.show_fragments()


( ** ref) -<- d002717 -<- -*    Acetic acid, at plant
( ** ref) -<- cd48c3a -<- -*    Transport, barge, diesel powered
( ** ref) -<- e7ace8c -<- -*    Transport, train, diesel powered
( ** ref) -<- 2c8ba87 -<- -*    Transport, barge, average fuel mix
( ** ref) -<- 114c1d5 -<- -*    Transport, combination truck, diesel powered
( ** ref) -<- 0a4588e -<- -*    Transport, barge, residual fuel oil powered
( ** ref) -<- 1b76dbd -<- -*    Transport, pipeline, natural gas
( ** ref) -<- 68d264d -<- -*    Transport, combination truck, average fuel mix
( ** ref) -<- f2118f0 -<- -*    Transport, pipeline, unspecified petroleum products
( ** ref) -<- 0c44dc5 -<- -*    Polyethylene terephthalate, resin, at plant
((B) ref) -<- 5dfdb2f -<- ---:  Bituminous coal, at mine
((B) ref) -<- 0f4d896 -<- ---:  CUTOFF Transport, pipeline, coal slurry
((B) ref) -<- a8a990e -<- ---:  CUTOFF Disposal, solid waste, unspecified, to unspecified treatment
((B) ref) -<- 6f3a5da -<- ---:  CUTOFF Disposal, solid waste, unspecified, to waste-to-energy
((B) ref) -<- 0435524 -<- ---:  Electricity, at cogen, for natural gas turbine
((B) ref) =>= 5d4787c =>= ---:  Recovered energy, at acetic acid production
((B) ref) =>= 4241562 =>= ---:  Recovered energy
((B) ref) -<- 3976649 -<- ---:  CUTOFF Disposal, solid waste, unspecified, to sanitary landfill
((B) ref) -<- e436896 -<- ---:  Diesel, at refinery
((B) ref) -<- 86c34c7 -<- ---:  Electricity, at grid, US, 2000
((B) ref) -<- 4d264ea -<- ---:  Residual fuel oil, at refinery
((B) ref) -<- f892bf8 -<- ---:  Methanol, at plant
((B) ref) -<- 8430bad -<- ---:  Electricity, at grid, US, 2008
((B) ref) -<- 7b2c550 -<- ---:  CUTOFF Disposal, ash and flue gas desulfurization sludge, to unspecified reuse
((B) ref) -<- a628321 -<- ---:  CUTOFF Disposal, solid waste, unspecified, to municipal incineration
((B) ref) -<- 278d2e1 -<- ---:  Natural gas, processed, at plant

In [95]:
F.frag('1b7').direction


Out[95]:
'Input'

In [80]:
ios = F.get_fragment_inventory(F.frag('1b7'))


descending
descending
descending

In [144]:
ffs, _ = F.frag('1b7').traverse(lambda x: F.child_flows(x), 1.0, None)


descending
descending
descending

In [145]:
ffs


Out[145]:
[<lcatools.foreground.fragment_flows.FragmentFlow at 0x7fbfc9e3fcc0>,
 <lcatools.foreground.fragment_flows.FragmentFlow at 0x7fbfc9e3f550>,
 <lcatools.foreground.fragment_flows.FragmentFlow at 0x7fbfc9e3f5f8>,
 <lcatools.foreground.fragment_flows.FragmentFlow at 0x7fbfc9e3f668>,
 <lcatools.foreground.fragment_flows.FragmentFlow at 0x7fbfc9e3f780>,
 <lcatools.foreground.fragment_flows.FragmentFlow at 0x7fbfc9e3f7f0>,
 <lcatools.foreground.fragment_flows.FragmentFlow at 0x7fbfc9e3f898>,
 <lcatools.foreground.fragment_flows.FragmentFlow at 0x7fbfc9e3f908>,
 <lcatools.foreground.fragment_flows.FragmentFlow at 0x7fbfc9e3f828>,
 <lcatools.foreground.fragment_flows.FragmentFlow at 0x7fbfc9e3f860>,
 <lcatools.foreground.fragment_flows.FragmentFlow at 0x7fbfc9e3f080>,
 <lcatools.foreground.fragment_flows.FragmentFlow at 0x7fbfc9e3f358>]

In [151]:
F.draw_fragment(F.frag('1b7'))


-<--*   1b76dbd (      1) Transport, pipeline, natural gas
    | -<--*   b78ac6f (  0.012) Natural gas, combusted in industrial equipment
    |     | -<----: 9ca8b7d (    1.2) Transport, pipeline, natural gas
    |     | -<--#   78a3212 (    0.2) Transport, combination truck, average fuel mix
    |     | -<--#   dc450e8 (  0.012) Transport, train, diesel powered
    |     | -<---C  e038531 (      1) Natural gas, processed, at plant
    |     x 
    x 

In [158]:
F.draw_fragment(F.frag('78a').term.term_node)


-<--*   68d264d (      1) Transport, combination truck, average fuel mix
    | -<--#   cf3ed88 (      1) Transport, combination truck, diesel powered
    x 

In [159]:
F.draw_fragment(F.frag('cf3').term.term_node)


-<--*   114c1d5 (      1) Transport, combination truck, diesel powered
    | -<---C  4b85d4b (  0.027) Diesel, at refinery
    x 

In [174]:
tot = 0.0
for f in ffs:
    if f.term.score_cache(q) is None:
        score = '--'
        total = ' '
    else:
        scr = f.term.score_cache(q).total()
        score = '%-10.3g' % scr
        total = '%-10.3g' % (scr * f.node_weight)
        tot += (scr * f.node_weight)
    print('%-10.10s %-10.10s %s' % (total, score, f))
print('%-10.3g Total' % tot)


0          0          1b76dbd          1 [ Input] -#  Transport, pipeline, natural gas
1.51e-05   0.00125    b78ac6f     0.0121 [ Input] -#  Natural gas, combusted in industrial equipment
           --         78a3212    0.00241 [ Input] -#  Transport, combination truck, average fuel mix
0          0          68d264d    0.00241 [ Input] -#  Transport, combination truck, average fuel mix
           --         cf3ed88    0.00241 [ Input] -#  Transport, combination truck, diesel powered
1e-06      0.000417   114c1d5    0.00241 [ Input] -#  Transport, combination truck, diesel powered
           --         4b85d4b   6.56e-05 [ Input] --: Diesel, at refinery
           --         9ca8b7d     0.0144 [ Input] --: Transport, pipeline, natural gas
           --         e038531     0.0121 [ Input] --: Natural gas, processed, at plant
           --         dc450e8   0.000144 [ Input] -#  Transport, train, diesel powered
5.39e-08   0.000374   e7ace8c   0.000144 [ Input] -#  Transport, train, diesel powered
           --         0183c1a   9.33e-07 [ Input] --: Diesel, at refinery
1.62e-05   Total

In [183]:
['%10.6g %s' % (x.value, x.flow) for x in F.db.filter_exch(F.frag('b78').term.term_node, elem=False)]


Out[183]:
['    0.1985 Transport, combination truck, average fuel mix [Truck Transportation, General Freight Trucking]',
 '         1 Natural gas, processed, at plant [Chemical Manufacturing, Petrochemical Manufacturing]',
 '  0.011858 Transport, train, diesel powered [Rail Transportation, Rail Transportation]',
 '     1.186 Transport, pipeline, natural gas [Utilities, Fossil Fuel Electric Power Generation]',
 '         1 Natural gas, combusted in industrial equipment [Utilities, Steam and Air-Conditioning Supply]']

In [184]:
['%10.6g %s' % (x.value, x.flow) for x in F.db.filter_exch(F.frag('1b7').term.term_node, elem=False)]


Out[184]:
[' 0.0121378 Natural gas, combusted in industrial equipment [Utilities, Steam and Air-Conditioning Supply]',
 '         1 Transport, pipeline, natural gas [Utilities, Fossil Fuel Electric Power Generation]']

In [220]:
(.0121378 )/ (1.0 - .0144)


Out[220]:
0.012315137987012987

In [191]:
F.frag('1b7').term.term_flow.origin


Out[191]:
'/home/b/Dropbox/data/USLCI/USLCI_Processes_ecospold1.zip'

In [157]:
ffs[1].__dict__


Out[157]:
{'fragment': <lcatools.foreground.fragment_flows.LcFragment at 0x7fbfcc92b860>,
 'is_conserved': False,
 'magnitude': 0.0121378329004437,
 'node_weight': 0.0121378329004437,
 'term': <lcatools.foreground.fragment_flows.FlowTermination at 0x7fbfc9cdfa90>}

In [156]:
F.elementary(ffs[0].term.term_node)


Elementary exchanges:
Output:     [0.000138 [kg]] Carbon dioxide, fossil  [air, unspecified]
Output:     [0.00457 [kg]] Methane, fossil [air, unspecified]

In [192]:
fnew = create_fragment()


(N)ew flow or (S)earch for flow? N
Enter flow name: something that requires gas transport
Enter CAS number (or none):  []: 
Choose reference quantity: 

Choice Item
====== ======================================================================
 [0]   (30) (none)
 [1]   (4) ILCD2011
 [2]   (4) ILCD2011; ReCiPe2008
  (D)  done (keep all)
------ ----------------------------------------------------------------------
Grouped by Method
Enter choice (or "None"): 0
(0, None)
(selecting only choice (none))

Select item: 

Choice Item
====== ======================================================================
 [ 0]  Area
 [ 1]  Area*time
 [ 2]  Carbon content (biogenic)
 [ 3]  Carbon content (fossil)
 [ 4]  Duration
 [ 5]  EcoSpold Quantity MJ
 [ 6]  EcoSpold Quantity kWh
 [ 7]  EcoSpold Quantity kg
 [ 8]  EcoSpold Quantity l
 [ 9]  EcoSpold Quantity m3
 [10]  EcoSpold Quantity t*km
 [11]  Energy from renewable raw materials (net cal. value)
 [12]  Energy renewable and non renewable (gross calorific value)
 [13]  Energy renewable and non renewable (net calorific value)
 [14]  Exergy
 [15]  Goods transport (mass*distance)
 [16]  Gross calorific value
 [17]  Hydrogen content (mass)
 [18]  Length
 [19]  Market value US 2000, bulk prices
 [20]  Mass
 [21]  Net calorific value
 [22]  Normal Volume
 [23]  Number of items
 [24]  Person transport
 [25]  Price
 [26]  Recycled content (mass)
 [27]  Vehicle transport
 [28]  Volume
 [29]  Water content (mass)
------ ----------------------------------------------------------------------
Enter choice (or "None"): 23
Choose compartment:
Enter comment: dummy test flow

Choice Item
====== ======================================================================
 [0]   Elementary Flows
 [1]   Intermediate Flows
  (C)  Cancel
------ ----------------------------------------------------------------------
Enter choice (or "None"): 1
subcompartments of Intermediate Flows:

Choice Item
====== ======================================================================
 [ 0]  Air Transportation
 [ 1]  Biofuels Manufacturing
 [ 2]  By-product classification: Recyclable
 [ 3]  By-product classification: Waste
 [ 4]  By-product classification: allocatable product
 [ 5]  CPC: 17100: Electrical energy
 [ 6]  CPC: 37510: Non-refractory mortars and concretes
 [ 7]  CUTOFF Flows
 [ 8]  Chemical Manufacturing
 [ 9]  Crop Production
 [10]  Deposited goods
 [11]  Ecoinvent
 [12]  Elec. Equip., Appliance, and Comp. Manufacturing
 [13]  End-of-life treatment
 [14]  Energy carriers and technologies
 [15]  Fabricated Metal Product Manufacturing
 [16]  Forestry and Logging
 [17]  ISIC rev.4 ecoinvent: 012:Growing of perennial crops
 [18]  Intermediate flow
 [19]  Materials production
 [20]  Mining (except Oil and Gas)
 [21]  Nonmetallic Mineral Product Manufacturing
 [22]  Oil and Gas Extraction
 [23]  Others
 [24]  Paper Manufacturing
 [25]  Petroleum and Coal Products Manufacturing
 [26]  Plastics and Rubber Products Manufacturing
 [27]  Primary Metal Manufacturing
 [28]  Production residues in life cycle
 [29]  Rail Transportation
 [30]  Systems
 [31]  Transit and Ground Passenger Transportation
 [32]  Transport services
 [33]  Transportation Equipment Manufacturing
 [34]  Truck Transportation
 [35]  US LCI Database
 [36]  Utilities
 [37]  Valuable substances
 [38]  Waste Management and Remediation Services
 [39]  Wastes
 [40]  Water Transportation
 [41]  Wood Product Manufacturing
 [42]  economic
 [43]  final-waste-flow
 [44]  non-material
 [45]  others
  (K)  Keep "Intermediate Flows"
------ ----------------------------------------------------------------------
Enter choice (or "None"): K
flow is (I)nput or (O)utput?O
Enter comment:  []: fragment comment
LcFragment - Name: something that requires gas transport:

In [198]:
F.terminate_to_foreground(fnew)

In [212]:
fnew2 = create_fragment(fnew)


(N)ew flow or (S)earch for flow? s

LCA Catalog with the following archives:
X [ 0] FG     : ForegroundArchive with 169 entities at pet
  [ 1] ELCD   : /data/LCI/ELCD/ELCD3.2.zip
X [ 2] LCIA   : IlcdLcia with 33957 entities at /home/b/Dropbox/data/ELCD/ELCD3.2-a.zip
  [ 3] EI-LCIA: /data/GitHub/lca-tools-datafiles/catalogs/ei_lcia.json.gz
  [ 4] EI-U   : /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_undefined_xlsx.json.gz
  [ 5] EI_A   : /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_apos_xlsx.json.gz
  [ 6] EI_Q   : /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_consequential_xlsx.json.gz
  [ 7] EI_C   : /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_cut-off_xlsx.json.gz
X [ 8] USLCI  : EcospoldV1Archive with 4896 entities at /home/b/Dropbox/data/USLCI/USLCI_Processes_ecospold1.zip
  [ 9] GaBi-P : /data/GitHub/lca-tools-datafiles/catalogs/gabi_2016_professional-database-2016.json.gz
  [10] GaBi-X : /data/GitHub/lca-tools-datafiles/catalogs/gabi_2016_all-extensions.json.gz
Search which catalog? or blank to search all loaded catalogs0
(I)ntermediate, (E)lementary, or (A)ll flows?  [aei] [I]: 
Enter flow name search string: transport
10 results; choose by compartment:

Choice Item
====== ======================================================================
 [0]   (3) Water Transportation
 [1]   (2) Truck Transportation
 [2]   (2) Utilities
 [3]   (1) (none)
 [4]   (1) CUTOFF Flows
 [5]   (1) Rail Transportation
  (D)  done (keep all)
------ ----------------------------------------------------------------------
Enter choice (or "None"): 2
(2, None)
(selecting only choice Fossil Fuel Electric Power Generation)

Select item: 

Choice Item
====== ======================================================================
 [0]   (FG) {f} Transport, pipeline, natural gas [Utilities, Fossil Fuel Electric Power Generation]
 [1]   (FG) {f} Transport, pipeline, unspecified petroleum products [Utilities, Fossil Fuel Electric Power Generation]
------ ----------------------------------------------------------------------
Enter choice (or "None"): 0
Picked: (FG) {f} Transport, pipeline, natural gas [Utilities, Fossil Fuel Electric Power Generation]
flow is (I)nput or (O)utput?I
Enter comment:  []: node weight should get scaled
LcFragment - Name: Transport, pipeline, natural gas:

In [216]:
F.draw_fragment(fnew)


-<--O   410a96e (      1) something that requires gas transport
    | -<--#   6c6ec01 (      1) Transport, pipeline, natural gas
    |     | -<---C  b984568 (  0.012) Natural gas, processed, at plant
    |     | -<---C  8b9f144 (6.7e-05) Diesel, at refinery
    |     x 
    x 

In [219]:
F.frag('b98').exchange_value(0)


Out[219]:
0.01231511476334841

In [214]:
F.frag('6c6e').terminate(F.frag('1b7'))

In [215]:
F.build_child_flows(F.frag('6c6e'))


descending
descending
descending
LcFragment - Name: Natural gas, processed, at plant:
LcFragment - Name: Diesel, at refinery:
Out[215]:
[<lcatools.foreground.fragment_flows.LcFragment at 0x7fbfc15d7400>,
 <lcatools.foreground.fragment_flows.LcFragment at 0x7fbfc14fb550>]

In [146]:
R = traversal_to_lcia(ffs)

In [147]:
lcatools.show_lcia(R)


LCIA Results
------------------------------------------------------------
9.1944e-05 ILCD2011; Eutrophication terrestrial; midpoint; Accumulated Exceedance; Seppala et al 2006, Posch et al 2008 [LCIA]
6.8058e-05 ILCD2011; Photochemical ozone formation; midpoint - human health; POCP; Van Zelm et al. (2008) [LCIA]
8.3958e-06 ILCD2011; Eutrophication marine; midpoint; N equivalents; ReCiPe [LCIA]
   0.13836 ILCD2011; Climate change; midpoint; GWP100; IPCC2007 [LCIA]
 1.612e-07 ILCD2011; Respiratory inorganics; midpoint; PM2.5eq; Rabl and Spadaro 2004-Greco et al 2007 [LCIA]
         0 ILCD2011; Land use; midpoint; SOM loss; Mila i Canals et al. (2007) [LCIA]
1.6189e-05 ILCD2011; Acidification terrestrial and freshwater; midpoint; Accumulated Exceedance; Seppälä et al. 2006, Posch et al. 2008 [LCIA]
         0 ILCD2011; Eutrophication freshwater; midpoint; P equivalents; ReCiPe [LCIA]

In [148]:
R[q.get_uuid()].show_details()


ILCD2011; Acidification terrestrial and freshwater; midpoint; Accumulated Exceedance; Seppälä et al. 2006, Posch et al. 2008 [LCIA] mol
------------------------------------------------------------
============================================================
             Total score: 0 
  0.000144 x   0.000374 =   5.39e-08 [RNA] Transport, train, diesel powered [Rail Transportation, Rail Transportation]
============================================================
             Total score: 5.38937e-08 
    0.0121 x    0.00125 =   1.51e-05 [RNA] Natural gas, combusted in industrial equipment [Utilities, Steam and Air-Conditioning Supply]
============================================================
             Total score: 1.51304e-05 
   0.00241 x   0.000417 =      1e-06 [RNA] Transport, combination truck, diesel powered [Truck Transportation, General Freight Trucking]
============================================================
             Total score: 1.00453e-06 
============================================================
             Total score: 0 
  1.62e-05 ILCD2011; Acidification terrestrial and freshwater; midpoint; Accumulated Exceedance; Seppälä et al. 2006, Posch et al. 2008 [LCIA]

In [149]:
R[q.get_uuid()].show_components()


ILCD2011; Acidification terrestrial and freshwater; midpoint; Accumulated Exceedance; Seppälä et al. 2006, Posch et al. 2008 [LCIA] mol
------------------------------------------------------------
  1.51e-05 (1b76dbd) -<- b78ac6f -<- -*    Natural gas, combusted in industrial equipment
     1e-06 ( ** ref) -<- 114c1d5 -<- -*    Transport, combination truck, diesel powered
  5.39e-08 ( ** ref) -<- e7ace8c -<- -*    Transport, train, diesel powered
         0 ( ** ref) -<- 68d264d -<- -*    Transport, combination truck, average fuel mix
         0 ( ** ref) -<- 1b76dbd -<- -*    Transport, pipeline, natural gas
==========
  1.62e-05 ILCD2011; Acidification terrestrial and freshwater; midpoint; Accumulated Exceedance; Seppälä et al. 2006, Posch et al. 2008 [LCIA]

In [116]:
str(q)


Out[116]:
'ILCD2011; Acidification terrestrial and freshwater; midpoint; Accumulated Exceedance; Seppälä et al. 2006, Posch et al. 2008 [LCIA]'

In [119]:
F.draw_fragment(F.frag('1b7'))


-<--*   1b76dbd (      1) Transport, pipeline, natural gas
    | -<--*   b78ac6f (  0.012) Natural gas, combusted in industrial equipment
    |     | -<----: 9ca8b7d (    1.2) Transport, pipeline, natural gas
    |     | -<--#   78a3212 (    0.2) Transport, combination truck, average fuel mix
    |     | -<--#   dc450e8 (  0.012) Transport, train, diesel powered
    |     | -<---C  e038531 (      1) Natural gas, processed, at plant
    |     x 
    x 

In [140]:
R[q.get_uuid()].show_components()


ILCD2011; Acidification terrestrial and freshwater; midpoint; Accumulated Exceedance; Seppälä et al. 2006, Posch et al. 2008 [LCIA] mol
------------------------------------------------------------
  1.51e-05 (1b76dbd) -<- b78ac6f -<- -*    Natural gas, combusted in industrial equipment
     1e-06 ( ** ref) -<- 114c1d5 -<- -*    Transport, combination truck, diesel powered
  5.39e-08 ( ** ref) -<- e7ace8c -<- -*    Transport, train, diesel powered
         0 ( ** ref) -<- 68d264d -<- -*    Transport, combination truck, average fuel mix
         0 ( ** ref) -<- 1b76dbd -<- -*    Transport, pipeline, natural gas
==========
  1.62e-05 ILCD2011; Acidification terrestrial and freshwater; midpoint; Accumulated Exceedance; Seppälä et al. 2006, Posch et al. 2008 [LCIA]

In [120]:
F.draw_fragment(F.frag('68d'))


-<--*   68d264d (      1) Transport, combination truck, average fuel mix
    | -<--#   cf3ed88 (      1) Transport, combination truck, diesel powered
    x 

In [136]:
R = F.fg_lcia(F.frag('114').term.term_node)

In [137]:
R[q.get_uuid()].show_details()


ILCD2011; Acidification terrestrial and freshwater; midpoint; Accumulated Exceedance; Seppälä et al. 2006, Posch et al. 2008 [LCIA] mol
------------------------------------------------------------
  0.000532 x       0.74 =   0.000394 [GLO] Nitrogen oxides  [air, unspecified]
  1.76e-05 x       1.31 =    2.3e-05 [GLO] Sulfur oxides [air, unspecified]
============================================================
             Total score: 0.00041693 
  0.000417 ILCD2011; Acidification terrestrial and freshwater; midpoint; Accumulated Exceedance; Seppälä et al. 2006, Posch et al. 2008 [LCIA]

In [132]:
for f in F[0].fragments(show_all=True):
    f.term.clear_score_cache()

In [133]:
%time F.compute_unit_scores()


All characterizations have the same value- picking first one
All characterizations have the same value- picking first one
All characterizations have the same value- picking first one
CPU times: user 200 ms, sys: 0 ns, total: 200 ms
Wall time: 200 ms

In [134]:
F.fragment_lcia(F.frag('114'))[q.get_uuid()].show_details()


ILCD2011; Acidification terrestrial and freshwater; midpoint; Accumulated Exceedance; Seppälä et al. 2006, Posch et al. 2008 [LCIA] mol
------------------------------------------------------------
         1 x   0.000417 =   0.000417 [RNA] Transport, combination truck, diesel powered [Truck Transportation, General Freight Trucking]
============================================================
             Total score: 0.00041693 
  0.000417 ILCD2011; Acidification terrestrial and freshwater; midpoint; Accumulated Exceedance; Seppälä et al. 2006, Posch et al. 2008 [LCIA]

In [124]:
from lcatools.foreground.fragment_flows import traversal_to_lcia

In [125]:
F.show_fragments()


( ** ref) -<- d002717 -<- -*    Acetic acid, at plant
( ** ref) -<- cd48c3a -<- -*    Transport, barge, diesel powered
( ** ref) -<- e7ace8c -<- -*    Transport, train, diesel powered
( ** ref) -<- 2c8ba87 -<- -*    Transport, barge, average fuel mix
( ** ref) -<- 114c1d5 -<- -*    Transport, combination truck, diesel powered
( ** ref) -<- 0a4588e -<- -*    Transport, barge, residual fuel oil powered
( ** ref) -<- 1b76dbd -<- -*    Transport, pipeline, natural gas
( ** ref) -<- 68d264d -<- -*    Transport, combination truck, average fuel mix
( ** ref) -<- f2118f0 -<- -*    Transport, pipeline, unspecified petroleum products
( ** ref) -<- 0c44dc5 -<- -*    Polyethylene terephthalate, resin, at plant
((B) ref) -<- 5dfdb2f -<- ---:  Bituminous coal, at mine
((B) ref) -<- 0f4d896 -<- ---:  CUTOFF Transport, pipeline, coal slurry
((B) ref) -<- a8a990e -<- ---:  CUTOFF Disposal, solid waste, unspecified, to unspecified treatment
((B) ref) -<- 6f3a5da -<- ---:  CUTOFF Disposal, solid waste, unspecified, to waste-to-energy
((B) ref) -<- 0435524 -<- ---:  Electricity, at cogen, for natural gas turbine
((B) ref) =>= 5d4787c =>= ---:  Recovered energy, at acetic acid production
((B) ref) =>= 4241562 =>= ---:  Recovered energy
((B) ref) -<- 3976649 -<- ---:  CUTOFF Disposal, solid waste, unspecified, to sanitary landfill
((B) ref) -<- e436896 -<- ---:  Diesel, at refinery
((B) ref) -<- 86c34c7 -<- ---:  Electricity, at grid, US, 2000
((B) ref) -<- 4d264ea -<- ---:  Residual fuel oil, at refinery
((B) ref) -<- f892bf8 -<- ---:  Methanol, at plant
((B) ref) -<- 8430bad -<- ---:  Electricity, at grid, US, 2008
((B) ref) -<- 7b2c550 -<- ---:  CUTOFF Disposal, ash and flue gas desulfurization sludge, to unspecified reuse
((B) ref) -<- a628321 -<- ---:  CUTOFF Disposal, solid waste, unspecified, to municipal incineration
((B) ref) -<- 278d2e1 -<- ---:  Natural gas, processed, at plant

In [94]:
[str(x) for x in ffs]


Out[94]:
['4b85d4b   6.56e-05 [ Input] --: Diesel, at refinery',
 '9ca8b7d     0.0144 [ Input] --: Transport, pipeline, natural gas',
 'e038531     0.0121 [ Input] --: Natural gas, processed, at plant',
 '0183c1a   9.33e-07 [ Input] --: Diesel, at refinery']

In [109]:
['%6.3g %s %s' % (z.value, z.direction, z.flow) for z in ios]


Out[109]:
['0.0123 Input Natural gas, processed, at plant [Chemical Manufacturing, Petrochemical Manufacturing]',
 '6.75e-05 Input Diesel, at refinery [Petroleum and Coal Products Manufacturing, Petroleum Refineries]']

In [217]:
(6.56e-5 + 9.33e-7) / (1 - 0)


Out[217]:
6.6533e-05

In [105]:
ios[1].value


Out[105]:
6.749702035026239e-05

In [ ]:
f.

In [53]:
F.find_flowable('Nitrogen oxides     '.strip())


Out[53]:
{16}

In [47]:
fb


Out[47]:
set()

In [41]:
cm = F.db.find_matching_compartment(['Emissions to air'])

In [22]:
F.draw_fragment(F.frag('0c4'))


-<--*   0c44dc5 (      1) Polyethylene terephthalate, resin, at plant
    | -<----: db326b6 (   0.32) CUTOFF Ethylene glycol, at plant
    | -<----: 123d445 (   0.52) Paraxylene, at plant
    | -<--#   7771ba3 (    1.6) Transport, train, diesel powered
    | -<--*   a95908c (  0.019) Bituminous coal, combusted in industrial boiler
    |     | -<--#   c1f3eea (      1) Transport, train, diesel powered
    |     | -<--#   7dde672 ( 0.0068) Transport, combination truck, diesel powered
    |     | -<--#   f578071 (   0.13) Transport, barge, average fuel mix
    |     | -<---C  630f118 (      1) Bituminous coal, at mine
    |     | -<---C  2728068 (  0.079) CUTOFF Disposal, ash and flue gas desulfurization sludge, to unspecified reuse
    |     | -<---C  a4252ab (  0.005) CUTOFF Transport, pipeline, coal slurry
    |     | -<---C  c4b018b (  0.062) CUTOFF Disposal, solid waste, unspecified, to unspecified treatment
    |     x 
    | -<--*   4f772f2 (  0.027) Residual fuel oil, combusted in industrial boiler
    |     | -<--#   d4536a2 (  0.028) Transport, barge, average fuel mix
    |     | -<--#   c832f48 ( 0.0052) Transport, combination truck, average fuel mix
    |     | -<--#   1873c01 ( 0.0034) Transport, train, diesel powered
    |     | -<---C  86eb696 (      1) Residual fuel oil, at refinery
    |     | -<---C  81a875c ( 0.0013) CUTOFF Disposal, solid waste, unspecified, to unspecified treatment
    |     x 
    | -<--#   36b17af ( 0.0022) Transport, barge, residual fuel oil powered
    | -<--#   50beed1 (8.8e-05) Transport, pipeline, natural gas
    | -<--*   1a7d38d (  0.098) Natural gas, combusted in industrial boiler
    |     | -<--#   1d85d49 (  0.012) Transport, train, diesel powered
    |     | -<--#   27b9787 (    0.2) Transport, combination truck, average fuel mix
    |     | -<--#   5bda1ea (    1.2) Transport, pipeline, natural gas
    |     | -<---C  407ec33 (      1) Natural gas, processed, at plant
    |     x 
    | -<--#   86f05aa (  0.037) Acetic acid, at plant
    | -<--#   53861ab (0.00065) Transport, barge, diesel powered
    | -<--*   4083ab8 (  0.013) Diesel, combusted in industrial equipment
    |     | -<--#   ddf78b9 (  0.041) Transport, pipeline, unspecified petroleum products
    |     | -<--#   1ae7eb5 (  0.028) Transport, barge, average fuel mix
    |     | -<--#   56123b5 ( 0.0034) Transport, train, diesel powered
    |     | -<--#   e3c3da0 ( 0.0052) Transport, combination truck, average fuel mix
    |     | -<---C  3f09d7c (      1) Diesel, at refinery
    |     x 
    | -<---C  89562e6 ( 0.0042) CUTOFF Disposal, solid waste, unspecified, to sanitary landfill
    | -<---C  f934eef (   0.56) Electricity, at grid, US, 2008
    | -<---C  5905f9f (0.00059) CUTOFF Disposal, solid waste, unspecified, to waste-to-energy
    | -<---C  01777cb (0.00031) CUTOFF Disposal, solid waste, unspecified, to municipal incineration
    | -<---C  edabcb8 (  0.051) Electricity, at cogen, for natural gas turbine
    | -<---C  8ae77e8 (  0.035) Methanol, at plant
    | =>=--C  ab205ec (   0.14) Recovered energy
    x 

In [21]:
lcatools.show_lcia(F.frag('0c4').term._score_cache)


LCIA Results
------------------------------------------------------------
         0 ILCD2011; Eutrophication freshwater; midpoint; P equivalents; ReCiPe [LCIA]
         0 ILCD2011; Climate change; midpoint; GWP100; IPCC2007 [LCIA]
         0 ILCD2011; Respiratory inorganics; midpoint; PM2.5eq; Rabl and Spadaro 2004-Greco et al 2007 [LCIA]
         0 ILCD2011; Eutrophication marine; midpoint; N equivalents; ReCiPe [LCIA]
         0 ILCD2011; Eutrophication terrestrial; midpoint; Accumulated Exceedance; Seppala et al 2006, Posch et al 2008 [LCIA]
         0 ILCD2011; Acidification terrestrial and freshwater; midpoint; Accumulated Exceedance; Seppälä et al. 2006, Posch et al. 2008 [LCIA]
         0 ILCD2011; Land use; midpoint; SOM loss; Mila i Canals et al. (2007) [LCIA]
         0 ILCD2011; Photochemical ozone formation; midpoint - human health; POCP; Van Zelm et al. (2008) [LCIA]

In [55]:
foreground(F.frag('d00'))


(selecting only choice)
Picked: (USLCI) Acetic acid, at plant [Chemical Manufacturing, All Other Basic Organic Chemical Manufacturing] <- Acetic acid, at plant [RNA]
found termination in foreground
LcFragment - Name: Methanol, at plant:
found termination in foreground
LcFragment - Name: Electricity, at cogen, for natural gas turbine:
LcFragment - Name: Electricity, at grid, US, 2000:
BG: ((B) ref) -<- 86c34c7 -<- ---:  Electricity, at grid, US, 2000
created null termination in background
found termination in foreground
found termination in foreground
found termination in foreground
LcFragment - Name: Natural gas, combusted in industrial boiler:
BG: ((B) ref) -<- 0ac9934 -<- ---:  Natural gas, combusted in industrial boiler
created null termination in background
found termination in foreground
LcFragment - Name: Natural gas, processed, at plant:
LcFragment - Name: CUTOFF Disposal, solid waste, unspecified, to sanitary landfill:
LcFragment - Name: Recovered energy, at acetic acid production:
BG: ((B) ref) =>= 5d4787c =>= ---:  Recovered energy, at acetic acid production
created null termination in background

In [51]:
F.frag('db3').terminate(None)

In [92]:
F.save()


Saving foreground
Catalog file with 11 archives saved to foreground

In [61]:
for f in F[0].fragments(background=False, show_all=True, match='combus'):
     if not f.term.is_null:
        if f.term.is_bg:
            foreground(f)
            # print('%s' % f)


(selecting only choice)
Picked: (USLCI) Natural gas, combusted in industrial boiler [Utilities, Steam and Air-Conditioning Supply] <- Natural gas, combusted in industrial boiler [RNA]
found termination in foreground
found termination in foreground
found termination in foreground
LcFragment - Name: Natural gas, processed, at plant:

In [73]:
del_orphans(F[0])


Deleting (1f65198) -<- 02514d8 -<- --C   Transport, pipeline, unspecified petroleum products
Deleting (1f65198) -<- 3962b4b -<- --C   Natural gas, processed, at plant
Deleting (47fe10f) =>= 39b326b =>= --C   Recovered energy
Deleting (1f65198) -<- 268cdea -<- -#    Transport, barge, diesel powered
Deleting (96aa479) -<- d90abba -<- ---:  Transport, pipeline, natural gas
Deleting (a38e842) -<- eb7848f -<- -#    Transport, combination truck, diesel powered
Deleting (ba3ce83) -<- 32dd01c -<- --C   Diesel, at refinery
Deleting (96aa479) -<- e6b0be5 -<- -#    Transport, combination truck, average fuel mix
Deleting (47fe10f) -<- 19250a5 -<- --C   Methanol, at plant
Deleting (47fe10f) -<- 4bdce66 -<- --C   CUTOFF Disposal, solid waste, unspecified, to sanitary landfill
Deleting (47fe10f) -<- 8bb6f1e -<- --C   Electricity, at cogen, for natural gas turbine
Deleting (8ce3823) -<- 459b063 -<- --C   Diesel, at refinery
Deleting (47fe10f) -<- ee32fac -<- --C   Natural gas, combusted in industrial boiler
Deleting (47fe10f) -<- e3c292d -<- -#    Transport, barge, residual fuel oil powered
Deleting (1f65198) -<- ae8f69c -<- --C   Transport, pipeline, natural gas
Deleting (1f65198) =>= d292889 =>= --C   Recovered energy, at acetic acid production
Deleting (47fe10f) -<- 78bc20d -<- --C   Bituminous coal, combusted in industrial boiler
Deleting (1f65198) -<- 85ff3b9 -<- --C   Electricity, at cogen, for natural gas turbine
Deleting (47fe10f) -<- 3071e14 -<- --C   Residual fuel oil, combusted in industrial boiler
Deleting (96aa479) -<- 0c5ebc8 -<- --C   Natural gas, processed, at plant
Deleting (96aa479) -<- 68f3a39 -<- -#    Transport, train, diesel powered
Deleting (1f65198) -<- 0e0d80a -<- --C   Methanol, at plant
Deleting (1f65198) -<- 952477b -<- --C   Natural gas, combusted in industrial boiler
Deleting (47fe10f) -<- f91e8e2 -<- -#    Acetic acid, at plant
Deleting (c2305c1) -<- f349f94 -<- --C   Residual fuel oil, at refinery
Deleting (47fe10f) -<- 75075de -<- --C   CUTOFF Ethylene glycol, at plant
Deleting (1f65198) -<- e16b345 -<- --C   Electricity, at grid, US, 2000
Deleting (1f65198) -<- 40cad67 -<- --C   Transport, train, diesel powered
Deleting (1f65198) -<- a6cba1f -<- --C   CUTOFF Disposal, solid waste, unspecified, to sanitary landfill
Deleting (47fe10f) -<- 5dfa407 -<- -#    Transport, pipeline, natural gas
Deleting ( ** ref) -<- c2305c1 -<- -*    Transport, barge, residual fuel oil powered
Deleting (1f65198) -<- d5f5f68 -<- --C   Transport, barge, residual fuel oil powered
Deleting (47fe10f) -<- 4b63cee -<- --C   Electricity, at grid, US, 2008
Deleting (47fe10f) -<- e836d5d -<- --C   CUTOFF Disposal, solid waste, unspecified, to waste-to-energy
Deleting (47fe10f) -<- 51fbf81 -<- -#    Transport, train, diesel powered
Deleting (47fe10f) -<- 6c85cf1 -<- --C   Diesel, combusted in industrial equipment
Deleting (47fe10f) -<- 4c6646b -<- --C   Paraxylene, at plant
Deleting (613d6f8) -<- 11449f8 -<- --C   Diesel, at refinery
Deleting (47fe10f) -<- 9ed9989 -<- --C   CUTOFF Disposal, solid waste, unspecified, to municipal incineration
Deleting (1f65198) -<- c8451a5 -<- -#    Transport, combination truck, diesel powered
Deleting (47fe10f) -<- c37f647 -<- -#    Transport, barge, diesel powered
Deleting ( ** ref) -<- ba3ce83 -<- -*    Transport, train, diesel powered
Deleting (cff89df) -<- 96aa479 -<- -*    Natural gas, combusted in industrial equipment
Deleting ((B) ref) -<- c323bcb -<- ---:  CUTOFF Ethylene glycol, at plant
Deleting ((B) ref) -<- ad9ac81 -<- ---:  Diesel, combusted in industrial equipment
Deleting ((B) ref) -<- 63c2660 -<- ---:  Natural gas, combusted in industrial boiler
Deleting ((B) ref) -<- 5be0f02 -<- ---:  Transport, barge, residual fuel oil powered
Deleting ((B) ref) -<- 1b967e7 -<- ---:  Electricity, at cogen, for natural gas turbine
Deleting ((B) ref) -<- 3e0cdd6 -<- ---:  Bituminous coal, combusted in industrial boiler
Deleting ((B) ref) -<- 45b3e8f -<- ---:  Natural gas, combusted in industrial equipment
Deleting ((B) ref) -<- 5655b0d -<- ---:  Residual fuel oil, combusted in industrial boiler
Deleting ((B) ref) -<- fcf437d -<- ---:  Transport, pipeline, unspecified petroleum products
Deleting ((B) ref) -<- 0fb2f9c -<- ---:  Transport, train, diesel powered
Deleting ((B) ref) -<- e617086 -<- ---:  Transport, pipeline, natural gas
Deleting ((B) ref) -<- f0e9d0c -<- ---:  Diesel, at refinery
Deleting ((B) ref) -<- c8d012a -<- ---:  Electricity, at grid, US, 2000
Deleting ((B) ref) -<- eced367 -<- ---:  Electricity, at grid, US, 2008
Deleting ((B) ref) -<- a5673db -<- ---:  Paraxylene, at plant
Deleting ((B) ref) =>= 8989998 =>= ---:  Recovered energy
Deleting ((B) ref) -<- 3ee5876 -<- ---:  CUTOFF Disposal, solid waste, unspecified, to municipal incineration
Deleting ((B) ref) -<- 53ed502 -<- ---:  CUTOFF Disposal, solid waste, unspecified, to sanitary landfill
Deleting ((B) ref) -<- 507da31 -<- ---:  Methanol, at plant
Deleting ((B) ref) -<- 91475e3 -<- ---:  CUTOFF Disposal, solid waste, unspecified, to waste-to-energy
Deleting ((B) ref) =>= 2bb59c5 =>= ---:  Recovered energy, at acetic acid production
Deleting ((B) ref) -<- 33b62cb -<- ---:  Natural gas, processed, at plant
Deleting ((B) ref) -<- 60aa2f1 -<- ---:  Residual fuel oil, at refinery

In [69]:
del F[0]._entities[F.frag('4ec')._uuid]

In [67]:
F[0]._entities.remove(F.frag('4ec'))


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-67-94e5974e578f> in <module>()
----> 1 F[0]._entities.remove(F.frag('4ec'))

AttributeError: 'dict' object has no attribute 'remove'

In [70]:
F.show_fragments(show_all=True, background=True, match='transport')


((B) ref) -<- 5be0f02 -<- ---:  Transport, barge, residual fuel oil powered
((B) ref) -<- fcf437d -<- ---:  Transport, pipeline, unspecified petroleum products
((B) ref) -<- 0fb2f9c -<- ---:  Transport, train, diesel powered
((B) ref) -<- e617086 -<- ---:  Transport, pipeline, natural gas

In [49]:
F.frag('68f').terminate(F.frag('ba3'))

In [40]:
[str(x) for x in frag.io_flows(lambda x: F.child_flows(x), None)]


Out[40]:
['561ef05   0.000183 [ Input] --: Transport, combination truck, diesel powered',
 'e756aee     0.0201 [ Input] --: Methanol, at plant',
 '214d2bc   9.86e-05 [ Input] --: Transport, train, diesel powered',
 'ac6c85d    0.00165 [ Input] --: Transport, combination truck, average fuel mix',
 '5174ff7    0.00832 [ Input] --: Natural gas, processed, at plant',
 '071b31a    0.00986 [ Input] --: Transport, pipeline, natural gas',
 '44366ab   2.08e-05 [ Input] --: CUTOFF Disposal, solid waste, unspecified, to sanitary landfill',
 '89983cf    0.00701 [Output] --: Recovered energy, at acetic acid production',
 '62a5292     0.0164 [ Input] --: Natural gas, processed, at plant',
 '84623ff   3.23e-05 [ Input] --: Transport, pipeline, unspecified petroleum products',
 '2e320f5   0.000355 [ Input] --: Transport, barge, diesel powered',
 'a54e80a   0.000812 [ Input] --: Electricity, at grid, US, 2000',
 '3a3d3d4    0.00126 [ Input] --: Transport, barge, residual fuel oil powered',
 '05c3d96   0.000183 [ Input] --: Transport, train, diesel powered',
 '24fb181   7.63e-05 [ Input] --: Electricity, at cogen, for natural gas turbine',
 '245efd6     0.0183 [ Input] --: Transport, pipeline, natural gas',
 '2680bb5   0.000527 [ Input] --: Transport, pipeline, unspecified petroleum products',
 'c39a404     0.0128 [ Input] --: Diesel, at refinery',
 'b0d2cf0   0.000363 [ Input] --: Transport, barge, average fuel mix',
 '07baaaf    6.7e-05 [ Input] --: Transport, combination truck, average fuel mix',
 '1c40abc   4.28e-05 [ Input] --: Transport, train, diesel powered',
 '0400e42     0.0268 [ Input] --: Residual fuel oil, at refinery',
 '3bb2b4e    3.4e-05 [ Input] --: CUTOFF Disposal, solid waste, unspecified, to unspecified treatment',
 '6a2e47d   8.99e-05 [ Input] --: Transport, train, diesel powered',
 'a3d53d7    0.00014 [ Input] --: Transport, combination truck, average fuel mix',
 '854b011   0.000761 [ Input] --: Transport, barge, average fuel mix',
 '781b494   0.000128 [ Input] --: Transport, combination truck, diesel powered',
 'cfa5a46     0.0197 [ Input] --: Transport, train, diesel powered',
 '680a0b3    0.00149 [ Input] --: CUTOFF Disposal, ash and flue gas desulfurization sludge, to unspecified reuse',
 '9bacac2     0.0189 [ Input] --: Bituminous coal, at mine',
 '3fa7c95    0.00239 [ Input] --: Transport, barge, average fuel mix',
 '304d973    0.00117 [ Input] --: CUTOFF Disposal, solid waste, unspecified, to unspecified treatment',
 'b57271c   9.49e-05 [ Input] --: CUTOFF Transport, pipeline, coal slurry',
 'c0e582f     0.0352 [ Input] --: Methanol, at plant',
 '85abb79      0.558 [ Input] --: Electricity, at grid, US, 2008',
 '32d419c    0.00059 [ Input] --: CUTOFF Disposal, solid waste, unspecified, to waste-to-energy',
 '788aa97       1.61 [ Input] --: Transport, train, diesel powered',
 'c565de8      0.142 [Output] --: Recovered energy',
 '14e21f5     0.0981 [ Input] --: Natural gas, processed, at plant',
 '4386a40      0.116 [ Input] --: Transport, pipeline, natural gas',
 'cad2101     0.0195 [ Input] --: Transport, combination truck, average fuel mix',
 'b06ea0c    0.00116 [ Input] --: Transport, train, diesel powered',
 '5114e1d      0.521 [ Input] --: Paraxylene, at plant',
 '5c81a82   8.76e-05 [ Input] --: Transport, pipeline, natural gas',
 '0583417      0.322 [ Input] --: CUTOFF Ethylene glycol, at plant',
 '435cfd4   0.000655 [ Input] --: Transport, barge, diesel powered',
 'a568f2f    0.00419 [ Input] --: CUTOFF Disposal, solid waste, unspecified, to sanitary landfill',
 '40b7a6b     0.0511 [ Input] --: Electricity, at cogen, for natural gas turbine',
 'ab154b4    0.00031 [ Input] --: CUTOFF Disposal, solid waste, unspecified, to municipal incineration']

In [36]:
F.frag('b8e').reference_entity = None

In [28]:
F.fragment_to_background(F.frag('094'))


LcFragment - Name: Transport, barge, residual fuel oil powered:
BG: ((B) ref) -<- 77a4145 -<- -*    Transport, barge, residual fuel oil powered [RNA]
Out[28]:
<lcatools.foreground.fragment_flows.LcFragment at 0x7f53ffa49e48>

In [ ]:
for f in ('')

In [33]:
F.frag('ba3c')._background=False

In [36]:
F.build_child_flows(F.frag('ba3'), background_children=True)


LcFragment - Name: Diesel, at refinery:
Out[36]:
[<lcatools.foreground.fragment_flows.LcFragment at 0x7f5390f01358>]

In [31]:
auto_terminate(F.frag('ba3c'))


(selecting only choice)
Picked: (USLCI) Transport, combination truck, diesel powered [Truck Transportation, General Freight Trucking] <- Transport, combination truck, diesel powered [RNA]

In [25]:
F.frag('15f1').terminate(None)

In [29]:
foreground(F.frag('28b5'))


(selecting only choice)
Picked: (USLCI) Acetic acid, at plant [Chemical Manufacturing, All Other Basic Organic Chemical Manufacturing] <- Acetic acid, at plant [RNA]
LcFragment - Name: Transport, combination truck, diesel powered:
BG: ((B) ref) -<- ba3c424 -<- ---:  Transport, combination truck, diesel powered
LcFragment - Name: CUTOFF Disposal, solid waste, unspecified, to sanitary landfill:
LcFragment - Name: Transport, train, diesel powered:
LcFragment - Name: Natural gas, processed, at plant:
LcFragment - Name: Transport, barge, diesel powered:
LcFragment - Name: Electricity, at grid, US, 2000:
BG: ((B) ref) -<- 756d536 -<- ---:  Electricity, at grid, US, 2000
LcFragment - Name: Electricity, at cogen, for natural gas turbine:
LcFragment - Name: Transport, pipeline, unspecified petroleum products:
LcFragment - Name: Methanol, at plant:
LcFragment - Name: Natural gas, combusted in industrial boiler:
LcFragment - Name: Transport, pipeline, natural gas:
LcFragment - Name: Transport, barge, residual fuel oil powered:
LcFragment - Name: Recovered energy, at acetic acid production:
BG: ((B) ref) =>= 3df587e =>= ---:  Recovered energy, at acetic acid production

In [19]:
auto_terminate(F.frag('491'))


(selecting only choice)
Picked: (USLCI) Natural gas, combusted in industrial boiler [Utilities, Steam and Air-Conditioning Supply] <- Natural gas, combusted in industrial boiler [RNA]
LcFragment - Name: Transport, combination truck, average fuel mix:
BG: ((B) ref) -<- 949b684 -<- ---:  Transport, combination truck, average fuel mix
LcFragment - Name: Transport, pipeline, natural gas:
LcFragment - Name: Transport, train, diesel powered:
LcFragment - Name: Natural gas, processed, at plant:
BG: ((B) ref) -<- 583eea1 -<- ---:  Natural gas, processed, at plant

In [9]:
def create_quantity(self):
    name = input('Enter quantity name: ')
    unit = ifinput('Enter reference unit: ', 'kg')
    comment = ifinput('Enter comment: ', '')
    q = LcQuantity.new(name, unit, Comment=comment)
    self[0].add(q)
    return q

In [10]:
def edit_flow(self):
    flow = pick_one(self._catalog[0].flows())
    ch = cyoa('Edit (P)roperties or (C)haracterizations? ', 'pc').lower()
    if ch == 'p':
        _edit_entity(flow)
    elif ch == 'c':
        edit_characterizations(flow)


def _edit_entity(entity):
    print('Select field to edit:')
    field = menu_list(*entity.keys())
    if field == -1 or field is None:
        return True
    new = ifinput('Enter new value for %s: ' % field, flow[field])
    if len(new) > 0:
        entity[field] = new
    else:
        print('Not updating.')

def edit_characterizations(flow):
    char = pick_one(cf for cf in flow.characterizations())
    val = float(ifinput('enter new characterization value: ', char.value ))
    char.value = val

In [13]:
def pick_fragment(background=False):
    """
    self is a foreground manager
    """
    frag = pick_list([f for f in F[0].fragments(background=background)])
    print('%s' % frag)
    return frag

In [14]:
def show_info(frag):
    frag.show()
    print('Exchange Values:')
    evs = list(frag._exchange_values.keys())
    evs.remove(0)
    evs.remove(1)
    print('%20.20s: %g' % ('Cached', frag.cached_ev))
    print('%20.20s: %g' % ('Observed', frag.observed_ev))
    for k in evs:
        print('%20.20s: %g' % (k, frag.exchange_value(k)))
    if frag._balance_flow:
        print('\nBalance flow: True (%s)' % frag.flow.reference_entity)
    else:
        print('\nBalance flow: False')    

def show_terminations(frag):
    print('Terminations: ')
    print('%20s: %s' % ('Scenario', 'Termination'))
    for k, v in frag._terminations.items():
        if v.descend:
            desc = '(agg)'
        else:
            desc = '     '
        print('%20.20s: %s %s %s' % (k, v, desc, v.term_node))

In [28]:
def _pick_scenario(scs):
    sc = _pick_list(scs, 'New scenario', 'Cancel')
    if sc == (None, None):
        return None
    if sc == (None, 1):
        scen = input('Enter scenario Name: ')
    elif sc == (None, 2):
        return None
    else:
        scen = scs[sc[0]]
    if scen == '0':
        scen = 0
    return scen

def _f_add_child(frag):
    return create_fragment(frag)

def _f_info(frag):
    _edit_entity(frag)
    
def _f_exch(frag):
    action = cyoa('Set (O)bserved exchange value, (S)cenario exchange value, (B)alance? ', 'osb')
    if action == 'o':
        frag.observed_ev = float(ifinput('Enter observed exchange value: ', frag.observed_ev))
    elif action == 's':
        scs = list(frag._exchange_values.keys())
        if frag.cached_ev != 1.0:
            scs.remove(0)
        scs.remove(1)
        sc = _pick_scenario(scs)
        if sc == None:
            return
        elif sc == 0:
            cev = frag.cached_ev
        elif sc in frag._exchange_values.keys():
            cev = frag.exchange_value(sc)
        else:
            cev = 1.0
        ev = float(ifinput('Enter exchange value: ', cev))
        frag.set_exchange_value(sc, ev)
    elif action == 'b':
        if frag._balance_flow:
            frag.unset_balance_flow()
        else:
            frag.set_balance_flow()

def _f_terms(frag):
    scs = list(frag.terminations())
    sc = _pick_scenario(scs)
    term = find_termination(frag)
    if term is None:
        ch = cyoa('No terminations found. Search for termination by (P)rocess or by (F)low? ', 'pf')
        
    else:
        add_termination(frag, term, scenario=sc)

def _f_select_child(frag):
    ch = pick_list([f for f in F.child_flows(frag)])
    edit_fragment(ch)
        
def edit_fragment(frag):
    print('%s' % frag)
    F._show_frag_children(frag)
    show_info(frag)
    show_terminations(frag)
    action = {'a': _f_add_child, 'i': _f_info, 'e': _f_exch, 't': _f_terms, 's': _f_select_child, 'q': None
             }[cyoa('Choices: (A)dd child, (I)nfo, (E)xchange values, (T)erminations; (S)elect child, (Q)uit: ', 'aeitsq', 'i')]
    if action is None:
        return
    action(frag)

In [21]:
F.show_fragments(background=None)


( ** ref) -<- de6bbb6 -<- ---:  Polyethylene terephthalate, resin, at plant

In [29]:
edit_fragment(frag)


( ** ref) -<- de6bbb6 -<- -*    Polyethylene terephthalate, resin, at plant
 (de6bbb6) -<- ebfc8dd -<- ---:  Bituminous coal, combusted in industrial boiler
 (de6bbb6) -<- a138003 -<- ---:  Diesel, combusted in industrial equipment
 (de6bbb6) -<- 2f5d5a7 -<- ---:  Paraxylene, at plant
 (de6bbb6) -<- b0adf5b -<- ---:  Residual fuel oil, combusted in industrial boiler
 (de6bbb6) -<- 06bd393 -<- ---:  Electricity, at grid, US, 2008
 (de6bbb6) -<- e91a6c4 -<- ---:  CUTOFF Ethylene glycol, at plant
 (de6bbb6) -<- 1cd07b2 -<- ---:  CUTOFF Disposal, solid waste, unspecified, to sanitary landfill
 (de6bbb6) -<- 314ca25 -<- ---:  Transport, barge, residual fuel oil powered
 (de6bbb6) -<- e599048 -<- ---:  Methanol, at plant
 (de6bbb6) -<- 34e3cff -<- ---:  Transport, train, diesel powered
 (de6bbb6) -<- bf4b217 -<- ---:  Acetic acid, at plant
 (de6bbb6) -<- cf302f7 -<- ---:  Transport, barge, diesel powered
 (de6bbb6) -<- 038c03f -<- ---:  Electricity, at cogen, for natural gas turbine
 (de6bbb6) =>= 9cad754 =>= ---:  Recovered energy
 (de6bbb6) -<- c6405b9 -<- ---:  CUTOFF Disposal, solid waste, unspecified, to municipal incineration
 (de6bbb6) -<- 98a4235 -<- ---:  CUTOFF Disposal, solid waste, unspecified, to waste-to-energy
 (de6bbb6) -<- 85c992f -<- ---:  Transport, pipeline, natural gas
 (de6bbb6) -<- cd5bdc2 -<- ---:  Natural gas, combusted in industrial boiler
Fragment Entity
     Name: Polyethylene terephthalate, resin, at plant
  Comment: pet uslci
StageName: 
Exchange Values:
              Cached: 1
            Observed: 0

Balance flow: False
Terminations: 
            Scenario: Termination
                None: -*   (agg) (USLCI) {p} Polyethylene terephthalate, resin, at plant [RNA]
Choices: (A)dd child, (I)nfo, (E)xchange values, (T)erminations; (S)elect child, (Q)uit:  [aeitsq] [i]: s

Select item: 

Choice Item
====== ======================================================================
 [ 0]  (de6bbb6) -<- 038c03f -<- ---:  Electricity, at cogen, for natural gas turbine
 [ 1]  (de6bbb6) -<- 06bd393 -<- ---:  Electricity, at grid, US, 2008
 [ 2]  (de6bbb6) -<- 1cd07b2 -<- ---:  CUTOFF Disposal, solid waste, unspecified, to sanitary landfill
 [ 3]  (de6bbb6) -<- 2f5d5a7 -<- ---:  Paraxylene, at plant
 [ 4]  (de6bbb6) -<- 314ca25 -<- ---:  Transport, barge, residual fuel oil powered
 [ 5]  (de6bbb6) -<- 34e3cff -<- ---:  Transport, train, diesel powered
 [ 6]  (de6bbb6) -<- 85c992f -<- ---:  Transport, pipeline, natural gas
 [ 7]  (de6bbb6) -<- 98a4235 -<- ---:  CUTOFF Disposal, solid waste, unspecified, to waste-to-energy
 [ 8]  (de6bbb6) -<- a138003 -<- ---:  Diesel, combusted in industrial equipment
 [ 9]  (de6bbb6) -<- b0adf5b -<- ---:  Residual fuel oil, combusted in industrial boiler
 [10]  (de6bbb6) -<- bf4b217 -<- ---:  Acetic acid, at plant
 [11]  (de6bbb6) -<- c6405b9 -<- ---:  CUTOFF Disposal, solid waste, unspecified, to municipal incineration
 [12]  (de6bbb6) -<- cd5bdc2 -<- ---:  Natural gas, combusted in industrial boiler
 [13]  (de6bbb6) -<- cf302f7 -<- ---:  Transport, barge, diesel powered
 [14]  (de6bbb6) -<- e599048 -<- ---:  Methanol, at plant
 [15]  (de6bbb6) -<- e91a6c4 -<- ---:  CUTOFF Ethylene glycol, at plant
 [16]  (de6bbb6) -<- ebfc8dd -<- ---:  Bituminous coal, combusted in industrial boiler
 [17]  (de6bbb6) =>= 9cad754 =>= ---:  Recovered energy
------ ----------------------------------------------------------------------
Enter choice (or "None"): 15
(de6bbb6) -<- e91a6c4 -<- ---:  CUTOFF Ethylene glycol, at plant
Fragment Entity
     Name: CUTOFF Ethylene glycol, at plant
  Comment: 
StageName: 
Exchange Values:
              Cached: 0.322
            Observed: 0

Balance flow: False
Terminations: 
            Scenario: Termination
                None: ---: (agg) None
Choices: (A)dd child, (I)nfo, (E)xchange values, (T)erminations; (S)elect child, (Q)uit:  [aeitsq] [i]: T

Choice Item
====== ======================================================================
 [0]    None
  (N)  New scenario
  (C)  Cancel
------ ----------------------------------------------------------------------
Enter choice (or "None"): 0

LCA Catalog with the following archives:
X [ 0] FG     : ForegroundArchive with 68 entities at pet
  [ 1] ELCD   : /data/LCI/ELCD/ELCD3.2.zip
X [ 2] LCIA   : IlcdLcia with 1310 entities at /home/b/Dropbox/data/ELCD/ELCD3.2.zip
  [ 3] EI-LCIA: /data/GitHub/lca-tools-datafiles/catalogs/ei_lcia.json.gz
  [ 4] EI-U   : /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_undefined_xlsx.json.gz
  [ 5] EI_A   : /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_apos_xlsx.json.gz
  [ 6] EI_Q   : /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_consequential_xlsx.json.gz
  [ 7] EI_C   : /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_cut-off_xlsx.json.gz
X [ 8] USLCI  : EcospoldV1Archive with 4896 entities at /home/b/Dropbox/data/USLCI/USLCI_Processes_ecospold1.zip
  [ 9] GaBi-P : /data/GitHub/lca-tools-datafiles/catalogs/gabi_2016_professional-database-2016.json.gz
  [10] GaBi-X : /data/GitHub/lca-tools-datafiles/catalogs/gabi_2016_all-extensions.json.gz
Search which catalog? or blank to search all loaded catalogs8
No entities.
Picked: None

In [72]:
frag.term.__dict__


Out[72]:
{'_cached_ev': 1.0,
 '_descend': True,
 '_parent': <lcatools.foreground.fragment_flows.LcFragment at 0x7feb09e84588>,
 '_process_ref': None,
 '_score_cache': {},
 'direction': 'Output',
 'term_flow': None}

In [64]:
frbc = F.frag('ebfc')

In [66]:
help(del)


  File "<ipython-input-66-0bb27ba05bc1>", line 1
    help(del)
           ^
SyntaxError: invalid syntax

In [63]:
F.draw_fragment(frag)


-<--*   de6bbb6 (      1) Polyethylene terephthalate, resin, at plant
    | -<----: b0adf5b (  0.027) Residual fuel oil, combusted in industrial boiler
    | -<----: 06bd393 (   0.56) Electricity, at grid, US, 2008
    | -<----: e91a6c4 (   0.32) CUTOFF Ethylene glycol, at plant
    | -<----: 1cd07b2 ( 0.0042) CUTOFF Disposal, solid waste, unspecified, to sanitary landfill
    | -<----: 314ca25 ( 0.0022) Transport, barge, residual fuel oil powered
    | -<----: 34e3cff (    1.6) Transport, train, diesel powered
    | -<----: cf302f7 (0.00065) Transport, barge, diesel powered
    | -<----: 98a4235 (0.00059) CUTOFF Disposal, solid waste, unspecified, to waste-to-energy
    | -<----: bf4b217 (  0.037) Acetic acid, at plant
    | -<----: 85c992f (8.8e-05) Transport, pipeline, natural gas
    | -<----: 038c03f (  0.051) Electricity, at cogen, for natural gas turbine
    | =>=---: 9cad754 (   0.14) Recovered energy
    | -<----: c6405b9 (0.00031) CUTOFF Disposal, solid waste, unspecified, to municipal incineration
    | -<--*   ebfc8dd (  0.019) Bituminous coal, combusted in industrial boiler
    |     | -<----: ef8d254 (  0.005) CUTOFF Transport, pipeline, coal slurry
    |     | -<----: d6cc8fe (  0.062) CUTOFF Disposal, solid waste, unspecified, to unspecified treatment
    |     | -<----: 9eca840 (      1) Bituminous coal, at mine
    |     | -<----: 48f353c (  0.079) CUTOFF Disposal, ash and flue gas desulfurization sludge, to unspecified reuse
    |     | -<--*   219c395 ( 0.0068) Transport, combination truck, diesel powered
    |     |     | -<----: 89d095a (  0.027) Diesel, at refinery
    |     |     x 
    |     | -<--*   17b733a (      1) Transport, train, diesel powered
    |     |     | -<----: 8758f08 ( 0.0065) Diesel, at refinery
    |     |     x 
    |     | -<--*   0789399 (   0.13) Transport, barge, average fuel mix
    |     |     | -<--*   3a0f450 (   0.78) Transport, barge, residual fuel oil powered
    |     |     |     | -<----: a7e9f36 ( 0.0088) Residual fuel oil, at refinery
    |     |     |     x 
    |     |     | -<--*   daa5679 (   0.22) Transport, barge, diesel powered
    |     |     |     | -<----: 773bc27 ( 0.0096) Diesel, at refinery
    |     |     |     x 
    |     |     x 
    |     x 
    | -<--*   a138003 (  0.013) Diesel, combusted in industrial equipment
    |     | -<----: 2f09b50 (  0.028) Transport, barge, average fuel mix
    |     | -<----: ac857de (  0.041) Transport, pipeline, unspecified petroleum products
    |     | -<----: 33ba7ea (      1) Diesel, at refinery
    |     | -<----: 4c60692 ( 0.0034) Transport, train, diesel powered
    |     | -<----: bb4d169 ( 0.0052) Transport, combination truck, average fuel mix
    |     x 
    | -<--*   2f5d5a7 (   0.52) Paraxylene, at plant
    |     | -<----: 334a292 (   0.13) Electricity, at grid, US, 2000
    |     | -<----: b3afd31 (  0.026) Bituminous coal, combusted in industrial boiler
    |     | -<----: e23cad3 (   0.15) Natural gas, combusted in industrial boiler
    |     | -<----: 6511778 (      1) Xylenes, mixed, at plant
    |     | -<----: 111c50b ( 0.0076) Liquefied petroleum gas, combusted in industrial boiler
    |     x 
    | -<--*   e599048 (  0.035) Methanol, at plant
    |     | -<----: 4eafaca (   0.01) Transport, train, diesel powered
    |     | -<----: 682ed53 (  0.008) Electricity, at grid, US, 2008
    |     | -<----: d6e0e2f (   0.01) Transport, combination truck, diesel powered
    |     | -<----: 0c0fbd5 (   0.62) Natural gas, processed, for olefins production, at plant
    |     | -<----: f1b900e (      1) Transport, pipeline, natural gas
    |     | -<----: ae6706e ( 0.0005) CUTOFF Disposal, solid waste, unspecified, to sanitary landfill
    |     | -<----: 99ca398 (   0.13) Natural gas, combusted in industrial boiler
    |     x 
    | -<--*   cd5bdc2 (  0.098) Natural gas, combusted in industrial boiler
    |     | -<----: 6cf8470 (  0.012) Transport, train, diesel powered
    |     | -<----: d363f9d (    1.2) Transport, pipeline, natural gas
    |     | -<--*   cec9fc4 (    0.2) Transport, combination truck, average fuel mix
    |     |     | -<----: 0270a6a (      1) Transport, combination truck, diesel powered
    |     |     x 
    |     | -<--*   9d8e3a4 (      1) Natural gas, processed, at plant
    |     |     | -<----: 4de21a0 (   0.74) Natural gas, extracted
    |     |     | -<----: 4b180c5 (  0.025) Natural gas, combusted in industrial boiler
    |     |     | -<----: 1688a4b (3.7e-05) Residual fuel oil, combusted in industrial boiler
    |     |     | -<----: 2e87523 (  0.016) Electricity, at grid, US, 2008
    |     |     | -<----: e39eb94 (3.5e-05) Gasoline, combusted in equipment
    |     |     | -<----: 895fcfd (3.7e-05) Diesel, combusted in industrial equipment
    |     |     x 
    |     x 
    x 

In [58]:
auto_terminate(F.frag('2f5d'), index=8)


(selecting only choice)
Picked: (USLCI) Paraxylene, at plant [Chemical Manufacturing, Petrochemical Manufacturing] <- Paraxylene, at plant [RNA]

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [48]:
str(flow_ref)


Out[48]:
'(USLCI) {f} Ethylene glycol, at plant  [Chemical Manufacturing, Petrochemical Manufacturing]'

In [51]:
x = find_termination(flow_ref, direction)


(selecting only choice)
Picked: (USLCI) Ethylene glycol, at plant  [Chemical Manufacturing, Petrochemical Manufacturing] <- Ethylene glycol, at plant  [RNA]

In [40]:
str(x.exchange)


Out[40]:
'Output: {*} [1 [kg]] Polyethylene terephthalate, resin, at plant [Chemical Manufacturing, Petrochemical Manufacturing]'