Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
joa-quim opened this issue Feb 9, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@joa-quim
Copy link
Member

joa-quim commented Feb 9, 2024

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 joa-quim added the bug Something isn't working label Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant