From 0607d6858dd06d243ff3b6020eaf16939e438aae Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 24 Sep 2024 10:43:38 +0800 Subject: [PATCH] Only set the 'Conventions' attr to 'CF-1.7' for netCDF files --- pygmt/datatypes/header.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pygmt/datatypes/header.py b/pygmt/datatypes/header.py index 04e10ac0c72..7c4a5028412 100644 --- a/pygmt/datatypes/header.py +++ b/pygmt/datatypes/header.py @@ -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. # @@ -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()