brightway-lca / brightway2-io

Importing and exporting for the Brightway LCA framework
BSD 3-Clause "New" or "Revised" License
26 stars 41 forks source link

Unit conversion in the CF for ReCiPe Midpoint Water Depletion wrong #24

Closed aleksandra-kim closed 8 years ago

aleksandra-kim commented 8 years ago

Original report by Tomas Navarrete Gutierrez (Bitbucket: tomas_navarrete, ).


Looking at the characterization factors for ReCiPe Midpoint (H), water depletion, and found a problem with the CF for "water natural unspecified origin".

Here is the output of bw2-browser to see the cfs of the method:


default [ReCiPe Midpoint (H)/water depletion/WDP] >> cfs 
CFS 
---------------------------------  --------------------------------  ---------------  ---  -----  ----------- 
Water, in air                      ('natural resource', 'in air')    water depletion  WDP  1      cubic meter 
Water, lake                        ('natural resource', 'in water')  water depletion  WDP  1      cubic meter 
Water, river                       ('natural resource', 'in water')  water depletion  WDP  1      cubic meter 
Water, unspecified natural origin  ('natural resource', 'in water')  water depletion  WDP  0.001  cubic meter 
Water, well, in ground             ('natural resource', 'in water')  water depletion  WDP  1      cubic meter 
---------------------------------  --------------------------------  ---------------  ---  -----  -----------

Looking quickly at the xlsx files from recipe website (http://www.lcia-recipe.net/file-cabinet/ReCiPe111.xlsx?attredirects=0&d=1 [tab wdp] or http://www.lcia-recipe.net/file-cabinet/ReCiPe112Midpoints.CSV?attredirects=0&d=1, rows 79102 and 79103) , we found that:

aleksandra-kim commented 8 years ago

Original comment by Chris Mutel (Bitbucket: cmutel, GitHub: cmutel).


Fixes #24. Change CFs for water which had wrong units

aleksandra-kim commented 8 years ago

Original comment by Chris Mutel (Bitbucket: cmutel, GitHub: cmutel).


Unfortunately, there is no good way to refresh the changed methods. Easiest is probably the following:

#!python
for x in list(databases):
    del databases[x]

create_default_lcia_methods()
aleksandra-kim commented 8 years ago

Original comment by Tomas Navarrete Gutierrez (Bitbucket: tomas_navarrete, ).


I get this error when trying your suggestion:

     92     create_default_biosphere3()
     93     print("Creating default LCIA methods\n")
---> 94     create_default_lcia_methods()
     95     print("Creating core data migrations\n")
     96     create_core_migrations()

/home/tomas/virtualenvs/jamiroquai/lib/python3.4/site-packages/bw2io/__init__.py in create_default_lcia_methods()
     83     ei = EcoinventLCIAImporter()
     84     ei.apply_strategies()
---> 85     ei.write_methods()
     86 
     87 def bw2setup():

/home/tomas/virtualenvs/jamiroquai/lib/python3.4/site-packages/bw2io/importers/base_lcia.py in write_methods(self, overwrite)
     59                     raise ValueError((u"Method {} already exists. Use "
     60                         u"``overwrite=True`` to overwrite existing methods"
---> 61                         ).format(ds['name']))
     62 
     63             with warnings.catch_warnings():

ValueError: Method ('ReCiPe Midpoint (H)', 'climate change', 'GWP100') already exists. Use ``overwrite=True`` to overwrite existing methods

but calling create_default_lcia_methods with overwrite=True is not possible:

In [9]: create_default_lcia_methods(overwrite=True)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-9-9f046d2f54f6> in <module>()
----> 1 create_default_lcia_methods(overwrite=True)

TypeError: create_default_lcia_methods() got an unexpected keyword argument 'overwrite'

bw2setup() after deleting databases won't work either:

In [11]: for x in list(databases):
    del databases[x]
   ....: 

In [12]: bw2setup()
Creating default biosphere

Applying strategy: normalize_units
Applying strategy: drop_unspecified_subcategories
Applied 2 strategies in 0.01 seconds
Writing activities to SQLite3 database:
0%                          100%
[##############################] | ETA: 00:00:00
Total time elapsed: 00:00:03
Title: Writing activities to SQLite3 database:
  Started: 07/01/2016 16:08:05
  Finished: 07/01/2016 16:08:08
  Total time elapsed: 00:00:03
  CPU %: 12.00
  Memory %: 1.50
Created database: biosphere3
Creating default LCIA methods

Applying strategy: normalize_units
Applying strategy: set_biosphere_type
Applying strategy: drop_unspecified_subcategories
Applying strategy: link_iterable_by_fields
Applied 4 strategies in 1.13 seconds
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-12-c9438012d7c9> in <module>()
----> 1 bw2setup()

/home/tomas/virtualenvs/jamiroquai/lib/python3.4/site-packages/bw2io/__init__.py in bw2setup()
     92     create_default_biosphere3()
     93     print("Creating default LCIA methods\n")
---> 94     create_default_lcia_methods()
     95     print("Creating core data migrations\n")
     96     create_core_migrations()

/home/tomas/virtualenvs/jamiroquai/lib/python3.4/site-packages/bw2io/__init__.py in create_default_lcia_methods()
     83     ei = EcoinventLCIAImporter()
     84     ei.apply_strategies()
---> 85     ei.write_methods()
     86 
     87 def bw2setup():

/home/tomas/virtualenvs/jamiroquai/lib/python3.4/site-packages/bw2io/importers/base_lcia.py in write_methods(self, overwrite)
     59                     raise ValueError((u"Method {} already exists. Use "
     60                         u"``overwrite=True`` to overwrite existing methods"
---> 61                         ).format(ds['name']))
     62 
     63             with warnings.catch_warnings():

ValueError: Method ('ReCiPe Midpoint (E) w/o LT', 'ionising radiation w/o LT', 'IRP_HE w/o LT') already exists. Use ``overwrite=True`` to overwrite existing methods

relevant installed modules:

aleksandra-kim commented 8 years ago

Original comment by Chris Mutel (Bitbucket: cmutel, GitHub: cmutel).


Sorry, really stupid typo/brain fart there.

The correct code is:

#!python
for x in list(methods):
    del methods[x]

create_default_lcia_methods()

overwrite flag was added in f37f0c3, but this is part of a bigger release that will take a few days.