Skip to content

meca: Only stretch master CPTs given in -C to the depth range - #9177

Merged
Esteban82 merged 1 commit into
masterfrom
fix-9176-meca-cpt
Sep 4, 2026
Merged

meca: Only stretch master CPTs given in -C to the depth range#9177
Esteban82 merged 1 commit into
masterfrom
fix-9176-meca-cpt

Conversation

@Esteban82

Copy link
Copy Markdown
Member

Fixes #9176. Since #8966, meca always resampled whatever CPT was given in -C to span the depth range of the events being plotted. That discarded the z-range of a CPT the user had built with makecpt, so beachball colors no longer matched the CPT (or a colorbar drawn from it), and even changed depending on which other events were in the input.

Stretching should only happen when -C is given the name of a master CPT (e.g. -Cbatlow), since those have the default 0-1 range. This PR only stretches in that case; a real CPT file, or the current CPT in modern mode, is now used as given.

Assisted by Claude Opus 5

Fixes #9176.

Since #8966 meca always resampled the CPT given in -C so that it spanned
the depth range of the events being plotted.  That silently discarded the
z-range of a CPT the user had prepared with makecpt, so the beachball
colors no longer agreed with the CPT (nor with the colorbar drawn from
it), and they even changed when events were added to or removed from the
input file.

The stretching is only needed for the case #8966 added, i.e., when -C is
given the name of a master CPT (e.g., -Cbatlow), since those only have
the default 0-1 range.  So we now record at parse time whether the -C
argument is a master CPT name and only stretch in that case; a real CPT
file, and the current CPT in modern mode, are used as given.

We also use gmt_stretch_cpt instead of gmt_sample_cpt, which preserves
any hinge and does not leave the original CPT behind, we widen the
stretched range by the same round-off guard gmt_get_palette uses so the
deepest event cannot fall outside the CPT and pick up the foreground
color, and we plug the leak of the string returned by gmt_is_cpt_master.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Esteban82 Esteban82 added add-changelog Add PR to the changelog AI-assisted All (or most) of the code was written by Artificial Intelligence. labels Sep 3, 2026

@joa-quim joa-quim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm, it seems we are starting to have a non-negligible side effects on these AI fixes.

@Esteban82

Copy link
Copy Markdown
Member Author

Hmm, it seems we are starting to have a non-negligible side effects on these AI fixes.

Yes, we should be more careful.

@Esteban82
Esteban82 merged commit e3fa9e2 into master Sep 4, 2026
11 of 14 checks passed
@Esteban82
Esteban82 deleted the fix-9176-meca-cpt branch September 4, 2026 00:28
@yvonnefroehlich

Copy link
Copy Markdown
Member

Thanks for looking at this issue so fast.

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.

meca ignors colormap created via makecpt

3 participants