+3 votes
1.2k views
How I can change Uncertainty value like "Normal distribution" mean, standard deviation by python code.
in openLCA by (230 points)

1 Answer

+2 votes
by (1.5k points)
selected by
 
Best answer
If you use the ipc server it's pretty straight forward.  Here I update the first exchange in my process called test to normal distribution with a mean of 3 and standard deviation of .25.

import olca
client = olca.Client(8080)

ref = client.find(olca.Process,'test')
process = client.get(olca.Process, ref.id)
process.exchanges[0].uncertainty.distribution_type = olca.UncertaintyType('NORMAL_DISTRIBUTION')
process.exchanges[0].uncertainty.mean = 3
process.exchanges[0].uncertainty.sd = 0.25

client.update(process)
by (230 points)
Thank you for your help.
This the procedure which I want to add two statements (Mean&SD), but it does not work.

def updateProcess(id,List_flow):  
    pro = olca.getProcess(id)
    #exs = pro.getExchanges()
    exs = pro.exchanges
    for ex in exs:
        k=0
        for j in List_flow:  
            if ex.flow.name == List_flow[k][0] and ex.flow.category.name==List_flow[k][2]:                
                ex.amount = float(List_flow[k][1])             
                log.info("{} uncertainty", ex.uncertainty)

                #here the problem
                ex.uncertainty.mean=3
                break
            k=k+1
    olca.updateProcess(pro)
    log.info("{} has been updated",pro.name)

    return
I hope you can help me.
...