+1 vote
1.1k views
Hi, I am trying to change the value of a parameter in python as explained here: https://github.com/GreenDelta/olca-ipc.py.

however, the following error comes up: " 'NoneType' object has no attribute 'append' ".

could anyone tell me what I am doing wrong? many many thanks in advance.

here is my code:

import olca

import uuid

client = olca.Client(8080)

setup = olca.CalculationSetup()

redef = olca.ParameterRedef()

redef.name = 'Test_Parameter'

redef.value = 2000

setup.parameter_redefs.append(redef)

setup.calculation_type = olca.CalculationType.SIMPLE_CALCULATION

setup.impact_method = client.find(olca.ImpactMethod, 'ReCiPe Midpoint (H)')

setup.product_system = client.find(olca.ProductSystem, 'Test_Process')

setup.amount = 1.0

result = client.calculate(setup)

client.excel_export(result, 'hellotest.xlsx')

client.dispose(result)
in openLCA by (160 points)
by (110 points)
I have exactly the same problem, did you find a solution?
by (160 points)
that's my code:
import olca
import uuid
client = olca.Client(8086)
setup = olca.CalculationSetup()
setup.parameter_redefs = []
redef1 = olca.ParameterRedef()
redef1.name = 'Transport_Parameter'
redef1.value = Data_for_Parameters['Transport_Parameter'][i]
setup.parameter_redefs.append(redef1)
setup.calculation_type = olca.CalculationType.CONTRIBUTION_ANALYSIS
setup.impact_method = client.find(olca.ImpactMethod, 'ReCiPe Midpoint
setup.product_system = client.find(olca.ProductSystem, 'Lettuce
production')
setup.amount = 1.0
result = client.calculate(setup)
client.excel_export(result, path1)
client.dispose(result)

1 Answer

+3 votes
by (1.0k points)
If you want to redefine multple parameters, you need to initialize first:

setup.parameter_redefs = []

Then you can append all the redefinitions.

Or, you directly set:

setup.parameter_redefs = [redef]

(this will only work, when you redefine only one parameter)

You also need to set the redef.context, e.g. with the process id like this:

redef.context = olca.ref(olca.Process,'5d9f6c69-2ad6-4f9f-99b7-9e69e181d3bc')
...