Skip to content

Commit

Permalink
Set the 'Conventions' attribute to 'CF-1.7' for netCDF grids only (#3463
Browse files Browse the repository at this point in the history
)

Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
  • Loading branch information
seisman and weiji14 authored Sep 28, 2024
1 parent 015899b commit cf48764
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 GridFormat

# 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 {
GridFormat.NB,
GridFormat.NS,
GridFormat.NI,
GridFormat.NF,
GridFormat.ND,
}: # Only set the 'Conventions' attribute for netCDF.
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 cf48764

Please sign in to comment.