GeezerVison is showing github.com — Set CF-1.7-specific attributes for netCDF formats only · GenericMappingTools/pygmt@62f0ce0
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: pygmt/datatypes/grid.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -139,8 +139,8 @@ def to_dataarray(self) -> xr.DataArray: |
139 | 139 | title: Produced by grdcut |
140 | 140 | history: grdcut @earth_relief_01d_p -R-55/-47/-24/-10 -Gstatic_ea... |
141 | 141 | description: Reduced by Gaussian Cartesian filtering (111.2 km fullwi... |
142 | | - long_name: elevation (m) |
143 | 142 | actual_range: [190. 981.] |
| 143 | + long_name: elevation (m) |
144 | 144 | >>> da.coords["lon"] # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS |
145 | 145 | <xarray.DataArray 'lon' (lon: 8)>... |
146 | 146 | array([-54.5, -53.5, -52.5, -51.5, -50.5, -49.5, -48.5, -47.5]) |
|
Collapse file
Copy file name to clipboardExpand all lines: pygmt/datatypes/header.py +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -210,17 +210,17 @@ def data_attrs(self) -> dict[str, Any]: |
210 | 210 | GridFormat.NI, |
211 | 211 | GridFormat.NF, |
212 | 212 | GridFormat.ND, |
213 | | - }: # Only set the 'Conventions' attribute for netCDF. |
| 213 | + }: # Set attributes specific to CF-1.7 conventions |
214 | 214 | attrs["Conventions"] = "CF-1.7" |
215 | | - attrs["title"] = self.title.decode() |
216 | | - attrs["history"] = self.command.decode() |
217 | | - attrs["description"] = self.remark.decode() |
| 215 | + attrs["title"] = self.title.decode() |
| 216 | + attrs["history"] = self.command.decode() |
| 217 | + attrs["description"] = self.remark.decode() |
| 218 | + attrs["actual_range"] = np.array([self.z_min, self.z_max]) |
218 | 219 | long_name, units = _parse_nameunits(self.z_units.decode()) |
219 | 220 | if long_name: |
220 | 221 | attrs["long_name"] = long_name |
221 | 222 | if units: |
222 | 223 | attrs["units"] = units |
223 | | - attrs["actual_range"] = np.array([self.z_min, self.z_max]) |
224 | 224 | return attrs |
225 | 225 |
|
226 | 226 | @property |
|
Collapse file
Copy file name to clipboardExpand all lines: pygmt/datatypes/image.py -4Lines changed: 0 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -145,11 +145,7 @@ def to_dataarray(self) -> xr.DataArray: |
145 | 145 | * x (x) float64... -179.5 -178.5 -177.5 -176.5 ... 177.5 178.5 179.5 |
146 | 146 | * band (band) uint8... 1 2 3 |
147 | 147 | Attributes: |
148 | | - title: |
149 | | - history: |
150 | | - description: |
151 | 148 | long_name: z |
152 | | - actual_range: [ 1.79769313e+308 -1.79769313e+308] |
153 | 149 |
|
154 | 150 | >>> da.coords["x"] # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS |
155 | 151 | <xarray.DataArray 'x' (x: 360)>... |
|