-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse_iw.py
8126 lines (7330 loc) · 551 KB
/
parse_iw.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
This project aims to parse the IMPACT World+ files from the original Microsoft access database to the different
implementation in the available LCA software (SimaPro, openLCA & brightway2). A developer version of IW+ is also parsed
and is made available in an Excel format. This version is aimed for entities wishing to integrated IW+ in their
tools/databases on their own.
In the end, IMPACT World+ will span over 5 different files, in different formats:
- the original Microsoft access database (referred to as the source version)
- the Excel version of IW+ regrouping characterization factors from the source version as well as additional
extrapolated CFs (referred to as the dev version)
- the IW+ version directly implementable in the SimaPro LCA software, in a .csv format (referred to as the SimaPro version)
- the IW+ version directly implementable in the openLCA LCA software, in a .zip format (referred to as the openLCA version)
- the IW+ version directly implementable in the brightway2 LCA software, in a .bw2package format (referred to as the
brightway2 version)
All equations modeling the AGTP of GHGs come from the work of Thomas Gasser (gasser@iiasa.ac.at) and Yue He (heyue@iiasa.ac.at)
file name: parse_iw.py
author: Maxime Agez
e-mail: maxime.agez@polymtl.ca
date created: 02-04-22
python version= 3.9
"""
import pandas as pd
import numpy as np
import os
import pkg_resources
import json
import country_converter as coco
import scipy.sparse
import brightway2 as bw2
import bw2io
import datetime
from datetime import datetime
import csv
import warnings
import uuid
import shutil
import zipfile
import logging
import sqlite3
import math
import molmass
from scipy.stats import gmean
from tqdm import tqdm
class Parse:
def __init__(self, path_access_db, version, bw2_projects):
"""
:param path_access_db: path to the Microsoft access database (source version)
:param version: the version of IW+ to parse
:param version: (optional) the name of a brightway2 project in which the database "biosphere3" is available
Object instance variables:
-------------------------
- master_db : the master dataframe where basic IW CFs are stored (what is used to produce the dev.xlsx file)
- ei35_iw : the dataframe where IW CFs linked to ecoinvent v3.5 elementary flows are stored
- ei36_iw : the dataframe where IW CFs linked to ecoinvent v3.6 elementary flows are stored
- ei371_iw : the dataframe where IW CFs linked to ecoinvent v3.7.1 elementary flows are stored
- ei38_iw : the dataframe where IW CFs linked to ecoinvent v3.8 elementary flows are stored
- ei391_iw : the dataframe where IW CFs linked to ecoinvent v3.9.1 elementary flows are stored
- ei310_iw : the dataframe where IW CFs linked to ecoinvent v3.10 elementary flows are stored
- iw_sp : the dataframe where IW CFs linked to SimaPro elementary flows are stored
- olca_iw : the dataframe where IW CFs linked to openLCA elementary flows are stored
- exio_iw : the dataframe where IW CFs linked to EXIOBASE elementary flows are stored
Object insteance methods:
-------------------------
- load_cfs()
- load_basic_cfs()
- load_acid_eutro_cfs()
- load_land_use_cfs()
- load_particulates_cfs()
- load_water_scarcity_cfs()
- load_water_availability_fw_cfs()
- load_water_availability_hh_cfs()
- load_water_availability_terr_cfs()
- load_thermally_polluted_water_cfs()
- apply_rules()
- create_not_regio_flows()
- create_regio_flows_for_not_regio_ic()
- order_things_around()
- separate_regio_cfs()
- link_to_ecoinvent()
- export_to_bw2()
- link_to_sp()
- export_to_sp()
- produce_files()
- produce_files_hybrid_ecoinvent()
"""
# ignoring some warnings
warnings.filterwarnings(action='ignore', category=FutureWarning)
warnings.filterwarnings(action='ignore', category=np.VisibleDeprecationWarning)
warnings.filterwarnings(action='ignore', category=pd.errors.PerformanceWarning)
warnings.filterwarnings(action='ignore', category=UserWarning)
# set up logging tool
self.logger = logging.getLogger('IW_Reborn')
self.logger.setLevel(logging.INFO)
self.logger.handlers = []
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
ch.setFormatter(formatter)
self.logger.addHandler(ch)
self.logger.propagate = False
self.path_access_db = path_access_db
self.version = str(version)
self.bw2_projects = bw2_projects
# OUTPUTs
self.master_db = pd.DataFrame()
self.master_db_carbon_neutrality = pd.DataFrame()
self.master_db_not_regio = pd.DataFrame()
self.master_db_not_regio_carbon_neutrality = pd.DataFrame()
self.ei38_iw = pd.DataFrame()
self.ei38_iw_carbon_neutrality = pd.DataFrame()
self.ei39_iw = pd.DataFrame()
self.ei39_iw_carbon_neutrality = pd.DataFrame()
self.ei310_iw = pd.DataFrame()
self.ei310_iw_carbon_neutrality = pd.DataFrame()
self.simplified_version_ei38 = pd.DataFrame()
self.simplified_version_ei39 = pd.DataFrame()
self.simplified_version_ei310 = pd.DataFrame()
self.iw_sp = pd.DataFrame()
self.iw_sp_carbon_neutrality = pd.DataFrame()
self.simplified_version_sp = pd.DataFrame()
self.simplified_version_olca = pd.DataFrame()
self.simplified_version_bw = pd.DataFrame()
self.sp_data = {}
self.olca_iw = pd.DataFrame()
self.olca_iw_carbon_neutrality = pd.DataFrame()
self.olca_data = {}
self.olca_data_custom = {}
self.exio_iw = pd.DataFrame()
self.conn = sqlite3.connect(self.path_access_db)
# -------------------------------------------- Main methods ------------------------------------------------------------
def load_cfs(self):
"""
Load the characterization factors and stored them in master_db.
:return: updated master_db
"""
self.load_basic_cfs()
self.logger.info("Loading climate change characterization factors...")
self.load_climate_change_cfs()
self.logger.info("Loading ozone layer depletion characterization factors...")
self.load_ozone_layer_depletion_cfs()
self.logger.info("Loading photochemical ozone formation characterization factors...")
self.load_photochemical_ozone_formation()
self.logger.info("Loading acidification characterization factors...")
self.load_freshwater_acidification_cfs()
self.load_terrestrial_acidification_cfs()
self.logger.info("Loading eutrophication characterization factors...")
self.load_marine_eutrophication_cfs()
self.load_freshwater_eutrophication_cfs()
self.logger.info("Loading land use characterization factors...")
self.load_land_use_cfs()
self.logger.info("Loading particulate matter characterization factors...")
self.load_particulates_cfs()
self.logger.info("Loading water scarcity characterization factors...")
self.load_water_scarcity_cfs()
self.logger.info("Loading water availability characterization factors...")
self.load_water_availability_fw_cfs()
self.load_water_availability_hh_cfs()
self.load_water_availability_terr_cfs()
self.logger.info("Loading thermally polluted water characterization factors...")
self.load_thermally_polluted_water_cfs()
self.logger.info("Loading plastic physical effects on biota characterization factors...")
self.load_plastic_cfs()
self.logger.info("Loading fisheries impact characterization factors...")
self.load_fisheries_cfs()
self.logger.info("Harmonizing regionalized substances across indicators...")
self.harmonize_regionalized_substances()
self.logger.info("Applying rules...")
self.apply_rules()
self.logger.info("Treating regionalized factors...")
self.create_not_regio_flows()
self.create_regio_flows_for_not_regio_ic()
self.order_things_around()
self.logger.info("Managing biogenic carbon shenanigans...")
self.deal_with_biogenic_carbon()
self.deal_with_temporary_storage_of_carbon()
self.separate_ghg_indicators()
self.logger.info("Create non-regionalized version for ecoinvent...")
self.separate_regio_cfs()
self.logger.info("Linking to ecoinvent elementary flows...")
self.link_to_ecoinvent()
self.logger.info("Linking to SimaPro elementary flows...")
self.link_to_sp()
self.logger.info("Linking to openLCA elementary flows...")
self.link_to_olca()
self.logger.info("Linking to exiobase environmental extensions...")
self.link_to_exiobase()
self.logger.info("Prepare the footprint version...")
self.get_simplified_versions()
self.get_total_hh_and_eq()
def export_to_bw2(self):
"""
This method creates a brightway2 method with the IW+ characterization factors.
:param ei_flows_version: [str] Provide a specific ei version (e.g., 3.6) to be used to determine the elementary flows
to be linked to iw+. Default values = eiv3.8 (in 2022)
:return:
"""
self.logger.info("Exporting to brightway2...")
for project in self.bw2_projects:
bw2.projects.set_current(project)
bio = bw2.Database('biosphere3')
ei_version = project.split('ecoinvent')[1]
bw_flows_with_codes = (
pd.DataFrame(
[(i.as_dict()['name'], i.as_dict()['categories'][0], i.as_dict()['categories'][1],
i.as_dict()['code'])
if len(i.as_dict()['categories']) == 2
else (i.as_dict()['name'], i.as_dict()['categories'][0], 'unspecified', i.as_dict()['code'])
for i in bio],
columns=['Elem flow name', 'Compartment', 'Sub-compartment', 'code'])
)
if project == 'ecoinvent3.8':
ei_in_bw_normal = self.ei38_iw.merge(bw_flows_with_codes)
ei_in_bw_carbon_neutrality = self.ei38_iw_carbon_neutrality.merge(bw_flows_with_codes)
ei_in_bw_simple = self.simplified_version_ei38.merge(bw_flows_with_codes)
elif project == 'ecoinvent3.9':
ei_in_bw_normal = self.ei39_iw.merge(bw_flows_with_codes)
ei_in_bw_carbon_neutrality = self.ei39_iw_carbon_neutrality.merge(bw_flows_with_codes)
ei_in_bw_simple = self.simplified_version_ei39.merge(bw_flows_with_codes)
elif project == 'ecoinvent3.10':
ei_in_bw_normal = self.ei310_iw.merge(bw_flows_with_codes)
ei_in_bw_carbon_neutrality = self.ei310_iw_carbon_neutrality.merge(bw_flows_with_codes)
ei_in_bw_simple = self.simplified_version_ei310.merge(bw_flows_with_codes)
for ei_in_bw_format in ['normal', 'carbon neutrality']:
if ei_in_bw_format == 'normal':
ei_in_bw = ei_in_bw_normal
elif ei_in_bw_format == 'carbon neutrality':
ei_in_bw = ei_in_bw_carbon_neutrality
# create total HH and EQ categories
ei_in_bw.set_index(['Impact category', 'CF unit', 'code'], inplace=True)
total_hh = ei_in_bw.loc(axis=0)[:, 'DALY'].copy('deep')
total_hh = total_hh.groupby('code').agg({'Compartment': 'first',
'Sub-compartment': 'first',
'Elem flow name': 'first',
'CAS number': 'first',
'CF value': sum,
'Elem flow unit': 'first',
'MP or Damage': 'first',
'Native geographical resolution scale': 'first'})
total_hh.index = pd.MultiIndex.from_product([['Total human health'], ['DALY'], total_hh.index])
total_eq = ei_in_bw.loc(axis=0)[:, 'PDF.m2.yr'].copy('deep')
total_eq = total_eq.groupby('code').agg({'Compartment': 'first',
'Sub-compartment': 'first',
'Elem flow name': 'first',
'CAS number': 'first',
'CF value': sum,
'Elem flow unit': 'first',
'MP or Damage': 'first',
'Native geographical resolution scale': 'first'})
total_eq.index = pd.MultiIndex.from_product([['Total ecosystem quality'], ['PDF.m2.yr'], total_eq.index])
ei_in_bw = pd.concat([ei_in_bw, total_hh, total_eq])
ei_in_bw.index.names = ['Impact category', 'CF unit', 'code']
ei_in_bw = ei_in_bw.reset_index()
ei_in_bw.set_index(['Impact category', 'CF unit'], inplace=True)
impact_categories = ei_in_bw.index.drop_duplicates()
# -------------- For complete version of IW+ ----------------
for ic in impact_categories:
if ei_in_bw.loc[[ic], 'MP or Damage'].iloc[0] == 'Midpoint':
mid_end = 'Midpoint'
if ei_in_bw_format == 'normal':
name = ('IMPACT World+ ' + mid_end + ' ' + self.version + ' for ecoinvent v' +
ei_version + ' (incl. CO2 uptake)', 'Midpoint', ic[0])
elif ei_in_bw_format == 'carbon neutrality':
name = ('IMPACT World+ ' + mid_end + ' ' + self.version + ' for ecoinvent v' +
ei_version, 'Midpoint', ic[0])
else:
mid_end = 'Damage'
if ic[1] == 'DALY':
if ei_in_bw_format == 'normal':
name = ('IMPACT World+ ' + mid_end + ' ' + self.version + ' for ecoinvent v' +
ei_version + ' (incl. CO2 uptake)', 'Human health', ic[0])
elif ei_in_bw_format == 'carbon neutrality':
name = ('IMPACT World+ ' + mid_end + ' ' + self.version + ' for ecoinvent v' +
ei_version, 'Human health', ic[0])
else:
if ei_in_bw_format == 'normal':
name = ('IMPACT World+ ' + mid_end + ' ' + self.version + ' for ecoinvent v' +
ei_version + ' (incl. CO2 uptake)', 'Ecosystem quality', ic[0])
elif ei_in_bw_format == 'carbon neutrality':
name = ('IMPACT World+ ' + mid_end + ' ' + self.version + ' for ecoinvent v' +
ei_version, 'Ecosystem quality', ic[0])
# initialize the "Method" method
new_method = bw2.Method(name)
# register the new method
new_method.register()
# set its unit
new_method.metadata["unit"] = ic[1]
df = ei_in_bw.loc[[ic], ['code', 'CF value']].copy()
df.set_index('code', inplace=True)
data = []
for stressor in df.index:
data.append((('biosphere3', stressor), df.loc[stressor, 'CF value']))
new_method.write(data)
# -------------- For simplified version of IW+ ----------------
ei_in_bw_simple.set_index(['Impact category', 'CF unit'], inplace=True)
impact_categories_simple = ei_in_bw_simple.index.drop_duplicates()
for ic in impact_categories_simple:
name = ('IMPACT World+ Footprint ' + self.version + ' for ecoinvent v' + ei_version, ic[0])
# initialize the "Method" method
new_method = bw2.Method(name)
# register the new method
new_method.register()
# set its unit
new_method.metadata["unit"] = ic[1]
df = ei_in_bw_simple.loc[[ic], ['code', 'CF value']].copy()
df.set_index('code', inplace=True)
data = []
for stressor in df.index:
data.append((('biosphere3', stressor), df.loc[stressor, 'CF value']))
new_method.write(data)
def export_to_sp(self):
"""
This method creates the necessary information for the csv creation in SimaPro.
:return:
"""
self.logger.info("Exporting to SimaPro...")
# csv accepts strings only
self.iw_sp.loc[:, 'CF value'] = self.iw_sp.loc[:, 'CF value'].astype(str)
self.iw_sp_carbon_neutrality.loc[:, 'CF value'] = self.iw_sp_carbon_neutrality.loc[:, 'CF value'].astype(str)
self.simplified_version_sp.loc[:, 'CF value'] = self.simplified_version_sp.loc[:, 'CF value'].astype(str)
# Metadata
l = ['SimaPro 9.6', 'methods', 'Date: ' + datetime.now().strftime("%D"),
'Time: ' + datetime.now().strftime("%H:%M:%S"),
'Project: Methods', 'CSV Format version: 8.0.5', 'CSV separator: Semicolon',
'Decimal separator: .', 'Date separator: -', 'Short date format: yyyy-MM-dd', 'Selection: Selection (1)',
'Related objects (system descriptions, substances, units, etc.): Yes',
'Include sub product stages and processes: No', "Open library: 'Methods'"]
metadata = []
for i in l:
s = '{' + i + '}'
metadata.append([s, '', '', '', '', ''])
# metadata on the midpoint method
midpoint_method_metadata = [['Method', '', '', '', '', ''], ['', '', '', '', '', ''],
['Name', '', '', '', '', ''],
['IMPACT World+ Midpoint ' + self.version + ' (incl. CO2 uptake)', '', '', '', '', ''],
['', '', '', '', '', ''], ['Version', '', '', '', '', ''],
['2','1', '', '', '', ''],
['', '', '', '', '', ''], ['Comment', '', '', '', '', ''],
['IMPACT World+ Midpoint ' + self.version + ' (incl. CO2 uptake)' + chr(int("007F", 16)) + chr(int("007F", 16)) +
'New category:' + chr(int("007F", 16)) +
'- Plastics physical effect on biota' + chr(int("007F", 16)) +
chr(int("007F", 16)) +
'Updated categories:' + chr(int("007F", 16)) +
'- Climate change indicators with -1/+1 approach biogenic carbon' + chr(int("007F", 16)) +
'- Fossil and nuclear energy use'+chr(int("007F", 16)) +
'- Ozone layer depletion' + chr(int("007F", 16)) +
'- Particulate matter formation' + chr(int("007F", 16)) +
'- Photochemical ozone formation' + chr(int("007F", 16)) +
'- Water scarcity' + chr(int("007F", 16)) +
chr(int("007F", 16)) +
'For more information on IMPACT World+ and its methodology: https://www.impactworldplus.org.' + chr(int("007F", 16)) +
'Full list of changes available here: https://github.com/CIRAIG/IWP_Reborn/tree/master/Report_changes',
'', '', '', '', ''], ['', '', '', '', '', ''],
['Category', '', '', '', '', ''], ['Others', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Damage Assessment', '', '', '', '', ''], ['No', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Normalization', '', '', '', '', ''], ['No', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Weighting', '', '', '', '', ''], ['No', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Addition', '', '', '', '', ''], ['No', '', '', '', '', '']]
# metadata on the damage method
damage_method_metadata = [['Method', '', '', '', '', ''], ['', '', '', '', '', ''],
['Name', '', '', '', '', ''],
['IMPACT World+ Expert ' + self.version + ' (incl. CO2 uptake)', '', '', '', '', ''],
['', '', '', '', '', ''], ['Version', '', '', '', '', ''],
['2','1', '', '', '', ''],
['', '', '', '', '', ''], ['Comment', '', '', '', '', ''],
['IMPACT World+ Expert ' + self.version + ' (incl. CO2 uptake)' + chr(int("007F", 16)) + chr(int("007F", 16)) +
'New categories:' + chr(int("007F", 16)) + '- Marine ecotoxicity' + chr(int("007F", 16)) +
'- Terrestrial ecotoxicity' + chr(int("007F", 16)) + '- Fisheries' + chr(int("007F", 16)) +
'- Plastics physical effect on biota' + chr(int("007F", 16)) +
'- Phochemical ozone formation, ecosystem quality' + chr(int("007F", 16)) + chr(int("007F", 16)) +
'Updated categories:' + chr(int("007F", 16)) +
'- Climate change indicators with -1/+1 approach biogenic carbon' + chr(int("007F", 16)) +
'- Climate change damage indicators' + chr(int("007F", 16)) +
'- Ozone layer depletion' + chr(int("007F", 16)) +
'- Particulate matter formation' + chr(int("007F", 16)) +
'- Photochemical ozone formation' + chr(int("007F", 16)) +
'- Water availability, human health' + chr(int("007F", 16)) +
'- Water availability, terrestrial ecosystems' + chr(int("007F", 16))
+ chr(int("007F", 16)) +
'For more information on IMPACT World+ and its methodology: https://www.impactworldplus.org.' + chr(int("007F", 16)) +
'Full list of changes available here: https://github.com/CIRAIG/IWP_Reborn/tree/master/Report_changes',
'', '', '', '', ''], ['', '', '', '', '', ''],
['Category', '', '', '', '', ''], ['Others', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Damage Assessment', '', '', '', '', ''], ['Yes', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Normalization', '', '', '', '', ''], ['Yes', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Weighting', '', '', '', '', ''], ['Yes', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Addition', '', '', '', '', ''], ['Yes', '', '', '', '', '']]
# metadata on the combined method
combined_method_metadata = [['Method', '', '', '', '', ''], ['', '', '', '', '', ''],
['Name', '', '', '', '', ''],
['IMPACT World+ ' + self.version + ' (incl. CO2 uptake)', '', '', '', '', ''],
['', '', '', '', '', ''], ['Version', '', '', '', '', ''],
['2','1', '', '', '', ''],
['', '', '', '', '', ''], ['Comment', '', '', '', '', ''],
['IMPACT World+ ' + self.version + ' (incl. CO2 uptake)' + chr(int("007F", 16)) +
'New categories:' + chr(int("007F", 16)) +
'- Marine ecotoxicity' + chr(int("007F", 16)) +
'- Terrestrial ecotoxicity' + chr(int("007F", 16)) +
'- Fisheries' + chr(int("007F", 16)) +
'- Plastics physical effect on biota' + chr(int("007F", 16)) +
'- Phochemical ozone formation, ecosystem quality' + chr(int("007F", 16)) +
chr(int("007F", 16)) +
'Updated categories:' + chr(int("007F", 16)) +
'- Climate change indicators with -1/+1 approach biogenic carbon' + chr(int("007F", 16)) +
'- Climate change damage indicators' + chr(int("007F", 16)) +
'- Fossil and nuclear energy use' + chr(int("007F", 16)) +
'- Ozone layer depletion' + chr(int("007F", 16)) +
'- Particulate matter formation' + chr(int("007F", 16)) +
'- Photochemical ozone formation' + chr(int("007F", 16)) +
'- Water availability, human health' + chr(int("007F", 16)) +
'- Water availability, terrestrial ecosystems' + chr(int("007F", 16)) +
'- Water scarcity' + chr(int("007F", 16)) +
chr(int("007F", 16)) +
'For more information on IMPACT World+ and its methodology: https://www.impactworldplus.org.' + chr(int("007F", 16)) +
'Full list of changes available here: https://github.com/CIRAIG/IWP_Reborn/tree/master/Report_changes',
'', '', '', '', ''], ['', '', '', '', '', ''],
['Category', '', '', '', '', ''], ['Others', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Damage Assessment', '', '', '', '', ''], ['Yes', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Normalization', '', '', '', '', ''], ['Yes', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Weighting', '', '', '', '', ''], ['Yes', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Addition', '', '', '', '', ''], ['Yes', '', '', '', '', '']]
# metadata on the midpoint method
midpoint_method_metadata_carboneutrality = [['Method', '', '', '', '', ''], ['', '', '', '', '', ''],
['Name', '', '', '', '', ''],
['IMPACT World+ Midpoint ' + self.version, '', '', '', '', ''],
['', '', '', '', '', ''], ['Version', '', '', '', '', ''],
['2','1', '', '', '', ''],
['IMPACT World+ Midpoint ' + self.version + chr(int("007F", 16)) + chr(int("007F", 16)) +
'New category:' + chr(int("007F", 16)) +
'- Plastics physical effect on biota' + chr(int("007F", 16)) +
chr(int("007F", 16)) +
'Updated categories:' + chr(int("007F", 16)) +
'- Fossil and nuclear energy use'+chr(int("007F", 16)) +
'- Ozone layer depletion' + chr(int("007F", 16)) +
'- Particulate matter formation' + chr(int("007F", 16)) +
'- Photochemical ozone formation' + chr(int("007F", 16)) +
'- Water scarcity' + chr(int("007F", 16)) +
chr(int("007F", 16)) +
'For more information on IMPACT World+ and its methodology: https://www.impactworldplus.org.' + chr(int("007F", 16)) +
'Full list of changes available here: https://github.com/CIRAIG/IWP_Reborn/tree/master/Report_changes',
'', '', '', '', ''], ['', '', '', '', '', ''],
['Category', '', '', '', '', ''], ['Others', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Damage Assessment', '', '', '', '', ''], ['No', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Normalization', '', '', '', '', ''], ['No', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Weighting', '', '', '', '', ''], ['No', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Addition', '', '', '', '', ''], ['No', '', '', '', '', '']]
# metadata on the damage method
damage_method_metadata_carboneutrality = [['Method', '', '', '', '', ''], ['', '', '', '', '', ''],
['Name', '', '', '', '', ''],
['IMPACT World+ Expert ' + self.version, '', '', '', '', ''],
['', '', '', '', '', ''], ['Version', '', '', '', '', ''],
['2','1', '', '', '', ''],
['', '', '', '', '', ''], ['Comment', '', '', '', '', ''],
['IMPACT World+ Expert ' + self.version + chr(int("007F", 16)) + chr(int("007F", 16)) +
'New categories:' + chr(int("007F", 16)) + '- Marine ecotoxicity' + chr(int("007F", 16)) +
'- Terrestrial ecotoxicity' + chr(int("007F", 16)) + '- Fisheries' + chr(int("007F", 16)) +
'- Plastics physical effect on biota' + chr(int("007F", 16)) +
'- Phochemical ozone formation, ecosystem quality' + chr(int("007F", 16)) + chr(int("007F", 16)) +
'Updated categories:' + chr(int("007F", 16)) +
'- Climate change damage indicators' + chr(int("007F", 16)) +
'- Ozone layer depletion' + chr(int("007F", 16)) +
'- Particulate matter formation' + chr(int("007F", 16)) +
'- Photochemical ozone formation' + chr(int("007F", 16)) +
'- Water availability, human health' + chr(int("007F", 16)) +
'- Water availability, terrestrial ecosystems' + chr(int("007F", 16))
+ chr(int("007F", 16)) +
'For more information on IMPACT World+ and its methodology: https://www.impactworldplus.org.' + chr(int("007F", 16)) +
'Full list of changes available here: https://github.com/CIRAIG/IWP_Reborn/tree/master/Report_changes',
'', '', '', '', ''], ['', '', '', '', '', ''],
['Category', '', '', '', '', ''], ['Others', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Damage Assessment', '', '', '', '', ''], ['Yes', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Normalization', '', '', '', '', ''], ['Yes', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Weighting', '', '', '', '', ''], ['Yes', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Addition', '', '', '', '', ''], ['Yes', '', '', '', '', '']]
# metadata on the combined method
combined_method_metadata_carboneutrality = [['Method', '', '', '', '', ''], ['', '', '', '', '', ''],
['Name', '', '', '', '', ''],
['IMPACT World+ ' + self.version, '', '', '', '', ''],
['', '', '', '', '', ''], ['Version', '', '', '', '', ''],
['2','1', '', '', '', ''],
['', '', '', '', '', ''], ['Comment', '', '', '', '', ''],
['IMPACT World+ ' + self.version + chr(int("007F", 16)) +
'New categories:' + chr(int("007F", 16)) +
'- Marine ecotoxicity' + chr(int("007F", 16)) +
'- Terrestrial ecotoxicity' + chr(int("007F", 16)) +
'- Fisheries' + chr(int("007F", 16)) +
'- Plastics physical effect on biota' + chr(int("007F", 16)) +
'- Phochemical ozone formation, ecosystem quality' + chr(int("007F", 16)) +
chr(int("007F", 16)) +
'Updated categories:' + chr(int("007F", 16)) +
'- Climate change damage indicators' + chr(int("007F", 16)) +
'- Fossil and nuclear energy use' + chr(int("007F", 16)) +
'- Ozone layer depletion' + chr(int("007F", 16)) +
'- Particulate matter formation' + chr(int("007F", 16)) +
'- Photochemical ozone formation' + chr(int("007F", 16)) +
'- Water availability, human health' + chr(int("007F", 16)) +
'- Water availability, terrestrial ecosystems' + chr(int("007F", 16)) +
'- Water scarcity' + chr(int("007F", 16)) +
chr(int("007F", 16)) +
'For more information on IMPACT World+ and its methodology: https://www.impactworldplus.org.' + chr(int("007F", 16)) +
'Full list of changes available here: https://github.com/CIRAIG/IWP_Reborn/tree/master/Report_changes',
'', '', '', '', ''], ['', '', '', '', '', ''],
['Category', '', '', '', '', ''], ['Others', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Damage Assessment', '', '', '', '', ''], ['Yes', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Normalization', '', '', '', '', ''], ['Yes', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Weighting', '', '', '', '', ''], ['Yes', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Addition', '', '', '', '', ''], ['Yes', '', '', '', '', '']]
# metadata on the simplified method
simplified_method_metadata = [['Method', '', '', '', '', ''], ['', '', '', '', '', ''],
['Name', '', '', '', '', ''],
['IMPACT World+ Footprint ' + self.version, '', '', '', '', ''],
['', '', '', '', '', ''], ['Version', '', '', '', '', ''],
['2','1', '', '', '', ''],
['', '', '', '', '', ''], ['Comment', '', '', '', '', ''],
['IMPACT World+ Footprint ' + self.version + chr(int("007F", 16)) +
'Updated categories:' + chr(int("007F", 16)) +
'- Fossil and nuclear energy use' + chr(int("007F", 16)) +
'- Water footprint - Scarcity' + chr(int("007F", 16)) +
'- Human health (residual)' + chr(int("007F", 16)) +
'- Ecosystem quality (residual)' + chr(int("007F", 16)) +
'For details on what the footprint version of IW+ entails, please consult this page: '
'https://www.impactworldplus.org/version-2-0-1/' + chr(int("007F", 16)) +
'For more information on IMPACT World+ and its methodology: https://www.impactworldplus.org.' + chr(int("007F", 16)) +
'Full list of changes available here: https://github.com/CIRAIG/IWP_Reborn/tree/master/Report_changes',
'', '', '', '', ''], ['', '', '', '', '', ''],
['Category', '', '', '', '', ''], ['Others', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Damage Assessment', '', '', '', '', ''], ['No', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Normalization', '', '', '', '', ''], ['No', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Weighting', '', '', '', '', ''], ['No', '', '', '', '', ''],
['', '', '', '', '', ''],
['Use Addition', '', '', '', '', ''], ['No', '', '', '', '', '']]
# data for weighting and normalizing
df = pd.read_csv(pkg_resources.resource_filename(
__name__, '/Data/weighting_normalizing/weighting_and_normalization.csv'),
header=None, delimiter=';').fillna('')
weighting_info_damage_carboneutrality = [[df.loc[i].tolist()[0], df.loc[i].tolist()[1], '', '', '', ''] for i in df.index]
weighting_info_damage_carboneutrality[10] = ['Ionizing radiations, human health', '1.00E+00', '', '', '', '']
weighting_info_damage_carboneutrality[13] = ['Photochemical ozone formation, human health', '1.00E+00', '', '', '', '']
weighting_info_damage_carboneutrality.insert(22, ['Fisheries impact', '1.00E+00', '', '', '', ''])
weighting_info_damage_carboneutrality[27] = ['Ionizing radiations, ecosystem quality', '1.00E+00', '', '', '', '']
weighting_info_damage_carboneutrality.insert(32, ['Marine ecotoxicity, long term', '1.00E+00', '', '', '', ''])
weighting_info_damage_carboneutrality.insert(33, ['Marine ecotoxicity, short term', '1.00E+00', '', '', '', ''])
weighting_info_damage_carboneutrality.insert(35, ['Photochemical ozone formation, ecosystem quality', '1.00E+00', '', '', '', ''])
weighting_info_damage_carboneutrality.insert(36, ['Plastics physical effects on biota', '1.00E+00', '', '', '', ''])
weighting_info_damage_carboneutrality.insert(38, ['Terrestrial ecotoxicity, long term', '1.00E+00', '', '', '', ''])
weighting_info_damage_carboneutrality.insert(39, ['Terrestrial ecotoxicity, short term', '1.00E+00', '', '', '', ''])
weighting_info_combined_carboneutrality = weighting_info_damage_carboneutrality.copy()
weighting_info_combined_carboneutrality[11] = ['Ozone layer depletion (damage)', '1.00E+00', '', '', '', '']
weighting_info_combined_carboneutrality[12] = ['Particulate matter formation (damage)', '1.00E+00', '', '', '', '']
weighting_info_combined_carboneutrality[23] = ['Freshwater acidification (damage)', '1.00E+00', '', '', '', '']
weighting_info_combined_carboneutrality[26] = ['Freshwater eutrophication (damage)', '1.00E+00', '', '', '', '']
weighting_info_combined_carboneutrality[28] = ['Land occupation, biodiversity (damage)', '1.00E+00', '', '', '', '']
weighting_info_combined_carboneutrality[29] = ['Land transformation, biodiversity (damage)', '1.00E+00', '', '', '', '']
weighting_info_combined_carboneutrality[34] = ['Marine eutrophication (damage)', '1.00E+00', '', '', '', '']
weighting_info_combined_carboneutrality[36] = ['Plastics physical effects on biota (damage)', '1.00E+00', '', '', '', '']
weighting_info_combined_carboneutrality[37] = ['Terrestrial acidification (damage)', '1.00E+00', '', '', '', '']
weighting_info_damage = [[df.loc[i].tolist()[0], df.loc[i].tolist()[1], '', '', '', ''] for i in df.index]
weighting_info_damage[4] = ['Climate change, HH, LT, fossil', '1.00E+00', '', '', '', '']
weighting_info_damage[5] = ['Climate change, HH, ST, fossil', '1.00E+00', '', '', '', '']
weighting_info_damage[10] = ['Ionizing radiations, human health', '1.00E+00', '', '', '', '']
weighting_info_damage[13] = ['Photochemical ozone formation, human health', '1.00E+00', '', '', '', '']
weighting_info_damage[20] = ['Climate change, EQ, LT, fossil', '1.00E+00', '', '', '', '']
weighting_info_damage[21] = ['Climate change, EQ, ST, fossil', '1.00E+00', '', '', '', '']
weighting_info_damage.insert(22, ['Fisheries impact', '1.00E+00', '', '', '', ''])
weighting_info_damage[27] = ['Ionizing radiations, ecosystem quality', '1.00E+00', '', '', '', '']
weighting_info_damage.insert(32, ['Marine ecotoxicity, long term', '1.00E+00', '', '', '', ''])
weighting_info_damage.insert(33, ['Marine ecotoxicity, short term', '1.00E+00', '', '', '', ''])
weighting_info_damage.insert(35, ['Photochemical ozone formation, ecosystem quality', '1.00E+00', '', '', '', ''])
weighting_info_damage.insert(36, ['Plastics physical effects on biota', '1.00E+00', '', '', '', ''])
weighting_info_damage.insert(38, ['Terrestrial ecotoxicity, long term', '1.00E+00', '', '', '', ''])
weighting_info_damage.insert(39, ['Terrestrial ecotoxicity, short term', '1.00E+00', '', '', '', ''])
weighting_info_damage.insert(6, ['Climate change, HH, LT, biogenic', '1.00E+00', '', '', '', ''])
weighting_info_damage.insert(7, ['Climate change, HH, ST, biogenic', '1.00E+00', '', '', '', ''])
weighting_info_damage.insert(8, ['Climate change, HH, LT, CO2 uptake', '1.00E+00', '', '', '', ''])
weighting_info_damage.insert(9, ['Climate change, HH, ST, CO2 uptake', '1.00E+00', '', '', '', ''])
weighting_info_damage.insert(10, ['Climate change, HH, LT, land transformation', '1.00E+00', '', '', '', ''])
weighting_info_damage.insert(11, ['Climate change, HH, ST, land transformation', '1.00E+00', '', '', '', ''])
weighting_info_damage.insert(28, ['Climate change, EQ, LT, biogenic', '1.00E+00', '', '', '', ''])
weighting_info_damage.insert(29, ['Climate change, EQ, ST, biogenic', '1.00E+00', '', '', '', ''])
weighting_info_damage.insert(30, ['Climate change, EQ, LT, CO2 uptake', '1.00E+00', '', '', '', ''])
weighting_info_damage.insert(31, ['Climate change, EQ, ST, CO2 uptake', '1.00E+00', '', '', '', ''])
weighting_info_damage.insert(32, ['Climate change, EQ, LT, land transformation', '1.00E+00', '', '', '', ''])
weighting_info_damage.insert(33, ['Climate change, EQ, ST, land transformation', '1.00E+00', '', '', '', ''])
weighting_info_combined = weighting_info_damage.copy()
weighting_info_combined[17] = ['Ozone layer depletion (damage)', '1.00E+00', '', '', '', '']
weighting_info_combined[18] = ['Particulate matter formation (damage)', '1.00E+00', '', '', '', '']
weighting_info_combined[35] = ['Freshwater acidification (damage)', '1.00E+00', '', '', '', '']
weighting_info_combined[38] = ['Freshwater eutrophication (damage)', '1.00E+00', '', '', '', '']
weighting_info_combined[40] = ['Land occupation, biodiversity (damage)', '1.00E+00', '', '', '', '']
weighting_info_combined[41] = ['Land transformation, biodiversity (damage)', '1.00E+00', '', '', '', '']
weighting_info_combined[46] = ['Marine eutrophication (damage)', '1.00E+00', '', '', '', '']
weighting_info_combined[48] = ['Plastics physical effects on biota (damage)', '1.00E+00', '', '', '', '']
weighting_info_combined[49] = ['Terrestrial acidification (damage)', '1.00E+00', '', '', '', '']
# extracting midpoint CFs
d_ic_unit = self.iw_sp.loc[self.iw_sp['MP or Damage'] == 'Midpoint',
['Impact category', 'CF unit']].drop_duplicates().set_index('Impact category').iloc[:,
0].to_dict()
midpoint_values = []
for j in d_ic_unit.keys():
midpoint_values.append(['', '', '', '', '', ''])
midpoint_values.append(['Impact category', '', '', '', '', ''])
midpoint_values.append([j, d_ic_unit[j], '', '', '', ''])
midpoint_values.append(['', '', '', '', '', ''])
midpoint_values.append(['Substances', '', '', '', '', ''])
df = self.iw_sp[self.iw_sp['Impact category'] == j]
df = df[df['CF unit'] == d_ic_unit[j]]
df = df[['Compartment', 'Sub-compartment', 'Elem flow name', 'CAS number', 'CF value', 'Elem flow unit']]
for i in df.index:
if type(df.loc[i, 'CAS number']) == float:
df.loc[i, 'CAS number'] = ''
midpoint_values.append(df.loc[i].tolist())
d_ic_unit = self.iw_sp_carbon_neutrality.loc[self.iw_sp_carbon_neutrality['MP or Damage'] == 'Midpoint',
['Impact category', 'CF unit']].drop_duplicates().set_index('Impact category').iloc[:,
0].to_dict()
midpoint_values_carboneutrality = []
for j in d_ic_unit.keys():
midpoint_values_carboneutrality.append(['', '', '', '', '', ''])
midpoint_values_carboneutrality.append(['Impact category', '', '', '', '', ''])
midpoint_values_carboneutrality.append([j, d_ic_unit[j], '', '', '', ''])
midpoint_values_carboneutrality.append(['', '', '', '', '', ''])
midpoint_values_carboneutrality.append(['Substances', '', '', '', '', ''])
df = self.iw_sp_carbon_neutrality[self.iw_sp_carbon_neutrality['Impact category'] == j]
df = df[df['CF unit'] == d_ic_unit[j]]
df = df[['Compartment', 'Sub-compartment', 'Elem flow name', 'CAS number', 'CF value', 'Elem flow unit']]
for i in df.index:
if type(df.loc[i, 'CAS number']) == float:
df.loc[i, 'CAS number'] = ''
midpoint_values_carboneutrality.append(df.loc[i].tolist())
# extracting damage CFs
d_ic_unit = self.iw_sp.loc[self.iw_sp['MP or Damage'] == 'Damage',
['Impact category', 'CF unit']].drop_duplicates().set_index('Impact category').iloc[:,
0].to_dict()
damage_values = []
for j in d_ic_unit.keys():
damage_values.append(['', '', '', '', '', ''])
damage_values.append(['Impact category', '', '', '', '', ''])
damage_values.append([j, d_ic_unit[j], '', '', '', ''])
damage_values.append(['', '', '', '', '', ''])
damage_values.append(['Substances', '', '', '', '', ''])
df = self.iw_sp[self.iw_sp['Impact category'] == j]
df = df[df['CF unit'] == d_ic_unit[j]]
df = df[['Compartment', 'Sub-compartment', 'Elem flow name', 'CAS number', 'CF value', 'Elem flow unit']]
for i in df.index:
if type(df.loc[i, 'CAS number']) == float:
df.loc[i, 'CAS number'] = ''
damage_values.append(df.loc[i].tolist())
d_ic_unit = self.iw_sp_carbon_neutrality.loc[self.iw_sp_carbon_neutrality['MP or Damage'] == 'Damage',
['Impact category', 'CF unit']].drop_duplicates().set_index('Impact category').iloc[:,
0].to_dict()
damage_values_carboneutrality = []
for j in d_ic_unit.keys():
damage_values_carboneutrality.append(['', '', '', '', '', ''])
damage_values_carboneutrality.append(['Impact category', '', '', '', '', ''])
damage_values_carboneutrality.append([j, d_ic_unit[j], '', '', '', ''])
damage_values_carboneutrality.append(['', '', '', '', '', ''])
damage_values_carboneutrality.append(['Substances', '', '', '', '', ''])
df = self.iw_sp_carbon_neutrality[self.iw_sp_carbon_neutrality['Impact category'] == j]
df = df[df['CF unit'] == d_ic_unit[j]]
df = df[['Compartment', 'Sub-compartment', 'Elem flow name', 'CAS number', 'CF value', 'Elem flow unit']]
for i in df.index:
if type(df.loc[i, 'CAS number']) == float:
df.loc[i, 'CAS number'] = ''
damage_values_carboneutrality.append(df.loc[i].tolist())
# extracting combined CFs
ic_unit = self.iw_sp.loc[:, ['Impact category', 'CF unit']].drop_duplicates()
same_names = ['Freshwater acidification','Freshwater eutrophication','Land occupation, biodiversity',
'Land transformation, biodiversity','Marine eutrophication','Ozone layer depletion',
'Particulate matter formation','Terrestrial acidification',
'Plastics physical effects on biota']
combined_values = []
for j in ic_unit.index:
combined_values.append(['', '', '', '', '', ''])
combined_values.append(['Impact category', '', '', '', '', ''])
if ic_unit.loc[j,'Impact category'] in same_names:
if ic_unit.loc[j,'CF unit'] in ['DALY','PDF.m2.yr']:
combined_values.append([ic_unit.loc[j,'Impact category']+' (damage)',
ic_unit.loc[j,'CF unit'], '', '', '', ''])
else:
combined_values.append([ic_unit.loc[j,'Impact category']+' (midpoint)',
ic_unit.loc[j,'CF unit'], '', '', '', ''])
else:
combined_values.append([ic_unit.loc[j, 'Impact category'],
ic_unit.loc[j, 'CF unit'], '', '', '', ''])
combined_values.append(['', '', '', '', '', ''])
combined_values.append(['Substances', '', '', '', '', ''])
df = self.iw_sp.loc[[i for i in self.iw_sp.index if (
self.iw_sp.loc[i,'Impact category'] == ic_unit.loc[j,'Impact category'] and
self.iw_sp.loc[i, 'CF unit'] == ic_unit.loc[j, 'CF unit'])]]
df = df[['Compartment', 'Sub-compartment', 'Elem flow name', 'CAS number', 'CF value', 'Elem flow unit']]
for i in df.index:
if type(df.loc[i, 'CAS number']) == float:
df.loc[i, 'CAS number'] = ''
combined_values.append(df.loc[i].tolist())
ic_unit = self.iw_sp_carbon_neutrality.loc[:, ['Impact category', 'CF unit']].drop_duplicates()
same_names = ['Freshwater acidification','Freshwater eutrophication','Land occupation, biodiversity',
'Land transformation, biodiversity','Marine eutrophication','Ozone layer depletion',
'Particulate matter formation','Terrestrial acidification',
'Plastics physical effects on biota']
combined_values_carboneutrality = []
for j in ic_unit.index:
combined_values_carboneutrality.append(['', '', '', '', '', ''])
combined_values_carboneutrality.append(['Impact category', '', '', '', '', ''])
if ic_unit.loc[j,'Impact category'] in same_names:
if ic_unit.loc[j,'CF unit'] in ['DALY','PDF.m2.yr']:
combined_values_carboneutrality.append([ic_unit.loc[j,'Impact category']+' (damage)',
ic_unit.loc[j,'CF unit'], '', '', '', ''])
else:
combined_values_carboneutrality.append([ic_unit.loc[j,'Impact category']+' (midpoint)',
ic_unit.loc[j,'CF unit'], '', '', '', ''])
else:
combined_values_carboneutrality.append([ic_unit.loc[j, 'Impact category'],
ic_unit.loc[j, 'CF unit'], '', '', '', ''])
combined_values_carboneutrality.append(['', '', '', '', '', ''])
combined_values_carboneutrality.append(['Substances', '', '', '', '', ''])
df = self.iw_sp_carbon_neutrality.loc[[i for i in self.iw_sp_carbon_neutrality.index if (
self.iw_sp_carbon_neutrality.loc[i,'Impact category'] == ic_unit.loc[j,'Impact category'] and
self.iw_sp_carbon_neutrality.loc[i, 'CF unit'] == ic_unit.loc[j, 'CF unit'])]]
df = df[['Compartment', 'Sub-compartment', 'Elem flow name', 'CAS number', 'CF value', 'Elem flow unit']]
for i in df.index:
if type(df.loc[i, 'CAS number']) == float:
df.loc[i, 'CAS number'] = ''
combined_values_carboneutrality.append(df.loc[i].tolist())
# extracting simplified values
ic_unit = self.simplified_version_sp.loc[:, ['Impact category', 'CF unit']].drop_duplicates()
simplified_values = []
for j in ic_unit.index:
simplified_values.append(['', '', '', '', '', ''])
simplified_values.append(['Impact category', '', '', '', '', ''])
simplified_values.append([ic_unit.loc[j, 'Impact category'],
ic_unit.loc[j, 'CF unit'], '', '', '', ''])
simplified_values.append(['', '', '', '', '', ''])
simplified_values.append(['Substances', '', '', '', '', ''])
df = self.simplified_version_sp.loc[[i for i in self.simplified_version_sp.index if (
self.simplified_version_sp.loc[i, 'Impact category'] == ic_unit.loc[j, 'Impact category'] and
self.simplified_version_sp.loc[i, 'CF unit'] == ic_unit.loc[j, 'CF unit'])]]
df = df[['Compartment', 'Sub-compartment', 'Elem flow name', 'CAS number', 'CF value', 'Elem flow unit']]
for i in df.index:
simplified_values.append(df.loc[i].tolist())
# dump everything in an attribute
self.sp_data = {'metadata': metadata, 'midpoint_method_metadata': midpoint_method_metadata,
'damage_method_metadata': damage_method_metadata,
'combined_method_metadata': combined_method_metadata,
'simplified_method_metadata': simplified_method_metadata,
'weighting_info_damage': weighting_info_damage,
'weighting_info_combined': weighting_info_combined,
'weighting_info_damage_carboneutrality': weighting_info_damage_carboneutrality,
'weighting_info_combined_carboneutrality': weighting_info_combined_carboneutrality,
'midpoint_values': midpoint_values, 'damage_values': damage_values,
'combined_values': combined_values, 'simplified_values': simplified_values,
'midpoint_method_metadata_carboneutrality': midpoint_method_metadata_carboneutrality,
'damage_method_metadata_carboneutrality': damage_method_metadata_carboneutrality,
'combined_method_metadata_carboneutrality': combined_method_metadata_carboneutrality,
'midpoint_values_carboneutrality': midpoint_values_carboneutrality,
'damage_values_carboneutrality': damage_values_carboneutrality,
'combined_values_carboneutrality': combined_values_carboneutrality}
def export_to_olca(self):
"""
This method creates the necessary information for the creation of json files in openLCA.
:return:
"""
self.logger.info("Exporting to openLCA...")
# --------------------- GENERAL METADATA OF IW+ ------------------------
id_category = str(uuid.uuid4())
category_metadata = {"@context": "http://greendelta.github.io/olca-schema/context.jsonld",
"@type": "Category",
"@id": id_category,
"name": "IMPACT World+",
"version": "2.1",
"modelType": "IMPACT_METHOD"}
# -----------------------IW+ VERSION METADATA --------------------------
category_names = {(i[0], i[1]): str(uuid.uuid4()) for i in
set(list(zip(self.olca_iw.loc[:, 'Impact category'], self.olca_iw.loc[:, 'CF unit'])))}
category_names_damage = {k: v for k, v in category_names.items() if k[1] in ['DALY', 'PDF.m2.yr']}
category_names_midpoint = {k: v for k, v in category_names.items() if k[1] not in ['DALY', 'PDF.m2.yr']}
category_names_footprint = {(i[0], i[1]): str(uuid.uuid4()) for i in set(list(
zip(self.simplified_version_olca.loc[:, 'Impact category'],
self.simplified_version_olca.loc[:, 'CF unit'])))}
category_names_carboneutrality = {(i[0], i[1]): str(uuid.uuid4()) for i in
set(list(zip(self.olca_iw_carbon_neutrality.loc[:, 'Impact category'],
self.olca_iw_carbon_neutrality.loc[:, 'CF unit'])))}
category_names_damage_carboneutrality = {k: v for k, v in category_names_carboneutrality.items() if
k[1] in ['DALY', 'PDF.m2.yr']}
category_names_midpoint_carboneutrality = {k: v for k, v in category_names_carboneutrality.items() if
k[1] not in ['DALY', 'PDF.m2.yr']}
# need to differentiate midpoint from endpoint with the names of the categories
category_names_combined = {}
for category in category_names:
if category[1] in ['DALY', 'PDF.m2.yr']:
category_names_combined[(category[0] + ' (damage)', category[1])] = category_names[category]
else:
category_names_combined[(category[0] + ' (midpoint)', category[1])] = category_names[category]
category_names_combined_carboneutrality = {}
for category in category_names_carboneutrality:
if category[1] in ['DALY', 'PDF.m2.yr']:
category_names_combined_carboneutrality[(category[0] + ' (damage)', category[1])] = \
category_names_carboneutrality[category]
else:
category_names_combined_carboneutrality[(category[0] + ' (midpoint)', category[1])] = \
category_names_carboneutrality[category]
id_iw_damage = str(uuid.uuid4())
id_iw_midpoint = str(uuid.uuid4())
id_iw_footprint = str(uuid.uuid4())
id_iw_combined = str(uuid.uuid4())
norm_weight_id = str(uuid.uuid4())
norm_weight_id_carboneutrality = str(uuid.uuid4())
id_iw_damage_carboneutrality = str(uuid.uuid4())
id_iw_midpoint_carboneutrality = str(uuid.uuid4())
id_iw_combined_carboneutrality = str(uuid.uuid4())
metadata_iw_damage = {
"@context": "http://greendelta.github.io/olca-schema/context.jsonld",
"@type": "ImpactMethod",
"@id": id_iw_damage,
"name": "IMPACT World+ Expert v" + self.version + ' (incl. CO2 uptake)',
"lastChange": "2024-09-15T17:25:43.725-05:00",
"category": {
"@type": "Category",
"@id": id_category,
"name": "IMPACT World+",
"categoryType": "ImpactMethod"},
'impactCategories': [],
'nwSets': [{
"@type": "NwSet",
"@id": norm_weight_id,
"name": "IMPACT World+ (Stepwise 2006 values)"
}]
}
metadata_iw_midpoint = {
"@context": "http://greendelta.github.io/olca-schema/context.jsonld",
"@type": "ImpactMethod",
"@id": id_iw_midpoint,
"name": "IMPACT World+ Midpoint v" + self.version + ' (incl. CO2 uptake)',
"lastChange": "2024-09-15T17:25:43.725-05:00",
"category": {
"@type": "Category",
"@id": id_category,
"name": "IMPACT World+",
"categoryType": "ImpactMethod"},
'impactCategories': []
}
metadata_iw_footprint = {
"@context": "http://greendelta.github.io/olca-schema/context.jsonld",
"@type": "ImpactMethod",
"@id": id_iw_footprint,
"name": "IMPACT World+ Footprint v" + self.version,
"lastChange": "2024-09-15T17:25:43.725-05:00",
"category": {
"@type": "Category",
"@id": id_category,
"name": "CIRAIG methods",
"categoryType": "ImpactMethod"},
'impactCategories': []
}
metadata_iw_combined = {
"@context": "http://greendelta.github.io/olca-schema/context.jsonld",
"@type": "ImpactMethod",
"@id": id_iw_combined,
"name": "IMPACT World+ Combined v" + self.version + ' (incl. CO2 uptake)',
"lastChange": "2024-09-15T17:25:43.725-05:00",
"category": {
"@type": "Category",
"@id": id_category,
"name": "IMPACT World+",
"categoryType": "ImpactMethod"},
'impactCategories': [],
'nwSets': [{
"@type": "NwSet",
"@id": norm_weight_id,
"name": "IMPACT World+ (Stepwise 2006 values)"
}]
}
metadata_iw_damage_carboneutrality = {
"@context": "http://greendelta.github.io/olca-schema/context.jsonld",
"@type": "ImpactMethod",
"@id": id_iw_damage_carboneutrality,
"name": "IMPACT World+ Expert v" + self.version,
"lastChange": "2024-09-15T17:25:43.725-05:00",
"category": {
"@type": "Category",
"@id": id_category,
"name": "IMPACT World+",
"categoryType": "ImpactMethod"},
'impactCategories': [],
'nwSets': [{
"@type": "NwSet",
"@id": norm_weight_id,
"name": "IMPACT World+ (Stepwise 2006 values)"
}]
}
metadata_iw_midpoint_carboneutrality = {
"@context": "http://greendelta.github.io/olca-schema/context.jsonld",
"@type": "ImpactMethod",
"@id": id_iw_midpoint_carboneutrality,
"name": "IMPACT World+ Midpoint v" + self.version,
"lastChange": "2024-09-15T17:25:43.725-05:00",
"category": {
"@type": "Category",
"@id": id_category,
"name": "IMPACT World+",
"categoryType": "ImpactMethod"},
'impactCategories': []
}