Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting contribution tree results #24

Open
Luigi-Cala opened this issue Nov 20, 2020 · 1 comment
Open

Getting contribution tree results #24

Luigi-Cala opened this issue Nov 20, 2020 · 1 comment

Comments

@Luigi-Cala
Copy link

Hi,
i'm new here and I am trying to calculate a Product System using Contribution_Analysis calculation. As said in the title, I would like to export to an Excel Sheet the results in a form similar to the contribution tree obtained with the actual OpenLCA application when run an analisys calculation of the product system (doing all by hand, without the python developer tool).

I already tried to do it by my self but with poor results. The main problem is that as i i run the Contribution_calculation, it seem like the results provided are the same obtained with the Simple_calculation, which are basically the total impact (according to the impact category chosen) and the LCI and impact results related to the flow. While what i'm searching for are the impact realated to process used in the product system (as provided in the contribution tree results).

I hope that i explained my issue correctly and by the way I am working with the developer tool, already installed in OpenLCA. Do you perhaps have any advice on how to do this, without having to install other program or plug-in?

Thank you so much!

@Luigi-Cala
Copy link
Author

Luigi-Cala commented Nov 25, 2020

Hello!
Just an update if anyone is reading. I managed to get the contribution tree results of my product system using the following calculation method and selecting the field upstreamImpactResults in the FullResult class, exporting all on a .csv file:

f = FileChooser.forExport('*.csv', 'test.csv')
with open(f.getAbsolutePath(), 'wb') as stream:
writer = csv.writer(stream, delimiter=',')

solver = DenseSolver()
calculator = SystemCalculator(m_cache, solver)
setup = CalculationSetup(CalculationType.UPSTREAM_ANALYSIS, system)
setup.impactMethod = method
result = calculator.calculateFull(setup)

test= result.upstreamImpactResults 
col = test.columns()
roww = test.rows()
for i in range(roww):
     writer.writerow(test.getRow(i))

but now i come up with another problem, i can't find a way to "link" the result to the correct process. I have both results and the process descriptors of all the product system processes, but i really don't understand the order i which the results are provided. there is someone that has alredy deal with it? or at least know hot to sort correctly the upstreamImpactResults in such a way that i can create a table on the .csv file with named column?
Just to clarify the final table will have named rows with the impact categories selected and named columns with all the process in the product system.

Thanks in advance
Luigi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant