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

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

import lcatools
from lcatools.foreground.manager import ForegroundManager

In [2]:
F = ForegroundManager('foreground')


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.81 s)
Fragments loaded... (0.81 s)
finished... (0.81 s)

In [3]:
F.show_fragments(show_all=True)

In [4]:
F.show_all()


LCA Catalog with the following archives:
X [ 0] FG     : ForegroundArchive with 24 entities at foreground
  [ 1] ELCD   : /data/LCI/ELCD/ELCD3.2.zip
  [ 2] LCIA   : /data/GitHub/lca-tools-datafiles/catalogs/elcd_lcia.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
  [ 8] USLCI  : /data/GitHub/lca-tools-datafiles/catalogs/uslci_ecospold.json.gz
  [ 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]:
F.load_lcia_cfs(3)


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

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


In [6]:
F.add_archive('/data/GitHub/lca-tools-datafiles/catalogs/elcd_lcia_all.json.gz', 'LCIA_ALL', 'json')


json archive added in position 11

In [7]:
F.load_lcia_cfs(11)


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


In [8]:
F.show_all()


LCA Catalog with the following archives:
X [ 0] FG      : ForegroundArchive with 24 entities at foreground
  [ 1] ELCD    : /data/LCI/ELCD/ELCD3.2.zip
  [ 2] LCIA    : /data/GitHub/lca-tools-datafiles/catalogs/elcd_lcia.json.gz
