Skip to content

Commit 195a50f

Browse files
committed
fix missing group in exposure
1 parent 0234238 commit 195a50f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

climada/trajectories/riskperiod.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -710,10 +710,15 @@ def calc_eai_gdf(self) -> gpd.GeoDataFrame:
710710
df = df.reset_index().melt(
711711
id_vars="date", var_name="coord_id", value_name="risk"
712712
)
713-
eai_gdf = self.snapshot_start.exposure.gdf[["group_id"]]
714-
eai_gdf["coord_id"] = eai_gdf.index
715-
eai_gdf = eai_gdf.merge(df, on="coord_id")
716-
eai_gdf = eai_gdf.rename(columns={"group_id": "group"})
713+
if "group_id" in self.snapshot_start.exposure.gdf:
714+
eai_gdf = self.snapshot_start.exposure.gdf[["group_id"]]
715+
eai_gdf["coord_id"] = eai_gdf.index
716+
eai_gdf = eai_gdf.merge(df, on="coord_id")
717+
eai_gdf = eai_gdf.rename(columns={"group_id": "group"})
718+
else:
719+
eai_gdf = df
720+
eai_gdf["group"] = pd.NA
721+
717722
eai_gdf["group"] = pd.Categorical(eai_gdf["group"], categories=self._groups_id)
718723
eai_gdf["metric"] = "eai"
719724
eai_gdf["measure"] = self.measure.name if self.measure else "no_measure"

0 commit comments

Comments
 (0)