ec-jrc / pyPoseidon

Framework for Hydrodynamic simulations
https://pyposeidon.readthedocs.io/
European Union Public License 1.2
20 stars 8 forks source link

Preserve netcdf attributes #163

Closed pmav99 closed 11 months ago

pmav99 commented 1 year ago

xarray is dropping dataset attributes by default. This afffects us when, for example, we call to_2d(). The resulting dataset does not have any metadata.

I think that in most cases we should preserve them (or even update them, but this is a different issue).

To preserve the metadata it should be enough to add a line like this

new_ds.attrs.update(old_ds.attrs)

https://docs.xarray.dev/en/stable/getting-started-guide/faq.html#what-is-your-approach-to-metadata