Giter VIP home page Giter VIP logo

brightway2-analyzer's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

brightway2-analyzer's Issues

bw2analyzer v2 imports _currently_ obsolete classes from bw2calc

An install of brightway25 1.0, using conda on a clean python 3.9 environment with:

conda install -y -q -c conda-forge -c cmutel -c haasad brightway25

will produce import error on basic imports suggested at the homepage of the brightway25 repo as shown below.
It seems that some classes are not published anymore in bw2calc.

Python 3.9.5 (default, Jun  4 2021, 12:28:51) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.28.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import bw2analyzer as ba
   ...: import bw2data as bd
   ...: import bw2calc as bc
   ...: import bw2io as bi
   ...: import matrix_utils as mu
   ...: import bw_processing as bp
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/tmp/ipykernel_902/2868165393.py in <module>
----> 1 import bw2analyzer as ba
      2 import bw2data as bd
      3 import bw2calc as bc
      4 import bw2io as bi
      5 import matrix_utils as mu

/opt/conda/lib/python3.9/site-packages/bw2analyzer/__init__.py in <module>
     19 from .health_check import DatabaseHealthCheck
     20 from .page_rank import PageRank
---> 21 from .report import SerializedLCAReport
     22 from .sc_graph import GTManipulator
     23 from .tagged import traverse_tagged_databases

/opt/conda/lib/python3.9/site-packages/bw2analyzer/report.py in <module>
      3 from .sc_graph import GTManipulator
      4 from bw2data import JsonWrapper, methods, config, projects, get_activity
----> 5 from bw2calc import ParallelMonteCarlo, LCA, GraphTraversal
      6 from scipy.stats import gaussian_kde
      7 import numpy as np

ImportError: cannot import name 'ParallelMonteCarlo' from 'bw2calc' (/opt/conda/lib/python3.9/site-packages/bw2calc/__init__.py)

Tests are failing

Tests are failing with the most recent version of brightway2-analyzer. I attached the console dump. All four tests seem to fail for the same reason: the chained calling of filter_by_attribute does not work anymore, because it returns a string, not a package.
bugreport.txt

Top activities not working for upstream exploration of hotspots

brightway2==2.3
bw-migrations==0.2
bw2analyzer==0.11.4
bw2calc==1.8.1
bw2data==3.6.2
bw2io==0.8.7
bw2parameters==0.6.6
python = 3.9
print(lca.top_activities())

