Skip to content

Commit

Permalink
Only set the 'Conventions' attr to 'CF-1.7' for netCDF files
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed Sep 24, 2024
1 parent 22d7041 commit 0607d68
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pygmt/datatypes/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Any, ClassVar

import numpy as np
from pygmt.enums import GridID

# Constants for lengths of grid header variables.
#
Expand Down Expand Up @@ -203,7 +204,14 @@ def data_attrs(self) -> dict[str, Any]:
Attributes for the data variable from the grid header.
"""
attrs: dict[str, Any] = {}
attrs["Conventions"] = "CF-1.7"
if self.type in { # netCDF format
GridID.GMT_GRID_IS_NB,
GridID.GMT_GRID_IS_NS,
GridID.GMT_GRID_IS_NI,
GridID.GMT_GRID_IS_NF,
GridID.GMT_GRID_IS_ND,
}:
attrs["Conventions"] = "CF-1.7"
attrs["title"] = self.title.decode()
attrs["history"] = self.command.decode()
attrs["description"] = self.remark.decode()
Expand Down

0 comments on commit 0607d68

Please sign in to comment.