I'm quite new to bw2 and python as well so I don't understand what is going wrong when running through the parametetrisation of the bottle production part of the notebook.
This is the code:
The following for-loop is only to guarantee that we can create a new bottle production process
for activity in [act for act in eidb if 'Bottle production' in act['name'] and 'GLO' in act['location']]:
activity.delete()
activities and exchanges for simple bottle production model
bottle_production = eidb.new_activity(code = 'test1', name = "Bottle production", unit = "unit")
bottle_production.save()
project_data = [{
'name': 'M',
'amount': 0.06,
}, {
'name': 'D',
'amount': 200
}]
parameters.new_project_parameters(project_data)
for param in ProjectParameter.select():
print(param, param.amount)
electricity = [act for act in eidb if act['name']=='electricity production, photovoltaic, 3kWp slanted-roof installation, multi-Si, panel, mounted, label-certified' and 'CH' in act['location']][0]
bottle_production.new_exchange(input=electricity.key,amount=0,unit="kilowatt hour",type='technosphere', formula='20*M/3.6').save()
bottle_production.save()
mind how the following activity is treated differently! The reason for this will be shown later
polyethylene = [act for act in eidb if act['name']=='market for polyethylene, high density, granulate' and 'GLO' in act['location']][0]
pe = bottle_production.new_exchange(input=polyethylene.key,amount=0,unit="kilogram",type='technosphere', formula='M')
pe.save()
bottle_production.save()
transport = [act for act in eidb if act['name']=='market for transport, freight, lorry 3.5-7.5 metric ton, EURO5' and 'RER' in act['location']][0]
bottle_production.new_exchange(input=transport.key,amount=0,unit="ton kilometer",type='technosphere', formula='D*M/1000').save()
bottle_production.save()
parameters.add_exchanges_to_group("again another group", bottle_production)
ActivityParameter.recalculate_exchanges("again another group")
And this is the error that I get:
Project parameter: M 0.06
Project parameter: D 200.0
IndexError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_12900/2183810850.py in
20 print(param, param.amount)
21
---> 22 electricity = [act for act in eidb if act['name']=='electricity production, photovoltaic, 3kWp slanted-roof installation, multi-Si, panel, mounted, label-certified' and 'CH' in act['location']][0]
23 bottle_production.new_exchange(input=electricity.key,amount=0,unit="kilowatt hour",type='technosphere', formula='20*M/3.6').save()
24 bottle_production.save()
Hello everyone,
I'm quite new to bw2 and python as well so I don't understand what is going wrong when running through the parametetrisation of the bottle production part of the notebook.
This is the code:
The following for-loop is only to guarantee that we can create a new bottle production process
activities and exchanges for simple bottle production model
mind how the following activity is treated differently! The reason for this will be shown later
And this is the error that I get:
Project parameter: M 0.06 Project parameter: D 200.0
IndexError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_12900/2183810850.py in
20 print(param, param.amount)
21
---> 22 electricity = [act for act in eidb if act['name']=='electricity production, photovoltaic, 3kWp slanted-roof installation, multi-Si, panel, mounted, label-certified' and 'CH' in act['location']][0]
23 bottle_production.new_exchange(input=electricity.key,amount=0,unit="kilowatt hour",type='technosphere', formula='20*M/3.6').save()
24 bottle_production.save()
IndexError: list index out of range