Deltares / xugrid

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

Merge partition chunks #253

Closed Huite closed 3 months ago

Huite commented 3 months ago

This addresses #252

Also related to: https://github.com/Deltares/dfm_tools/issues/679 >> JV: this is something different, not occurring with merging

Huite commented 3 months ago

Might be worthwhile to check something like a reindex as well for completeness, since that's definitely one of the cases where the previous implementation was worst.

veenstrajelmer commented 3 months ago

After our discussion I tried to plot a transect to one partition of the merged model. This performance is indeed worse than before. With the RMM example from above:

import dfm_tools as dfmt
import numpy as np
line_array = np.array([[ 42546.47095912, 483810.44968039],
       [ 67475.42610872, 491926.42350426],
       [ 86985.04318231, 478574.33753595],
       [ 77230.23464551, 467054.8908182 ],
       [101797.90059004, 469672.94689042]])
print('>> plotting transect: ',end='')
dtstart = dt.datetime.now()
uds_crs = dfmt.polyline_mapslice(ds_merged_xu.isel(time=3), line_array)
fig, ax = plt.subplots()
uds_crs['mesh2d_sa1'].ugrid.plot(cmap='jet')
print(f'{(dt.datetime.now()-dtstart).total_seconds():.2f} sec')

Also this action seems to be faster with the new method, or at least as fast.