diff --git a/pygmt/datatypes/grid.py b/pygmt/datatypes/grid.py index 4be2599afd5..18ad679aeef 100644 --- a/pygmt/datatypes/grid.py +++ b/pygmt/datatypes/grid.py @@ -139,8 +139,8 @@ def to_dataarray(self) -> xr.DataArray: title: Produced by grdcut history: grdcut @earth_relief_01d_p -R-55/-47/-24/-10 -Gstatic_ea... description: Reduced by Gaussian Cartesian filtering (111.2 km fullwi... - long_name: elevation (m) actual_range: [190. 981.] + long_name: elevation (m) >>> da.coords["lon"] # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS ... array([-54.5, -53.5, -52.5, -51.5, -50.5, -49.5, -48.5, -47.5]) diff --git a/pygmt/datatypes/header.py b/pygmt/datatypes/header.py index d7806e50a24..1cef6d38b38 100644 --- a/pygmt/datatypes/header.py +++ b/pygmt/datatypes/header.py @@ -210,17 +210,17 @@ def data_attrs(self) -> dict[str, Any]: GridFormat.NI, GridFormat.NF, GridFormat.ND, - }: # Only set the 'Conventions' attribute for netCDF. + }: # Set attributes specific to CF-1.7 conventions attrs["Conventions"] = "CF-1.7" - attrs["title"] = self.title.decode() - attrs["history"] = self.command.decode() - attrs["description"] = self.remark.decode() + attrs["title"] = self.title.decode() + attrs["history"] = self.command.decode() + attrs["description"] = self.remark.decode() + attrs["actual_range"] = np.array([self.z_min, self.z_max]) long_name, units = _parse_nameunits(self.z_units.decode()) if long_name: attrs["long_name"] = long_name if units: attrs["units"] = units - attrs["actual_range"] = np.array([self.z_min, self.z_max]) return attrs @property diff --git a/pygmt/datatypes/image.py b/pygmt/datatypes/image.py index 037db5c2a6e..773c3cdb78a 100644 --- a/pygmt/datatypes/image.py +++ b/pygmt/datatypes/image.py @@ -145,11 +145,7 @@ def to_dataarray(self) -> xr.DataArray: * x (x) float64... -179.5 -178.5 -177.5 -176.5 ... 177.5 178.5 179.5 * band (band) uint8... 1 2 3 Attributes: - title: - history: - description: long_name: z - actual_range: [ 1.79769313e+308 -1.79769313e+308] >>> da.coords["x"] # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS ...