Skip to content

Conversation

@Dengda98
Copy link
Contributor

bug description

grdinterpolate -S failed with -T,

$ gmt grdinterpolate S362ANI_kmps.nc?vs -S120/30 -T30/2890/10
sample1d [ERROR]: x-values are not monotonically increasing/decreasing (at zero-based record 5)!
sample1d [ERROR]: Failure in gmt_intpol near row 6!

(cube can be downloaded by curl -s http://ds.iris.edu/spudservice/data/17996723 -o S362ANI_kmps.nc)

but single -S works fine,

$ gmt grdinterpolate S362ANI_kmps.nc?vs -S120/30
> Location 120,30
120     30      25      4.50629997253
120     30      50      4.45459985733
120     30      75      4.41890001297
120     30      100     4.40129995346
120     30      125     4.39860010147
120     30      150     4.40659999847
... (skip)

What's changed

Same logic as below. Column index passed to sampled1d -N[col] is changeable.

gmt/src/grdinterpolate.c

Lines 607 to 620 in 5beb2bd

if (Ctrl->S.active) { /* Want x,y,z[,.....],value output */
for (col = 0; col < GMT_Z; col++) /* Copy over x,y */
So->data[col][row_o] = Si->data[col][row];
So->data[GMT_Z][row_o] = level[k]; /* Add level as the z column */
while (col < Si->n_columns) { /* Copy over the rest */
So->data[col+1][row_o] = Si->data[col][row];
col++;
}
}
else { /* Format for -E is x,y[,....],value */
for (col = 0; col < Si->n_columns; col++) /* Copy over the various columns */
So->data[col][row_o] = Si->data[col][row];
So->data[col][row_o] = level[k]; /* Add level as the last data column */
}

The new result seems fine.

$ gmt grdinterpolate S362ANI_kmps.nc?vs -S120/30 -T30/2890/10
> Location 120,30
120     30      30      4.49469568981
120     30      40      4.47343079986
120     30      50      4.45459985733
120     30      60      4.43819725238
120     30      70      4.4245685905
120     30      80      4.41396319261
... (skip)

@joa-quim joa-quim merged commit ebea1f1 into GenericMappingTools:master May 18, 2025
11 of 13 checks passed
@Dengda98 Dengda98 deleted the fix_grdinterpolate_-S_-T branch May 19, 2025 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants