gmt icon indicating copy to clipboard operation
gmt copied to clipboard

grdinterpolate generates one layer too much when reading the cube.nc test file

Open joa-quim opened this issue 1 year ago • 0 comments

CLI report is fine

C:\Users\j\.julia\dev\GMT\test>grdinfo cube.nc
cube.nc: Title: Produced by grdmath
cube.nc: Command: Sat Jul 20 16:59:25 2019: ncecat -u level 1.nc 2.nc 3.nc 4.nc cube.nc
grdmath -R0/10/0/10 -I1 X Y MUL = 1.nc
cube.nc: Remark:
cube.nc: Gridline node registration used [Cartesian grid]
cube.nc: Grid file format: nf = GMT netCDF format (32-bit float), CF-1.7
cube.nc: x_min: 0 x_max: 10 x_inc: 1 name: x n_columns: 11
cube.nc: y_min: 0 y_max: 10 y_inc: 1 name: y n_rows: 11
cube.nc: z_min: 1 z_max: 5 z_inc: (variable) name: z n_levels: 4
cube.nc: z_levels: 1, 2, 3, 5
cube.nc: v_min: 0 v_max: 140 name: cube
cube.nc: scale_factor: 1 add_offset: 0
cube.nc: format: classic
cube.nc: Default CPT:

But when importing it in Julia

julia> C
A GMTgrid object with 5 layers of type Float32
command: gmt grdinterpolate C:\Users\j\.julia\dev\GMT\test\cube.nc -n+a -G@GMTAPI@-S-O-U-U-U-N-000000
Gridline node registration used
x_min: 0.0      x_max :10.0     x_inc :1.0      n_columns :11
y_min: 0.0      y_max :10.0     y_inc :1.0      n_rows :11
z_min: 1.0      z_max :5.0
Mem layout:     BCB
julia> slicecube(C,5).z
11×11 Matrix{Float32}:
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0

And debugging the Julia side shows that it reports nlayers = 5 and the data is fetch from the C memory with

t::Vector{Float32} = unsafe_wrap(Array, G.data, my * mx * nb)

So, that 5th layer of 0's came from C.

joa-quim avatar Feb 09 '24 13:02 joa-quim