Deltares / xugrid

Xarray and unstructured grids
https://deltares.github.io/xugrid/
MIT License
64 stars 8 forks source link

merge_partitions fails for grid with long_culverts #86

Closed veenstrajelmer closed 8 months ago

veenstrajelmer commented 1 year ago

Raises "ValueError: Expected 3 UGRID topologies for 3 partitions, received: defaultdict [...]"

MWE:

import xugrid as xu

file_nc_list = ['p:\\11209233-mad09a-2023-rijn\\C_Work\\02_lange_duikers\\02_berekeningen\\dflowfm2d-rijn-j19_6-v2a\\computations\\hist\\hw2018_kort\\v15\\results\\converted_RIJN_0000_map.nc',
                'p:\\11209233-mad09a-2023-rijn\\C_Work\\02_lange_duikers\\02_berekeningen\\dflowfm2d-rijn-j19_6-v2a\\computations\\hist\\hw2018_kort\\v15\\results\\converted_RIJN_0001_map.nc',
                'p:\\11209233-mad09a-2023-rijn\\C_Work\\02_lange_duikers\\02_berekeningen\\dflowfm2d-rijn-j19_6-v2a\\computations\\hist\\hw2018_kort\\v15\\results\\converted_RIJN_0002_map.nc',
                ]

chunks={'time':1} 
partitions = []
for iF, file_nc_one in enumerate(file_nc_list):
    uds = xu.open_dataset(file_nc_one, chunks=chunks)
    partitions.append(uds)
ds_merged_xu = xu.merge_partitions(partitions)

When supplying only the partition with long_culverts (the second one), it raises "ValueError: indexes must be provided for attrs". The grid of the single partition can also not be plotted, it raises "TypeError: Can only access grid topology via .grid if dataset contains exactly one grid. Dataset contains 3 grids. Use .grids instead."

This is related to https://github.com/Deltares/xugrid/issues/134

JoerivanEngelen commented 8 months ago

Fixed by: https://github.com/Deltares/xugrid/pull/216