@@ -57,7 +57,7 @@ def __init__(self, trade_database_path, regioinvent_database_name, bw_project_na
5757 self .regioinvent_database_name = regioinvent_database_name
5858 self .ecoinvent_database_name = ecoinvent_database_name
5959 self .name_ei_with_regionalized_biosphere = ecoinvent_database_name + ' regionalized'
60- self .name_regionalized_biosphere_database = 'biosphere3_spatialized_flows'
60+ self .name_spatialized_biosphere = 'biosphere3_spatialized_flows'
6161 self .cutoff = cutoff
6262 self .regio_bio = regionalized_elementary_flows
6363 self .trade_conn = sqlite3 .connect (trade_database_path )
@@ -164,7 +164,7 @@ def __init__(self, trade_database_path, regioinvent_database_name, bw_project_na
164164 'Phosphorus, total' ]
165165
166166 if self .regio_bio :
167- if self .name_regionalized_biosphere_database not in bw2 .databases :
167+ if self .name_spatialized_biosphere not in bw2 .databases :
168168 self .logger .info ("Creating regionalized biosphere flows..." )
169169 self .create_regionalized_biosphere_flows ()
170170 if 'IMPACT World+ Damage 2.0.1_regionalized' not in [i [0 ] for i in list (bw2 .methods )]:
@@ -200,7 +200,7 @@ def create_regionalized_biosphere_flows(self):
200200 with open (pkg_resources .resource_filename (__name__ , '/Data/regionalized_biosphere_database.pickle' ), 'rb' ) as f :
201201 regionalized_biosphere = pickle .load (f )
202202
203- bw2 .Database (self .name_regionalized_biosphere_database ).write (regionalized_biosphere )
203+ bw2 .Database (self .name_spatialized_biosphere ).write (regionalized_biosphere )
204204
205205 def importing_impact_world_plus (self ):
206206 """
@@ -219,9 +219,9 @@ def create_ecoinvent_with_regionalized_biosphere_flows(self):
219219 self .logger .info ("Regionalizing the biosphere inputs of the original ecoinvent database..." )
220220
221221 base_regionalized_flows = set ([', ' .join (i .as_dict ()['name' ].split (', ' )[:- 1 ]) for i in
222- bw2 .Database (self .name_regionalized_biosphere_database )])
222+ bw2 .Database (self .name_spatialized_biosphere )])
223223 regionalized_flows = {(i .as_dict ()['name' ], i .as_dict ()['categories' ]): i .as_dict ()['code' ] for i in
224- bw2 .Database (self .name_regionalized_biosphere_database )}
224+ bw2 .Database (self .name_spatialized_biosphere )}
225225 ei_iw_geo_mapping = pd .read_excel (pkg_resources .resource_filename (
226226 __name__ , '/Data/ei_iw_geo_mapping.xlsx' )).fillna ('NA' ).set_index ('ecoinvent' )
227227
@@ -238,7 +238,7 @@ def create_ecoinvent_with_regionalized_biosphere_flows(self):
238238 exc ['code' ] = regionalized_flows [(
239239 exc ['name' ] + ', ' + ei_iw_geo_mapping .loc [process ['location' ], 'water' ],
240240 exc ['categories' ])]
241- exc ['database' ] = self .name_regionalized_biosphere_database
241+ exc ['database' ] = self .name_spatialized_biosphere
242242 exc ['name' ] = exc ['name' ] + ', ' + ei_iw_geo_mapping .loc [process ['location' ], 'water' ]
243243 exc ['input' ] = (exc ['database' ], exc ['code' ])
244244 elif 'Occupation' in exc ['name' ] or 'Transformation' in exc ['name' ]:
@@ -247,12 +247,12 @@ def create_ecoinvent_with_regionalized_biosphere_flows(self):
247247 exc ['code' ] = regionalized_flows [(
248248 exc ['name' ] + ', ' + ei_iw_geo_mapping .loc [process ['location' ], 'land' ],
249249 exc ['categories' ])]
250- exc ['database' ] = self .name_regionalized_biosphere_database
250+ exc ['database' ] = self .name_spatialized_biosphere
251251 exc ['name' ] = exc ['name' ] + ', ' + ei_iw_geo_mapping .loc [process ['location' ], 'land' ]
252252 exc ['input' ] = (exc ['database' ], exc ['code' ])
253253 elif (exc ['name' ] + ', GLO' , exc ['categories' ]) in regionalized_flows .keys ():
254254 exc ['code' ] = regionalized_flows [(exc ['name' ] + ', GLO' , exc ['categories' ])]
255- exc ['database' ] = self .name_regionalized_biosphere_database
255+ exc ['database' ] = self .name_spatialized_biosphere
256256 exc ['name' ] = exc ['name' ] + ', GLO'
257257 exc ['input' ] = (exc ['database' ], exc ['code' ])
258258 elif exc ['name' ] in ['BOD5, Biological Oxygen Demand' , 'COD, Chemical Oxygen Demand' ,
@@ -262,7 +262,7 @@ def create_ecoinvent_with_regionalized_biosphere_flows(self):
262262 exc ['code' ] = regionalized_flows [(
263263 exc ['name' ] + ', ' + ei_iw_geo_mapping .loc [process ['location' ], 'eutro' ],
264264 exc ['categories' ])]
265- exc ['database' ] = self .name_regionalized_biosphere_database
265+ exc ['database' ] = self .name_spatialized_biosphere
266266 exc ['name' ] = exc ['name' ] + ', ' + ei_iw_geo_mapping .loc [process ['location' ], 'eutro' ]
267267 exc ['input' ] = (exc ['database' ], exc ['code' ])
268268 else :
@@ -271,7 +271,7 @@ def create_ecoinvent_with_regionalized_biosphere_flows(self):
271271 exc ['code' ] = regionalized_flows [(
272272 exc ['name' ] + ', ' + ei_iw_geo_mapping .loc [process ['location' ], 'acid' ],
273273 exc ['categories' ])]
274- exc ['database' ] = self .name_regionalized_biosphere_database
274+ exc ['database' ] = self .name_spatialized_biosphere
275275 exc ['name' ] = exc ['name' ] + ', ' + ei_iw_geo_mapping .loc [process ['location' ], 'acid' ]
276276 exc ['input' ] = (exc ['database' ], exc ['code' ])
277277 else :
@@ -789,6 +789,10 @@ def second_order_regionalization(self):
789789 replace_process = self .ei_in_dict [(
790790 exc ['product' ], magic_plumbering_geographies [process ['location' ]][1 ],
791791 'market for tap water' )]
792+ if exc ['name' ] == 'market group for irrigation' :
793+ replace_process = self .ei_in_dict [(
794+ exc ['product' ], magic_plumbering_geographies [process ['location' ]][1 ],
795+ 'market for irrigation' )]
792796 exc ['code' ] = replace_process ['code' ]
793797 exc ['name' ] = replace_process ['name' ]
794798 exc ['product' ] = replace_process ['reference product' ]
@@ -847,9 +851,9 @@ def regionalize_elem_flows(self):
847851 self .logger .info ("Regionalizing the elementary flows of the regioinvent database..." )
848852
849853 base_regionalized_flows = set ([', ' .join (i .as_dict ()['name' ].split (', ' )[:- 1 ]) for i in
850- bw2 .Database (self .name_regionalized_biosphere_database )])
854+ bw2 .Database (self .name_spatialized_biosphere )])
851855 regionalized_flows = {(i .as_dict ()['name' ], i .as_dict ()['categories' ]): i .as_dict ()['code' ] for i in
852- bw2 .Database (self .name_regionalized_biosphere_database )}
856+ bw2 .Database (self .name_spatialized_biosphere )}
853857 regio_iw_geo_mapping = pd .read_excel (pkg_resources .resource_filename (
854858 __name__ , '/Data/regio_iw_geo_mapping.xlsx' )).fillna ('NA' ).set_index ('regioinvent' )
855859
@@ -864,7 +868,7 @@ def regionalize_elem_flows(self):
864868 exc ['code' ] = regionalized_flows [(
865869 exc ['name' ] + ', ' + regio_iw_geo_mapping .loc [process ['location' ], 'water' ],
866870 exc ['categories' ])]
867- exc ['database' ] = self .name_regionalized_biosphere_database
871+ exc ['database' ] = self .name_spatialized_biosphere
868872 exc ['name' ] = exc ['name' ] + ', ' + regio_iw_geo_mapping .loc [
869873 process ['location' ], 'water' ]
870874 exc ['input' ] = (exc ['database' ], exc ['code' ])
@@ -874,12 +878,12 @@ def regionalize_elem_flows(self):
874878 exc ['code' ] = regionalized_flows [(
875879 exc ['name' ] + ', ' + regio_iw_geo_mapping .loc [process ['location' ], 'land' ],
876880 exc ['categories' ])]
877- exc ['database' ] = self .name_regionalized_biosphere_database
881+ exc ['database' ] = self .name_spatialized_biosphere
878882 exc ['name' ] = exc ['name' ] + ', ' + regio_iw_geo_mapping .loc [process ['location' ], 'land' ]
879883 exc ['input' ] = (exc ['database' ], exc ['code' ])
880884 elif (exc ['name' ] + ', GLO' , exc ['categories' ]) in regionalized_flows .keys ():
881885 exc ['code' ] = regionalized_flows [(exc ['name' ] + ', GLO' , exc ['categories' ])]
882- exc ['database' ] = self .name_regionalized_biosphere_database
886+ exc ['database' ] = self .name_spatialized_biosphere
883887 exc ['name' ] = exc ['name' ] + ', GLO'
884888 exc ['input' ] = (exc ['database' ], exc ['code' ])
885889 elif exc ['name' ] in ['BOD5, Biological Oxygen Demand' , 'COD, Chemical Oxygen Demand' ,
@@ -889,7 +893,7 @@ def regionalize_elem_flows(self):
889893 exc ['code' ] = regionalized_flows [(
890894 exc ['name' ] + ', ' + regio_iw_geo_mapping .loc [process ['location' ], 'eutro' ],
891895 exc ['categories' ])]
892- exc ['database' ] = self .name_regionalized_biosphere_database
896+ exc ['database' ] = self .name_spatialized_biosphere
893897 exc ['name' ] = exc ['name' ] + ', ' + regio_iw_geo_mapping .loc [
894898 process ['location' ], 'eutro' ]
895899 exc ['input' ] = (exc ['database' ], exc ['code' ])
@@ -899,7 +903,7 @@ def regionalize_elem_flows(self):
899903 exc ['code' ] = regionalized_flows [(
900904 exc ['name' ] + ', ' + regio_iw_geo_mapping .loc [process ['location' ], 'acid' ],
901905 exc ['categories' ])]
902- exc ['database' ] = self .name_regionalized_biosphere_database
906+ exc ['database' ] = self .name_spatialized_biosphere
903907 exc ['name' ] = exc ['name' ] + ', ' + regio_iw_geo_mapping .loc [process ['location' ], 'acid' ]
904908 exc ['input' ] = (exc ['database' ], exc ['code' ])
905909
0 commit comments