Skip to main content

No project description provided

Project description

background

Background LCI implementation including Tarjan Ordering.

This is kept as a separate repo because it is the only place numpy/scipy is required. The idea is to enable people to run LCI/A computations without having the background data on their machine or having to perform matrix construction and inversion (i.e. only using foreground computations, like GaBi does).

Partial Ordering

The default implementation performs an ordering of the LCI database using Tarjan's algorithm for detecting strongly-connected components (see Partial Ordering of Life Cycle Inventory Databases)

It performs the ordering, and then builds and stores a static LCI database (A and B matrices).
This code is a bit convoluted, but it works.

(Muttered question from the audience)

No, it isn't tested. Tests have been performed (and passed).

(indistinct grumbling)

I know. I'm sorry.

Installing

Installation should be straightforward-- lxml is required here to access a local copy of ecoinvent.

user@host$ pip install antelope_background lxml

Setting up a catalog with ecoinvent data

>>> from antelope_core import LcCatalog
>>> from antelope_core.data_sources.ecoinvent import EcoinventConfig
>>> cat = LcCatalog('/home/user/my_catalog')
Loading JSON data from /home/b/my_catalog/reference-quantities.json:
local.qdb: /home/b/my_catalog/reference-quantities.json
local.qdb: /data/GitHub/lca-tools/lcatools/qdb/data/elcd_reference_quantities.json
25 new quantity entities added (25 total)
6 new flow entities added (6 total)
 
>>> ec = EcoinventConfig('/path/to/ecoinvent')
>>> for res in ec.make_resources('local.ecoinvent.3.7.1.cutoff'):
        cat.add_resource(res)
 
>>> cat.show_interfaces()
local.ecoinvent.3.7.1.cutoff [basic, exchange]
local.qdb [basic, index, quantity]
 
>>>

When the background is installed, new interface methods are available for catalog queries. In order to access them, the background matrix must be constructed, which is done through traversal of the LCI network using Tarjan's algorithm. This is triggered automatically any time you request a background interface method. But it can also be triggered explicitly:

>>> q = cat.query('local.ecoinvent.3.7.1.cutoff')
>>> q.check_bg()
... # several minutes pass 
 Loaded 17400 processes (t=158.06 s)
 Loaded 17495 processes (t=158.69 s)
20 new quantity entities added (20 total)
5333 new flow entities added (5333 total)
17495 new process entities added (17495 total)
...
Creating flat background
...
 True
 
>>> cat.show_interfaces()
local.ecoinvent.3.7.1.cutoff [basic, exchange]
local.ecoinvent.3.7.1.cutoff.index.20210205 [background, basic, index]
local.qdb [basic, index, quantity]
 
>>>

The check_bg() route is slow because it requires indexing the database and traversing all exchanges, both of which require loading all XML files. Fortunately, if the two steps are done during the same python session, then the inventory remains in memory and each file only has to be loaded once.

Once the background matrix and index are created, the XML files do not need to be individually loaded except to access details about a specific process.

Now that the background interface exists, background queries can be conducted.

Contributing

Please do!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

antelope_background-0.3.1.tar.gz (35.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

antelope_background-0.3.1-py3-none-any.whl (46.7 kB view details)

Uploaded Python 3

File details

Details for the file antelope_background-0.3.1.tar.gz.

File metadata

  • Download URL: antelope_background-0.3.1.tar.gz
  • Upload date:
  • Size: 35.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for antelope_background-0.3.1.tar.gz
Algorithm Hash digest
SHA256 b349a28d93664f3c8cd7bf000949190e3f0786ec95bb122b187a3a81a4eb71b4
MD5 1497e98c21236f51e3a55409b72043b8
BLAKE2b-256 fb9e76ba2a683fd7e6cb8b8a197d3d88a736fca284a637960e2c7c560edc6805

See more details on using hashes here.

File details

Details for the file antelope_background-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for antelope_background-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c8f22d315cf3c3a36cb0ff677879a93efc30a4d84d35eb0fe589a137ddc8da81
MD5 064c97580a3f0a5150f0e7679564a25d
BLAKE2b-256 4c64b1a4eefc099bab89a2724a26d477e8294fb0f2b9c7bf6a8a584c5c4d87c5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page