File "/home/tghosh/.local/lib/python3.9/site-packages/bw2calc/lca.py", line 583, in top_activities
return ContributionAnalysis().annotated_top_processes(self, **kwargs)
File "/home/tghosh/.local/lib/python3.9/site-packages/bw2analyzer/contribution.py", line 133, in annotated_top_processes
results = [
File "/home/tghosh/.local/lib/python3.9/site-packages/bw2analyzer/contribution.py", line 137, in
lca.dicts.activity.reversed[int(index)],
AttributeError: 'LCA' object has no attribute 'dicts'

bw2analyzer==0.10 does not have this issue.

`recursive_calculation_to_object` not available in `bw2analyzer 0.10` but listed in legacy doc

Hello,
we are currently using legacy Brightway2 platform, installed with conda from the conda-forge channel.

We need to traverse the supply chain and calculate the LCA score of each activity for reporting purposes, and have found the function bw2analyzer.utils.recursive_calculation_to_object to be exactly what we need in this case. The legacy documentation shows the function as part of the bw2analyzer.utils module, however, in the packaged distribution of bw2analyzer that we have in our conda environment that function is missing, even after an update to the latest version using the command conda update -c conda-forge brightway2.

I tried updating directly the package with conda update -c conda-forge brightway2, but nothing changes and it seems that the latest version available is already installed, and that version is 0.10.

The command conda search -c conda-forge 'bw2analyzer>=0.10' returns

# Name                       Version           Build  Channel             
bw2analyzer                     0.10    pyhd8ed1ab_0  conda-forge         
bw2analyzer                   0.11.4    pyhd8ed1ab_0  conda-forge         
bw2analyzer                   0.11.4    pyhd8ed1ab_1  conda-forge

but, as I can understand from this documentation page we cannot use the 0.11.* versions as those are only compatible with Brightway25.

The function is documented in bw2analyzer for the legacy project, and in the branch bw2legacy of this repository is in fact present, is there any reason why it's not packaged yet? Maybe we should use a different channel?
I remember we first installed Brightway using the cmutel channel in September 2022, and then switched over to conda-forge in order to update to latest version.

Here are the installed versions in our environment:

# Name                    Version                   Build  Channel
brightway2                2.4.3              pyhd8ed1ab_0    conda-forge
bw2analyzer               0.10               pyhd8ed1ab_0    conda-forge
bw2calc                   1.8.2           py310hff52083_0    conda-forge
bw2data                   3.6.6              pyhd8ed1ab_0    conda-forge
bw2io                     0.8.8              pyhd8ed1ab_1    conda-forge
bw2parameters             0.7                pyhd8ed1ab_0    conda-forge
bw_migrations             0.2                pyhd8ed1ab_0    conda-forge

Thanks in advance for the help and also for all the effort put in this project, it's really awesome.
Regards

no attribute '_mapped_dict'

Original report by giuseppe cardellini (Bitbucket: cardosan, GitHub: cardosan).


In bw2analyzer 0, 9, 'dev2'

/home/giuseppec/miniconda3/envs/bw2_py3/lib/python3.4/site-packages/bw2analyzer/contribution.py in annotated_top_processes(self, lca, names, **kwargs)
131
132 """
--> 133 if lca._mapped_dict:
134 lca.fix_dictionaries()
135 ra, rp, rb = lca.reverse_dict()

AttributeError: 'LCA' object has no attribute '_mapped_dict'

Tagged graphs with non-unitary activities

Original report by Anonymous.


Hello,
I've been using the function analysis.recurse_tagged_database() to plot my LCA by tags for more clarity. However I've noticed that my biosphere exchanges are multiplied twice which at the end doesn't give the accurate impacts for the tags. However the LCA is run perfectly and give the right value. Because some of my activities don't always have an unitary output, I was wondering if the analysis.recurse_tagged_database() was working only with unitary activities?

Just to give an example:
My FU consumed 10 kg of Activity_1
Activity_1 is defined as: output (production)=10kg and biosphere input = 2 kg of CO2 (tag CO2_emissions)
The lca calculation will give a final result of 2 kg of CO2 (ok)
But the graph generated by the analysis.recurse_tagged_database() function will give an output of 2*10=20 kg CO2... which is inaccurate..
Could you help me with that ?
Regards,
Josephine

Invalid sorting for Contribution results when top contributors are negative (Absolute values)

When getting the contribution results, if the top contributions have a negative value BW analyzer ignore these. The issue is in the limit calculation, as it doesnt take negatives into account.

I have tried the following fix and it works:
contribution.py > ContributionAnalysis > sort_array() method > line 44
Currently: limit = (data >= (total * limit)).sum()
Fix: limit = (np.abs(data) >= (total * limit)).sum()

Does this issue have any horizontal impacts? (Other places where negatives may not have been considered?)

multi_traverse_tagged_databases does not yield same result as simple LCA when activity with negative production exchange is included

Hi, I am using the multi_traverse_tagged_databases function to generate a more detailed breakdown of LCA results, but noticed that the cumulative impact (calculated on the result of multi_traverse_tagged_databases with get_multi_cum_impact) of the resulting graph did not equal the impact score of the LCA function applied to the same reference flow.

After some analysis, I found out that the problem is linked to the occurrence of activities that have a production exchange of "-1" (i.e. a waste treatment record from the ecoinvent database). Changing the production exchange into "1" solves the discrepancy betwee both ways of calculating the impact.

Searching online brought me to this thread about the use of negative production exchanges in Brightway vs Simapro:
https://stackoverflow.com/questions/68133565/negative-production-for-end-of-life-treatment-process

Now my question is: which calculation correctly processes the negative production exchange: the standard LCA function or the multi_traverse_tagged_databases function? Or on other words: is there a bug in the code, or should I adapt negative production exchanges in background records before using them in Brightway? If the latter is the case, then why can't I find any guidance on this issue anywhere in the Brightway documentation, as it is a problem any user of "waste treatment" records of Ecoinvent will experience, without knowing?

Thank you for looking into this!

Pipelines failing

The log message is:

git remote add origin https://github.com/brightway-lca/brightway2-analyzer
git config gc.auto 0
git config --get-all http.https://github.com/brightway-lca/brightway2-analyzer.extraheader
git config --get-all http.proxy
git config http.version HTTP/1.1
git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --prune-tags --progress --no-recurse-submodules origin  +refs/heads/*:refs/remotes/origin/* +refs/pull/16/merge:refs/remotes/pull/16/merge
fatal: could not read Username for 'https://github.com': terminal prompts disabled
##[warning]Git fetch failed with exit code 128, back off 9.958 seconds before retry.
git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --prune-tags --progress --no-recurse-submodules origin  +refs/heads/*:refs/remotes/origin/* +refs/pull/16/merge:refs/remotes/pull/16/merge
fatal: could not read Username for 'https://github.com': terminal prompts disabled
##[warning]Git fetch failed with exit code 128, back off 5.756 seconds before retry.
git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --prune-tags --progress --no-recurse-submodules origin  +refs/heads/*:refs/remotes/origin/* +refs/pull/16/merge:refs/remotes/pull/16/merge
fatal: could not read Username for 'https://github.com': terminal prompts disabled
##[error]Git fetch failed with exit code: 128
Finishing: Checkout brightway-lca/brightway2-analyzer@refs/pull/16/merge to s

Very hard to understand what is happening here, as 1) this is a public repository which doesn't require authentication for pulls, 2) the config is copied from other Brightway repos which work fine, and 3) the Azure integration is for the whole Brightway org, it doesn't have separate configs for each repo.

I don't find anything useful searching online, only questions where authentication is needed.

ContributionAnalysis.sort_array

Hi,

first of all thanks for all the great work. Second this is a small issue and is related to the method used to order the contributions. If you disagree with what I feel about this then I would love to hear your feedback and arguments, I'm pretty stubborn but do try to listen to wisdom! The issue is around the use of the literal values, rather than what I would describe as the weight (e.g. the degree of impact, using the absolute of a value) that a parameter (be it a method, or process) has on a factor, for ordering those parameter contributions.

Working on the visualisations in the AB using the literal value means that there is no capability for us, or the users to investigate the impacts when there is a negative contribution to a factor. Hence part of why I would argue that there should be a change to the ContributionAnalysis.sort_array method, so that it would order the parameters according to their weights on the factor. I also think this would provide users with a better view on the actual degree of impact the parameters have on the factor they are trying to analyse.

I hope you agree, otherwise I look forward to trying to argue with you

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.