Skip to content

Commit

Permalink
fix setting index in gdf_to_da for vertex grids
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrakenhoff committed Jun 21, 2023
1 parent d2432f4 commit b75f83a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions nlmod/dims/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,9 +1062,12 @@ def gdf_to_da(
else:
# aggregation not neccesary
gdf_agg = gdf_cellid[[column]]
gdf_agg.set_index(
pd.MultiIndex.from_tuples(gdf_cellid.cellid.values), inplace=True
)
if isinstance(gdf_cellid.cellid.iloc[0], tuple):
gdf_agg.set_index(
pd.MultiIndex.from_tuples(gdf_cellid.cellid.values), inplace=True
)
else:
gdf_agg.set_index(gdf_cellid.cellid.values, inplace=True)
da = util.get_da_from_da_ds(ds, dims=ds.top.dims, data=fill_value)
for ind, row in gdf_agg.iterrows():
da.values[ind] = row[column]
Expand Down

0 comments on commit b75f83a

Please sign in to comment.