meca: Only stretch master CPTs given in -C to the depth range - #9177
Merged
Conversation
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>
joa-quim
approved these changes
Sep 3, 2026
joa-quim
left a comment
Member
There was a problem hiding this comment.
Hmm, it seems we are starting to have a non-negligible side effects on these AI fixes.
Member
Author
Yes, we should be more careful. |
Member
|
Thanks for looking at this issue so fast. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9176. Since #8966,
mecaalways resampled whatever CPT was given in-Cto span the depth range of the events being plotted. That discarded the z-range of a CPT the user had built withmakecpt, so beachball colors no longer matched the CPT (or acolorbardrawn from it), and even changed depending on which other events were in the input.Stretching should only happen when
-Cis 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