I have netCDF files of oceanographic data processed in Python, that I'd like to update the global attributes of (i.e., add the same attributes to a bunch of files). Tried doing it in Xarray per their instructions, but nothing seems to have been updated. Not sure what I'm doing wrong
With these metadata:
metadata = {'title': 'Time-series data of currents, temperature and waves off Lahaina, Maui, 2023',
'institution':'U.S. Geological Survey'}
I'm trying to update files in a folder with this:
for file in filelist:
with xr.open_dataset(file,mode='a') as ds:
ds = ds.attrs.update(metadata)
It runs just fine, and according to the file attributes, they have been updated. But when I open the file in Panoply, nothing has been added. the Xarray documentation states that this is a safer way to update a file, as it automatically closes.