Skip to content

Conversation

@Dengda98
Copy link
Contributor

@Dengda98 Dengda98 commented May 17, 2025

bug description

Following command gives 0 value result,

$ gmt grdtrack -G@earth_relief_30m -C23d/0.1/5 -E125/33/146/46+i0.1d -Su+a+d+r+s | head -n5
> Cross profile number -L0-0 at  125.000/033.000 az=-45.1
114.26416966    40.6673817899   -11.503849419   128.406893601   1235.72535495   0       0       0
114.367384391   40.6052116066   -11.403759574   128.406893601   1186.20357679   0       0       0
114.470407141   40.5429497186   -11.3036706902  128.47411274    1138.74642045   0       0       0
114.573238406   40.4805964975   -11.2035827687  128.541121917   1097.87933294   0       0       0

but -Sa(or m or p) result seems fine,

$ gmt grdtrack -G@earth_relief_30m -C23d/0.1/5 -E125/33/146/46+i0.1d -Sa+a+d+r+s | head -n5
> Cross profile number -L0-0 at  125.000/033.000 az=-45.1
114.26416966    40.6673817899   -11.503849419   128.406893601   1235.72535495   720.292586732   470.461540049   515.43276822
114.367384391   40.6052116066   -11.403759574   128.406893601   1186.20357679   671.853133504   467.132268645   514.350443286
114.470407141   40.5429497186   -11.3036706902  128.47411274    1138.74642045   617.656836713   463.490082661   521.089583733
114.573238406   40.4805964975   -11.2035827687  128.541121917   1097.87933294   565.3276248     460.812758913   532.551708144

the stacked profile (stacked_profile.txt, generated by +s) wasn't influenced.

What's Changed

The original continue statement here skip the value assignment, so I changed if to include "envolope" instead.

gmt/src/grdtrack.c

Lines 1018 to 1033 in 1388572

for (col = 4, colx = col0, k = 0; k < Ctrl->G.n_grids; k++, col++, colx += n_added_cols) { /* Place stacked, deviation, low, high [and lo_env hi_env] for each grid */
M->data[1+k*n_step][row] = stacked_val[k]; /* The stacked value */
M->data[2+k*n_step][row] = stacked_dev[k]; /* The stacked deviation */
M->data[3+k*n_step][row] = stacked_lo[k]; /* The stacked low value */
M->data[4+k*n_step][row] = stacked_hi[k]; /* The stacked high value */
if (Ctrl->S.mode >= STACK_LOWER) continue;
M->data[5+k*n_step][row] = stacked_val[k] - Ctrl->S.factor * stacked_dev[k]; /* The low envelope value */
M->data[6+k*n_step][row] = stacked_val[k] + Ctrl->S.factor * stacked_dev[k]; /* The low envelope value */
if (n_added_cols == 0) continue; /* No modification to profile outputs requested */
for (seg = 0; seg < T->n_segments; seg++) { /* For each segment to append to */
col_s = colx; /* Start over at this column */
if (Ctrl->S.selected[STACK_ADD_VAL]) T->segment[seg]->data[col_s++][row] = stacked_val[k]; /* Place stacked value at end of profile */
if (Ctrl->S.selected[STACK_ADD_DEV]) T->segment[seg]->data[col_s++][row] = stacked_dev[k]; /* Place deviation at end of profile */
if (Ctrl->S.selected[STACK_ADD_RES]) T->segment[seg]->data[col_s++][row] = T->segment[seg]->data[col][row] - stacked_val[k]; /* Place residuals(s) at end of profile */
}
}

The new result seems fine (0 value in residual column is normal for this command),

$ gmt grdtrack -G@earth_relief_30m -C23d/0.1/5 -E125/33/146/46+i0.1d -Su+a+d+r+s | head -n5
> Cross profile number -L0-0 at  125.000/033.000 az=-45.1
114.26416966    40.6673817899   -11.503849419   128.406893601   1235.72535495   1235.72535495   506.723581417   0
114.367384391   40.6052116066   -11.403759574   128.406893601   1186.20357679   1186.20357679   484.533767645   0
114.470407141   40.5429497186   -11.3036706902  128.47411274    1138.74642045   1138.74642045   461.580797293   0
114.573238406   40.4805964975   -11.2035827687  128.541121917   1097.87933294   1097.87933294   439.851354011   0

Copy link
Member

@joa-quim joa-quim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, looks good and if it fixes a bad result, fine. Didn't look to any eventual consequences though.

@joa-quim joa-quim merged commit 5beb2bd into GenericMappingTools:master May 17, 2025
12 of 13 checks passed
@Dengda98 Dengda98 deleted the fix_grdtrack_-S branch May 18, 2025 02:57
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