Giter VIP home page Giter VIP logo

bw_migrations's Introduction

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).

bw_migrations's People

Contributors

cmutel avatar michaelweinold avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.