brightway-lca / brightway2-io

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

EF 3.1 import from simapro #209

Open ccomb opened 1 year ago

ccomb commented 1 year ago

Using 0.9.DEV21, I'm trying to import an Environmental Footprint 3.1 method which is different from the one included in Brightway.

At the end of the Method section, there is a normalization and weighting set that look like this:

Method

Name
Environmental Footprint 3.1 (adapted) patch wtu

Version  
1;00

(..........)

Normalization-Weighting set
EF 3.1 normalization and weighting set

Normalization
Acidification;1,79954697817319E-2
Climate change;1,32396265000545E-4
Ecotoxicity, freshwater;1,76315265883092E-5
Particulate matter;1,67963676260898E3
Eutrophication, marine;5,11635053040380E-2
Eutrophication, freshwater;6,22334801314516E-1
Eutrophication, terrestrial;5,65754859095399E-3
Human toxicity, cancer;5,79612781610433E4                                                                                                                                                                                                     Human toxicity, non-cancer;7,76785093849270E3
Ionising radiation;2,36957650107588E-4
Land use;1,22025895949292E-6                                                                                                                                                                                                                  Ozone depletion;1,91027866641876E1
Photochemical ozone formation;2,44742935603176E-2
Resource use, fossils;1,53836072461811E-5
Resource use, minerals and metals;1,57176814608394E1
Water use;8,71937749334747E-5

Weighting
Acidification;0,062
Climate change;0,2106
Ecotoxicity, freshwater;0,0192
Particulate matter;0,0896
Eutrophication, marine;0,0296
Eutrophication, freshwater;0,028
Eutrophication, terrestrial;0,0371
Human toxicity, cancer;0,0213
Human toxicity, non-cancer;0,0184
Ionising radiation;0,0501
Land use;0,0794
Ozone depletion;0,0631
Photochemical ozone formation;0,0478
Resource use, fossils;0,0832
Resource use, minerals and metals;0,0755
Water use;0,0851

End

When importing it with the simapro_lcia_csv extractor, I get this error:

Traceback (most recent call last):
  File "/home/jovyan/ecobalyse/data/import_method.py", line 62, in <module>
    main()
  File "/home/jovyan/ecobalyse/data/import_method.py", line 56, in main
    import_method()
  File "/home/jovyan/ecobalyse/data/import_method.py", line 33, in import_method
    ef = bw2io.importers.SimaProLCIACSVImporter(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/bw2io/importers/simapro_lcia_csv.py", line 61, in __init__
    self.data = SimaProLCIACSVExtractor.extract(filepath, delimiter, encoding)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/bw2io/extractors/simapro_lcia_csv.py", line 85, in extract
    ds, index = cls.read_method_data_set(lines, index, filepath)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/bw2io/extractors/simapro_lcia_csv.py", line 239, in read_method_data_set
    nw_dataset, index = cls.get_normalization_weighting_data(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/bw2io/extractors/simapro_lcia_csv.py", line 419, in get_normalization_weighting_data
    assert data[index][0] == "Weighting"
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

At this moment, data[index][0] is equal to "Normalization". In the code there is a comment: # TODO: Only works for weighting data, no addition or normalization

ccomb commented 1 year ago

(I'm not sure how to fix this)

cmutel commented 1 year ago

Can you make the CSV file available somewhere? We can update the importer but the SimaPro CSVs are unpredictable, we need actual data (including outside the provided section) to write tests and make sure things are reasonable.

ccomb commented 1 year ago

I uploaded the file here: https://nextcloud.prelab.fr/index.php/s/Mao3AQaMPSL6xFs

tfardet commented 10 months ago

I have the same issue with SimaProLCIACSVImporter on the SImaPro files from Impact World+: https://zenodo.org/records/8200703