Skip to main content

Migration data and utilities for Brightway IO and LCA in general

Project description

bw_migrations

Migration data and utilities for Brightway IO and LCA in general

Build Status Coverage Status Build status

Most databases use their own nomenclature for classification systems, units, etc. These systems need to be matched when linking from one database to another. Often, a simple mapping is suitable, and tools like correspondentia are a good fit. However, sometimes one needs more complexity, e.g. change field X to Y, but only if field A has value B. When ecoinvent released version 3, they changed their unit of mesaure for water from kilograms to cubic meters. bw_migrations provides tools for this more complicated transformations, and is built around the following data format:

{
    # The fields on which to filter
    'fields': ['name', 'category', 'unit'],
    'data': [
        (
            # First element is input data in the order of `fields` above
            ('Water', 'air', 'kilogram'),
            # Second element is new values to substitute when all fields match
            {
                'unit': 'cubic meter',
                '__multiplier__': 0.001
            }
        )
    ]
}

And is implemented with the following pseudo-code:

for element in input_data:
    for original, new in migration['data']:
        if all(element[field] == original[field] for field in migration['fields']):
            element.update(dict(zip(migration['fields'], new)))

The actual code is a bit more complex, as bw_migrations can also do rescaling of probability distributions and disaggregation migrations (splitting one object into several outputs).

Project details


Release history Release notifications

This version

0.1

Download files

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

Files for bw-migrations, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size bw_migrations-0.1-py3-none-any.whl (8.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size bw_migrations-0.1.tar.gz (8.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page