Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed Sep 30, 2024
1 parent 84b37a7 commit 80999c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
21 changes: 10 additions & 11 deletions pygmt/datatypes/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,13 @@ class _GMT_CUBE(ctp.Structure): # noqa: N801
... # Cube-specific attributes.
... print(cube.mode, cube.z_range[:], cube.z_inc, cube.name, cube.units)
... # The x, y, and z coordinates
... x = cube.x[: header.n_columns]
... y = cube.y[: header.n_rows]
... z = cube.z[: header.n_bands]
... x = np.ctypeslib.as_array(cube.x, shape=(header.n_columns,)).copy()
... y = np.ctypeslib.as_array(cube.y, shape=(header.n_rows,)).copy()
... z = np.ctypeslib.as_array(cube.z, shape=(header.n_bands,)).copy()
... # The data array (with paddings)
... data = np.reshape(
... cube.data[: header.n_bands * header.mx * header.my],
... (header.my, header.mx, header.n_bands),
... )
... data = np.ctypeslib.as_array(
... cube.data, shape=(header.my, header.mx, header.n_bands)
... ).copy()
... # The data array (without paddings)
... pad = header.pad[:]
... data = data[pad[2] : header.my - pad[3], pad[0] : header.mx - pad[1], :]
Expand All @@ -68,15 +67,15 @@ class _GMT_CUBE(ctp.Structure): # noqa: N801
b'' 0.0
0 [1.0, 5.0] 0.0 b'' b'z'
>>> x
[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])
>>> y
[10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0]
array([10., 9., 8., 7., 6., 5., 4., 3., 2., 1., 0.])
>>> z
[1.0, 2.0, 3.0, 5.0]
array([1., 2., 3., 5.])
>>> data.shape
(11, 11, 4)
>>> # data.min(), data.max() # The min/max are wrong. Upstream bug?
>>> # (-29.399999618530273, 169.39999389648438)
>>> # (-29.4, 169.4)
"""

_fields_: ClassVar = [
Expand Down
2 changes: 1 addition & 1 deletion pygmt/tests/test_clib_read_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def test_clib_read_data_cube_actual_image():
"""
with Session() as lib:
with pytest.raises(GMTCLibError):
lib.read_data("@earth_day_01d_p", kind="cube", mode="GMT_CONTAINER_ONLY")
lib.read_data("@earth_day_01d", kind="cube", mode="GMT_CONTAINER_ONLY")


def test_clib_read_data_fails():
Expand Down

0 comments on commit 80999c6

Please sign in to comment.