Skip to content

Commit 8a24cc5

Browse files
committed
add try except for missing crs info
1 parent 0d5d677 commit 8a24cc5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

climada/engine/impact.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,10 @@ def read_csv(self, file_name):
459459
self.coord_exp = np.zeros((num_exp, 2))
460460
self.coord_exp[:, 0] = imp_df.exp_lat[:num_exp]
461461
self.coord_exp[:, 1] = imp_df.exp_lon[:num_exp]
462-
self.crs = ast.literal_eval(imp_df.exp_crs.values[0])
462+
try:
463+
self.crs = ast.literal_eval(imp_df.exp_crs.values[0])
464+
except AttributeError:
465+
self.crs = DEF_CRS
463466
self.tag['haz'] = TagHaz(str(imp_df.tag_hazard[0]),
464467
str(imp_df.tag_hazard[1]),
465468
str(imp_df.tag_hazard[2]))
@@ -502,7 +505,10 @@ def read_excel(self, file_name):
502505
self.coord_exp = np.zeros((self.eai_exp.size, 2))
503506
self.coord_exp[:, 0] = dfr.exp_lat.values[:self.eai_exp.size]
504507
self.coord_exp[:, 1] = dfr.exp_lon.values[:self.eai_exp.size]
505-
self.crs = ast.literal_eval(dfr.exp_crs.values[0])
508+
try:
509+
self.crs = ast.literal_eval(dfr.exp_crs.values[0])
510+
except AttributeError:
511+
self.crs = DEF_CRS
506512

507513
def _exp_impact(self, exp_iimp, exposures, hazard, imp_fun, insure_flag):
508514
"""Compute impact for inpute exposure indexes and impact function.

0 commit comments

Comments
 (0)