I would like to create an activity "recontextualizing" an existing dataset from a database (in this case ecoinvent) that serves as a proxy. For example, create heat pumps in Quebec based on heat pumps in Switzerland but changing the origin of electricity.
My problem is quite similar to the one raised by @MPa in this question, but I can't figure out how to do it without more details. This is what I did:
1) find the process I want to use as proxy from my ecoinvent 3.3 database:
hp_ch=Database('ei_33consequential').search("heat-pump production air-water",
filter={'location':'ch'},
)[0]
2) create a copy of the activity
hp_qc=hp_ch.copy()
3) change the location
hp_qc['location']='CA-QC'
4) erase the original flow storing the amount of the exchange
for exc in hp_qc.exchanges():
if 'electricity, low voltage' in exc['name']:
amnt=(exc.amount)
exc.delete()
5) add the new flow (in this case the same amount of electricity from Quebec)
here is where I am a lost. I know how to find the process that generates that flow ('44389eae7d62fa9d4ea9ea2b9fc2f609') but I don't know how to add it as an exchange to my "hp_qc" process. I guess I should also change the unique identifier code (UUID) or otherwise I will have two activities in my database with the same UUID, which could be problematic. I should also modify the "geographical representativeness" score of the pedigree matrix, but I am not sure these scores are actually used by Brightway 2 at this point.
[EDIT], following the suggestion of @MPa I did the following:
#electricity low voltage quebec
elw_qc=Database('ei_33consequential').get('44389eae7d62fa9d4ea9ea2b9fc2f609')
elect_to_hp = [exc for exc in hp_qc.technosphere() if 'electricity, low voltage' in exc['name']][0]
elect_to_hp.input = qc_elect
elec_to_hp.save()
hp_qc.save() #necessary?
and I tested with a common impact assessment method:
fu1={hp_qc:1}
lca1=LCA(fu1,('IMPACT 2002+ (Endpoint)', 'resources', 'total'))
lca1.lci()
lca1.lcia()
lca1.score
fu2={hp_ch:1}
lca2=LCA(fu2,('IMPACT 2002+ (Endpoint)', 'resources', 'total'))
lca2.lci()
lca2.lcia()
lca2.score
Both scores are different, although I get a negative score for the Swiss heat pump, which is a bit weird but I guess possible and totally unrelated to the recontextualisation. It works!