Code Monkey home page Code Monkey logo

Comments (4)

aleksandra-kim avatar aleksandra-kim commented on September 25, 2024

Original comment by Chris Mutel (Bitbucket: cmutel, GitHub: cmutel).


Thanks for the bug report!

It looks like this parameter distribution is incorrect. In the triangular distribution, the "left" (minimum) must be less than or equal to the mode, which must be less or equal to the maximum ("right"). See https://en.wikipedia.org/wiki/Triangular_distribution.

What database are you working with? Or can you say which tutorial, specifically?

Thanks,
Chris

from brightway2-calc.

aleksandra-kim avatar aleksandra-kim commented on September 25, 2024

Original comment by Caroline Nadel (Bitbucket: cazcazn, ).


Like I say, it happened with both tutorials 2 and 3 after following them from 1. In order to import the US-LCI database I had to fix a few things in the code, as when checking if a category is in the biosphere, it crashed. In addition, the database folder structure has changed so it makes sense to update the tutorial.

I would make a pull request, but it entailed forcing the checker to accept some database values that might not have been correct. Import failed with "Incorrect category for biosphere flow". The changes I made to get around this were in bw2data/io/import_ecospold.py:

21:BIOSPHERE = ("air", "water", "soil", "resource", "final-waste-flow", "raw", "others", "non-material")
431:            assert exc[u"matching"][u"categories"][0].lower() in BIOSPHERE, \

Specifically, "Air" was rejected so I added a .lower, and "others" and "non-material" were rejected so I added those to the biosphere list. This may have messed up the database in some unknown way.

Perhaps you could try running through the tutorials from scratch with the latest US-LCI and see what fixes need to be made? Then once I understand the code a bit more I'm more than happy to contribute!

from brightway2-calc.

aleksandra-kim avatar aleksandra-kim commented on September 25, 2024

Original comment by Chris Mutel (Bitbucket: cmutel, GitHub: cmutel).


Hi Cazcazn-

Thanks again, sorry for the delay.

I can't import the US LCI cleanly, due partly to the reasons you have noticed, but also because there are some internal inconsistencies, partly due it looks like to some entries being manually typed in (with the resulting typos), but also due to some pollution from SimaPro. I have also added the SimaPro biosphere categories (https://bitbucket.org/cmutel/brightway2-io/src/b7dca26debaaae2df834ed51df154e3192ac838f/bw2io/compatibility.py?at=default&fileviewer=file-view-default). However, I still have a number of issues with the import, as seen here: http://nbviewer.ipython.org/urls/bitbucket.org/cmutel/brightway2/raw/2.0/notebooks/IO%20-%20Importing%20US%20LCI%20database.ipynb

I would love to have an example database that could be used in the tutorials, but haven't found a good one yet. Maybe you have some ideas?

BTW, you can fix the MC problem with something like this (adapt as needed):

#!python

from brightway2 import *
from stats_arrays import *
import numpy as np

db = Database("whatever")
data = db.load()

for ds in data.values():
    for exc in ds.get('exchanges'):
        if exc['uncertainty type'] == TriangularUncertainty.id and \
                (exc['minimum'] >= exc['loc'] or exc['maximum'] <= exc['loc']):
            # Invalid triangular, switch to no uncertainty
            exc['uncertainty type'] = NoUncertainty.id
            exc['minimum'] = exc['maximum'] = np.nan

db.write(data)

In the development version (see http://brightwaylca.org/dev-docs/), it would be:

#!python

from brightway2 import *
from stats_arrays import *
import numpy as np

for ds in Database("whatever"):
    for exc in ds.exchanges():
        if exc['uncertainty type'] == TriangularUncertainty.id and \
                (exc['minimum'] >= exc['loc'] or exc['maximum'] <= exc['loc']):
            # Invalid triangular, switch to no uncertainty
            exc['uncertainty type'] = NoUncertainty.id
            exc['minimum'] = exc['maximum'] = np.nan
            exc.save()

from brightway2-calc.

aleksandra-kim avatar aleksandra-kim commented on September 25, 2024

Original comment by Chris Mutel (Bitbucket: cmutel, GitHub: cmutel).


If there is a problem, it isn't with bw2calc, so closing this for now.

from brightway2-calc.

Related Issues (20)

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.