brightway-lca / randonneur_data

Data for the randonneur ETL library and spec
MIT License
0 stars 0 forks source link

SimaPro correspondence files include `unit` which can replace units with conversion #5

Closed cmutel closed 5 days ago

cmutel commented 5 days ago

For example:

import randonneur_data as rd
registry = rd.Registry()
registry.sample("simapro-ecoinvent-3.10-cutoff")
>>> {'replace': [{'source': {'identifier': 'EI3ARUNI000011519624618',
    'name': 'Organic phosphorus fertiliser, as P2O5 {RER}| treatment of sewage sludge, 97% water, WWT-SLF, inert waste, landfarming | Cut-off, U',
    'platform_id': '77F4770A-F07C-4D94-B075-203DDF96522F'},
   'target': {'filename': '41cc61d7-ad1e-54da-8c56-1774f1a18be2_6dbeade5-eb8e-5666-b681-f479757cfd86.spold',
    'name': 'treatment of sewage sludge, 97% water, WWT-SLF, inert waste, landfarming',
    'location': 'RER',
    'reference product': 'organic phosphorus fertiliser, as P2O5',
    'unit': 'kg'}},
  {'source': {'identifier': 'EI3ARUNI000011519611863',
    'name': 'Electricity, high voltage {CN-SA}| electricity production, hard coal | Cut-off, U',
    'platform_id': '8AAD6DBB-BF18-444E-A410-ADD0159DD323'},
   'target': {'filename': 'ea919618-5884-5a94-a71e-a3c13e6319f1_66c93e71-f32b-4591-901c-55395db5c132.spold',
    'name': 'electricity production, hard coal',
    'location': 'CN-SA',
    'reference product': 'electricity, high voltage',
    'unit': 'kWh'}}]}

The process being linked to doesn't necessarily have the unit kWh or kg, so this can break data.

Need to check for similar potential problems in other randonneur_data files.

cmutel commented 5 days ago

What's happening is that when we import SimaPro we look at the unit with the value of 1 for each dimension. For energy this is MJ:

Units
kWh,Energy,3.6,MJ
MJ,Energy,1,MJ

So we start by converting all energy consumers to MJ. In your example:

{'amount': 6.682606596661168,
 'comment': '(2,3,1,2,1,na)',
 'line_no': 13189,
 'loc': 1.8562796101836578,
 'name': 'Electricity, low voltage {IN}| market group for electricity, low '
         'voltage | Cut-off, U',
 'original unit before conversion': 'kWh',
 'simapro_category': 'Electricity/heat',
 'type': 'technosphere',
 'uncertainty type': 0,
 'unit': 'MJ',
 'unit conversion factor': 3.6}

However, as soon as we apply the SimaPro conversion we get the 'unit' changed without an actual unit conversion:

{'amount': 6.682606596661168,
 'comment': '(2,3,1,2,1,na)',
 'filename': 'c3667777-8cf5-55bd-9c83-5a8c3bc0d979_d69294d7-8d64-4915-a896-9996a014c410.spold',
 'line_no': 13189,
 'loc': 1.8562796101836578,
 'location': 'IN',
 'name': 'market group for electricity, low voltage',
 'original unit before conversion': 'kWh',
 'reference product': 'electricity, low voltage',
 'simapro_category': 'Electricity/heat',
 'type': 'technosphere',
 'uncertainty type': 0,
 'unit': 'kWh',
 'unit conversion factor': 3.6}

Because the conversion looks like:

{'source': {'identifier': 'EI3ARUNI000011519606488',
            'name': 'Electricity, low voltage {IN}| market group for '
                    'electricity, low voltage | Cut-off, U',
            'platform_id': 'C4535753-CAA3-43C4-A244-1A1566794889'},
 'target': {'filename': 'c3667777-8cf5-55bd-9c83-5a8c3bc0d979_d69294d7-8d64-4915-a896-9996a014c410.spold',
            'location': 'IN',
            'name': 'market group for electricity, low voltage',
            'reference product': 'electricity, low voltage',
            'unit': 'kWh'}}

This data was taken without too much examination from the SimaPro conversion spreadsheets provided by PRé. Upon reflection it is obvious that having the 'unit' field in there is a huge problem, and also that this bug can be solved by simply deleting the 'unit' field.

cmutel commented 5 days ago

Fixed in 0.5