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 Q
There are a couple of questions in there. I will address each individually.
1) UUID: new_activity = old_activity.copy()
creates a new UUID for new_activity
. In your case, hp_qc.key==hp_ch.key
will return False
. Everything is therefore fine.
2) Adding an exchange: once you have found the activity you would like to link to (say, qc_elec
), you can do this:
hp_qc.new_exchange(input=qc_elect.key, amount = amount, type='technosphere')
where my_amount
is the actual amount for this exchange.
3) However, it would be much simpler in your case to adapt the exchange rather than delete and replace it:
hp_qc=hp_ch.copy()
hp_qc['location']='CA-QC'
# Assign the electricity input you want to change to a variable
elect_to_hp = [exc for exc in hp_qc.technosphere() if 'electricity, low voltage' in exc['name']][0]
# Change the input of this exchange so it links to `qc_elect`
elect_to_hp.input = qc_elect
# Save the resulting activity
elect_to_hp.save()
The exchange will be the same as the original (same amount, same uncertainty, same documentation) as the previous electricity input. You then need to change the fields you want (e.g. comment, uncertainty) this way:
elect_to_hp['comment'] = 'Recontextualisation'
4) Uncertainty, Pedigree:
You are quite right that (1) the Pedigree scores should be adapted, (2) the total uncertainty should therefore change, and (3) the pedigree scores are not used in Brightway to calculate the total uncertainty. However, you can rather easily calculate the new uncertainty using scale without pedigree
(equivalent to the basic uncertainty), the pedigree scores and the published additional uncertainty factors (reproduced from here below for your convenience) to calculate a new uncertainty (a new scale
if the PDF is lognormal) once you have modified the pedigree scores.
ecoinvent_33_pedigree_matrix = {
'reliability':
{
1:0.0,
2:0.0006,
3:0.002,
4:0.008,
5:0.04
},
'completeness':
{
1: 0.0,
2: 0.0001,
3: 0.0006,
4: 0.002,
5: 0.008
},
'temporal correlation':
{
1:0.0,
2:0.0002,
3:0.002,
4:0.008,
5:0.04
},
'geographical correlation':
{
1:0.0,
2:0.000025,
3:0.0001,
4:0.0006,
5:0.002
},
'further technological correlation':
{
1:0.0,
2:0.0006,
3:0.008,
4:0.04,
5:0.12
}
}