Skip to content

Fix pssac drawing a wrong short line (#5954) - #9132

Open
Esteban82 wants to merge 1 commit into
masterfrom
fix_5954
Open

Fix pssac drawing a wrong short line (#5954)#9132
Esteban82 wants to merge 1 commit into
masterfrom
fix_5954

Conversation

@Esteban82

Copy link
Copy Markdown
Member

Done with Claude (Sonnet 5, high reasoning effort).

Summary

Fixes #5954, where pssac/sac occasionally draws a short, disconnected
stray line segment near a trace peak.

Two bugs combined to produce this:

  • pssac.c never wrapped its line/fill drawing in gmt_map_clip_on/ gmt_map_clip_off, unlike other line-plotting modules (psxy, pswiggle, ...), so traces briefly exceeding the plotted y-range were never clipped to the frame.
  • The shared gmt_plot_line pen-width border-extension helper (gmtplot_get_outside_point_extension in gmt_plot.c) computes an extension length via W / tan(angle). When a line crosses the border at a near-tangent angle — which happens whenever a smooth waveform peak just barely pokes above/below the plotted range, as in the reporter's SAC trace — this blows up to a length far beyond the segment that defines the crossing direction, producing a visible stray line. This is a generic bug (reproduced identically via plain psxy on the same sample values), not specific to SAC data.

Fix

  • gmt_plot.c: cap the extension length to the length of the segment that defines the crossing direction (L = MIN(L, hypot(dx, dy))).
  • seis/pssac.c: add the missing gmt_map_clip_on/gmt_map_clip_off around the per-trace plotting loop.

Checked visually with:

plot_test_5954
gmt begin plot_test_5954 png
    gmt plot test.txt -JX10c/5c -W1p -R-8.22653e-14/3.935039/9.907071e-08/0.43307
gmt end
sac_test_5954_fixed
gmt begin sac_test_5954 png
    gmt sac -JX10c/1.1c -R-2.23517e-07/20/-4.80721e-06/4.30574e-06 bug.sac
gmt end

The files are in #5954.

@Esteban82
Esteban82 requested review from joa-quim and seisman August 20, 2026 20:30
@Esteban82 Esteban82 added add-changelog Add PR to the changelog AI-assisted All (or most) of the code was written by Artificial Intelligence. labels Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add-changelog Add PR to the changelog AI-assisted All (or most) of the code was written by Artificial Intelligence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sac module draw a wrong line

1 participant