Skip to content

Commit

Permalink
#525: gdal adds its own Conventions attribute with value 'CF-1.5' whi…
Browse files Browse the repository at this point in the history
…ch is obviously wrong. This is now deleted. Same goes for the history. That should also be handled in the processing software rather then by the gdal netcdf driver.
  • Loading branch information
mortenwh authored and akorosov committed Jan 5, 2023
1 parent 6915f11 commit 813aad6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions nansat/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,19 @@ def rename_attributes(filename):
rename_attrs = []
# Open new file to edit attribute names
ds = Dataset(filename, 'r+')
""" The netcdf driver adds the Conventions attribute with
value CF-1.5. This may be wrong, so it is better to use the
Conventions metadata from the Nansat object. Other attributes
added by gdal that are already present in Nansat, should also
be deleted."""
for attr in ds.ncattrs():
if GDAL in attr:
if attr.replace(GDAL, "") in ds.ncattrs():
# Mark for deletion
del_attrs.append(attr)
else:
# Mark for renaming
rename_attrs.append(attr)
# Mark the attribute created by the netcdf driver
# for deletion - ref above comment
del_attrs.append(attr.replace(GDAL, ""))
# Mark for renaming
rename_attrs.append(attr)

# Delete repeated attributes..
for attr in del_attrs:
Expand Down

0 comments on commit 813aad6

Please sign in to comment.