X [ 3] EI-LCIA : EcoinventLcia with 3965 entities at /data/LCI/LCIA implementation v3.1 2014_08_13.xlsx
  [ 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
  [ 8] USLCI   : /data/GitHub/lca-tools-datafiles/catalogs/uslci_ecospold.json.gz
  [ 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
X [11] LCIA_ALL: IlcdLcia with 33957 entities at /home/b/Dropbox/data/ELCD/ELCD3.2-a.zip

In [9]:
F.load('EI_A')


Loading JSON data from /data/GitHub/lca-tools-datafiles/catalogs/ecoinvent_3.2_apos_xlsx.json.gz:
Loading FG from /data/LCI/Ecoinvent/3.2/current_Version_3.2_apos_ecoSpold02.zip
Found Extension: zip
Loading BG from /data/LCI/Ecoinvent/3.2/current_Version_3.2_apos_lcia_ecoSpold02.zip
Found Extension: zip
Loading LCI from /data/LCI/Ecoinvent/3.2/current_Version_3.2_apos_lci_ecoSpold02.7z
Found Extension: 7z
**Upstream reference encountered: /home/b/Dropbox/data/Ecoinvent/3.2/activity_overview_for_users_3.2_undefined.xlsx

11420 new process entities added (11420 total)
6767 new flow entities added (6767 total)
718 new quantity entities added (718 total)

In [10]:
_ei_q = (F._catalog.ref(3, q) for q in F[3].lcia_methods())
_el_q = (F._catalog.ref(11, q) for q in F[11].lcia_methods())

In [11]:
_eia_p = (F._catalog.ref('EI_A', p) for p in F['EI_A'].processes())

In [16]:
p = next(_eia_p)
str(p)


Out[16]:
'(EI_A) {p} electricity production, natural gas, conventional power plant [CN-SX]'

In [17]:
F.elementary(p)


FG: electricity production, natural gas, conventional power plant [CN-SX]
Elementary exchanges:
 Input:     [0.0709 [m3]] Water, cooling, unspecified natural origin (CAS 007732-18-5) [natural resource, in water]
Output:     [1.17e-05 [kg]] Methane, fossil (CAS 000074-82-8) [air, non-urban air or from high stacks]
Output:     [3.44e-09 [kg]] Chromium (CAS 007440-47-3) [air, non-urban air or from high stacks]
Output:     [0.00024 [kg]] Carbon monoxide, fossil (CAS 000630-08-0) [air, non-urban air or from high stacks]
Output:     [6.86e-06 [kg]] Sulfur dioxide (CAS 007446-09-5) [air, non-urban air or from high stacks]
Output:     [3.88e-07 [kg]] Formaldehyde (CAS 000050-00-0) [air, non-urban air or from high stacks]
Output:     [1.24e-09 [kg]] Lead (CAS 007439-92-1) [air, non-urban air or from high stacks]
Output:     [0.00118 [m3]] Water (CAS 007732-18-5) [air, unspecified]
Output:     [9.6e-09 [kg]] Acetaldehyde (CAS 000075-07-0) [air, non-urban air or from high stacks]
Output:     [5.17e-09 [kg]] Nickel (CAS 007440-02-0) [air, non-urban air or from high stacks]
Output:     [4.93e-10 [kg]] Arsenic (CAS 007440-38-2) [air, non-urban air or from high stacks]
Output:     [9.37e-10 [kg]] Manganese (CAS 007439-96-5) [air, non-urban air or from high stacks]
Output:     [1.92e-07 [kg]] Propionic acid (CAS 000079-09-4) [air, non-urban air or from high stacks]
Output:     [5.89e-11 [kg]] Selenium (CAS 007782-49-2) [air, non-urban air or from high stacks]
Output:     [1.64e-05 [kg]] Ethane (CAS 000074-84-0) [air, non-urban air or from high stacks]
Output:     [8.46e-06 [kg]] Propane (CAS 000074-98-6) [air, non-urban air or from high stacks]
Output:     [1.11e-05 [kg]] Butane (CAS 000106-97-8) [air, non-urban air or from high stacks]
Output:     [0.00044 [kg]] Nitrogen oxides (CAS 011104-93-1) [air, non-urban air or from high stacks]
Output:     [1.45e-06 [kg]] Acetic acid (CAS 000064-19-7) [air, non-urban air or from high stacks]
Output:     [2.06e-10 [kg]] Cobalt (CAS 007440-48-4) [air, non-urban air or from high stacks]
Output:     [1.17e-05 [kg]] Dinitrogen monoxide (CAS 010024-97-2) [air, non-urban air or from high stacks]
Output:     [2.71e-09 [kg]] Cadmium (CAS 007440-43-9) [air, non-urban air or from high stacks]
Output:     [8.26e-10 [kg]] Mercury (CAS 007439-97-6) [air, non-urban air or from high stacks]
Output:     [1.08e-08 [kg]] Benzene (CAS 000071-43-2) [air, non-urban air or from high stacks]
Output:     [0.641 [kg]] Carbon dioxide, fossil (CAS 000124-38-9) [air, non-urban air or from high stacks]
Output:     [6.35e-12 [kg]] Benzo(a)pyrene (CAS 000050-32-8) [air, non-urban air or from high stacks]
Output:     [2.96e-11 [kg]] Beryllium (CAS 007440-41-7) [air, non-urban air or from high stacks]
Output:     [9.6e-08 [kg]] PAH, polycyclic aromatic hydrocarbons (CAS 130498-29-2) [air, non-urban air or from high stacks]
Output:     [1.38e-05 [kg]] Pentane (CAS 000109-66-0) [air, non-urban air or from high stacks]
Output:     [0.0722 [m3]] Water (CAS 007732-18-5) [water, unspecified]
Output:     [5.89e-06 [kg]] Particulates, < 2.5 um [air, non-urban air or from high stacks]
Output:     [9.52e-12 [kg]] Acenaphthene (CAS 000083-32-9) [air, non-urban air or from high stacks]
Output:     [9.52e-06 [kg]] Hexane (CAS 000110-54-3) [air, non-urban air or from high stacks]
Output:     [1.8e-08 [kg]] Toluene (CAS 000108-88-3) [air, non-urban air or from high stacks]

In [28]:
q = next(_ei_q)
str(q)


Out[28]:
'(EI-LCIA) {q} IMPACT 2002+ (Endpoint), human health, respiratory effects (inorganics) [LCIA]'

In [29]:
F.add_to_foreground(q)


Add to foreground: (EI-LCIA) {q} IMPACT 2002+ (Endpoint), human health, respiratory effects (inorganics) [LCIA]

In [30]:
from lcatools.lcia_results import show_lcia

In [31]:
show_lcia(F.fg_lcia(p))


FG: electricity production, natural gas, conventional power plant [CN-SX]
All characterizations have the same value- picking first one
LCIA Results
------------------------------------------------------------
0.00025349 ReCiPe Midpoint (H) w/o LT, terrestrial acidification w/o LT, TAP100 w/o LT [LCIA]
0.00048217 ReCiPe Midpoint (H), photochemical oxidant formation, POFP [LCIA]
 6.185e-06 IMPACT 2002+ (Endpoint), human health, respiratory effects (inorganics) [LCIA]

In [32]:
show_lcia(F.bg_lcia(p))


Loading LCIA results from ab0e6c29-9543-4ea0-99b9-d7c05f204ad3_66c93e71-f32b-4591-901c-55395db5c132.spold
LCIA Results
------------------------------------------------------------
 0.0019544 ReCiPe Midpoint (H) w/o LT, terrestrial acidification w/o LT, TAP100 w/o LT [LCIA]
 0.0010246 ReCiPe Midpoint (H), photochemical oxidant formation, POFP [LCIA]
2.2442e-05 IMPACT 2002+ (Endpoint), human health, respiratory effects (inorganics) [LCIA]

In [33]:
show_lcia(F[p.index].lci_proxy(p.id).lcias([q for q in F[0].lcia_methods()], flowdb=F._flowdb))


Performing LCI lookup -- this is slow because of 7z
retrieving ab0e6c29-9543-4ea0-99b9-d7c05f204ad3_66c93e71-f32b-4591-901c-55395db5c132.spold
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
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
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
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
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
All characterizations have the same value- picking first one
LCIA Results
------------------------------------------------------------
 0.0019544 ReCiPe Midpoint (H) w/o LT, terrestrial acidification w/o LT, TAP100 w/o LT [LCIA]
 0.0010246 ReCiPe Midpoint (H), photochemical oxidant formation, POFP [LCIA]
2.2442e-05 IMPACT 2002+ (Endpoint), human health, respiratory effects (inorganics) [LCIA]