0 votes
475 views

 I am trying to use python to change the values of 3 global parameters and then export the result to a csv file. I have followed the tutorials and other questions but it still is not working. I get the same value every time no matter what value the global parameters are supposed to take. I am using version 2.0.alpha2. Anyone know why the parameters are not updating?

https://github.com/GreenDelta/openlca-python-tutorial/commit/26cd97acbeb946702e57084a6d99e2d47b8c0d7b

https://github.com/GreenDelta/olca-ipc.py#monte-carlo-simulations

setup = olca.CalculationSetup()

setup.parameter_redefs = []

s=0

f=open('Scenario_Results.txt', 'w')

for s in range(0, Num_Scenarios):

    setup.parameter_redefs = []

    for c in ParName:

        redef = olca.ParameterRedef()

        redef.name = c

        redef.value = int(mydata.at[s,c])

        redef.context = olca.ref(olca.ProductSystem, Product_Sys)

        setup.parameter_redefs.append(redef)

        

    setup.calculation_type = olca.CalculationType.CONTRIBUTION_ANALYSIS

    setup.product_system = olca.ref(olca.ProductSystem, Product_Sys)

    

    setup.impact_method = olca.ref(

        olca.ImpactMethod,'3a052635-988a-46f6-ba4a-052ce1623e5e')

    setup.amount = 1.0

    setup.allocation_method = olca.AllocationType.USE_DEFAULT_ALLOCATION

    

    result = client.calculate(setup)

    client.excel_export(result, 'C:/Users/gdilullo/openLCA/jython_ide/workspace/Test_Python/Test Export.xlsx')

    client.dispose(result)

in openLCA by (230 points)

1 Answer

0 votes
by (230 points)

Found the error, I was using the wrong UUID and I removed the   redef.context = olca.ref(olca.ProductSystem, Product_Sys) line and it works now.

...