Skip to article frontmatterSkip to article content

Creating a Library

Purpose

This SOP documents procedures for creating libraries from Federal LCA Commons (FLCAC) repositories in openLCA. Please reference the openLCA Libraries User Guide for information on importing, exporting, and modeling with libraries. This SOP is inteded for use by the Data Curators.

Procedure

1. Prepare the library database

Python script to remove zero amounts from exchanges

To use this script in openLCA, select “Tools” --> “Developer Tools” --> “Python”.

from java.util import ArrayList
pDao = ProcessDao(db)
for d in pDao.getDescriptors():
  p = pDao.getForId(d.id)
  toRemove = ArrayList()
  for e in p.exchanges:
    if e.amount == 0 and e.id == p.quantitativeReference.id:
      log.info("Invalid: quantitative reference has zero amount in process " + p.name + " " + p.refId)
      continue
    if e.amount == 0 and e.isInput and e.flow.flowType == FlowType.WASTE_FLOW:
      log.info("Removing zero amount waste input " + e.flow.name + " from process " + p.name + " " + p.refId)
      toRemove.add(e)
    if e.amount == 0 and not e.isInput and e.flow.flowType == FlowType.PRODUCT_FLOW:
      log.info("Removing zero amount product output " + e.flow.name + " from process " + p.name + " " + p.refId)
      toRemove.add(e)
  log.info("toRemove.size(): " + str(toRemove.size()))
  if not toRemove.isEmpty():
    for e in toRemove:
      p.exchanges.remove(e)
    pDao.update(p)

2. Transform the library database into a library element