Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
bcf43f0
Wrap GMT's standard data type GMT_IMAGE for images
seisman Mar 18, 2024
a052a1a
Initial implementation of to_dataarray method for _GMT_IMAGE class
weiji14 Mar 20, 2024
56a6d65
Merge branch 'main' into datatypes/gmtimage
seisman Apr 17, 2024
f71e79c
Merge branch 'main' into datatypes/gmtimage
weiji14 Jun 18, 2024
4cce4a2
Small typo fixes and add output type-hint for to_dataarray
weiji14 Jun 18, 2024
e02b650
Fix mypy error using np.array([0, 1, 2]) instead of np.arange
weiji14 Jun 18, 2024
f3d4b1f
Parse name and data_attrs from grid/image header
weiji14 Jun 18, 2024
4390136
Transpose array to (band, y, x) order and add doctest for to_dataarray
weiji14 Jun 20, 2024
5f25669
Set registration and gtype from header
weiji14 Jun 20, 2024
a3c6c14
Print basic shape and padding info in _GMT_IMAGE doctest
weiji14 Jun 20, 2024
5888e10
Only set Conventions = CF-1.7 attribute for NetCDF grid type
weiji14 Jun 20, 2024
798e658
Merge branch 'main' into datatypes/gmtimage
weiji14 Jun 20, 2024
3dbf2f2
Remove rioxarray import
weiji14 Jun 20, 2024
6b860bf
Merge branch 'main' into datatypes/gmtimage
seisman Jul 27, 2024
0bf9368
Merge branch 'main' into datatypes/gmtimage
seisman Sep 19, 2024
7d437be
Use enum for grid ids
seisman Sep 19, 2024
268e34e
Fix the band. Starting from 1
seisman Sep 19, 2024
86765e1
Refactor the tests for images
seisman Sep 19, 2024
86f3ffa
In np.reshape, a is a position-only parameter
seisman Sep 20, 2024
cc28247
Improve tests
seisman Sep 20, 2024
1e2c973
Fix one failing doctest due to xarray changes
seisman Sep 20, 2024
734dc28
The np.reshape's newshape parameter is deprecated
seisman Sep 20, 2024
919dc00
Define grid IDs using IntEnum instead of Enum
seisman Sep 20, 2024
b1eacf1
Pass the new shape as a positional parameter
seisman Sep 20, 2024
aa4fdc9
Fix failing tests
seisman Sep 20, 2024
c87a3ec
One more fix
seisman Sep 20, 2024
a20d8a2
One more fix
seisman Sep 20, 2024
926427b
Simplify a doctest
seisman Sep 20, 2024
c73328e
Improve the tests
seisman Sep 20, 2024
fb97daa
Convert ctypes array to numpy array using np.ctypeslib.as_array
seisman Sep 20, 2024
15b8d53
Fix the incorrect value due to floating number conversion in sphinter…
seisman Sep 20, 2024
8433e78
Merge branch 'ctypesarray' into datatypes/gmtimage
seisman Sep 20, 2024
3e3a6f3
Update the to_dataarray method to match the codes in GMT_GRID
seisman Sep 20, 2024
12ef40a
image data should has uint8 dtype
seisman Sep 20, 2024
f64fbb8
Further improve the tests
seisman Sep 21, 2024
4f2ae48
Merge branch 'main' into datatypes/gmtimage
seisman Sep 24, 2024
d49afed
Add a note that currently only 3-band images are supported
seisman Sep 24, 2024
f70bec0
Merge branch 'main' into datatypes/gmtimage
seisman Sep 28, 2024
2fd13fb
Remove the old GMTGridID enums from pygmt/datatypes/header.py
seisman Sep 28, 2024
9972ba1
A minor fix
seisman Sep 28, 2024
62f0ce0
Set CF-1.7-specific attributes for netCDF formats only
seisman Sep 29, 2024
f715aee
Improve the logic for determine grid/image gtype based on upstream GM…
seisman Sep 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Set CF-1.7-specific attributes for netCDF formats only
  • Loading branch information
seisman committed Sep 29, 2024
commit 62f0ce056cb6bdd32521905529246d67faae2b8d
2 changes: 1 addition & 1 deletion pygmt/datatypes/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
<xarray.DataArray 'lon' (lon: 8)>...
array([-54.5, -53.5, -52.5, -51.5, -50.5, -49.5, -48.5, -47.5])
Expand Down
10 changes: 5 additions & 5 deletions pygmt/datatypes/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions pygmt/datatypes/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
<xarray.DataArray 'x' (x: 360)>...
Expand Down