Deltares / xugrid

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

add test to wrap ugriddataset twice (should fail now) #209

Closed veenstrajelmer closed 8 months ago

veenstrajelmer commented 8 months ago

@Huite your suggestion works and I have implemented it in this PR including a testcase that failed before the .copy() was added. I guess this is therefore a valid fix. However, I also noticed it works when calling ds = xr.decode_cf(ds) upon trying to create a testcase for this situation. This is unexpected, since ds = xr.open_dataset(file_nc) also has a decode_cf=True as default. Maybe this triggers you to find a solution elsewhere in the code. If not, I think this PR can be merged.

Huite commented 8 months ago

However, I also noticed it works when calling ds = xr.decode_cf(ds) upon trying to create a testcase for this situation.

You mean, the original connectivity does not get changed when you called xr.decode? That makes sense to me, the xr.decode call will just create a copy.

The difference with open_dataset is just the order right?

For the constructor: ds -> decode -> new_ds -> constructor

From open_dataset: file -> decode -> ds