Skip to content

Let makecpt honor the hinge during resampling - #2334

Merged
PaulWessel merged 5 commits into
6.0from
samplecptfix
Dec 24, 2019
Merged

PaulWessel merged 5 commits into
6.0from
samplecptfix

Conversation

@PaulWessel

Copy link
Copy Markdown
Contributor

See #2327 for context. Unlike the auto-stretching that occurs when a master CPT is given to grdimage (stretched to fit the data range, considering any hinge), makecpt did not have any implementation that dealt with the hinge. This PR implements the algorithm that treats the two sides of the CPT differently. I will update the three PS failures due to the change before committing the PR after approval.

Unlike the auto-stretching that occurs when a master CPT is given to grdimage (stretched to fit the data range, considering any hinge), makecpt did not have any implementation that dealt with the hinge.  This PR implements the algorithm that treats the two sides of the CPT differently.
@PaulWessel

Copy link
Copy Markdown
Contributor Author

We have an aliasing issue when we do makecpt and request a discrete output table.

Consider master CPT earth which has 160 z-slices. Appendix M 1a asks for only 8 discrete colors. There is no averaging here, so we simply sample the values of the z-slice closest to each of the 8 points. We normally call this aliasing. In fixing the hinge problem I noticed we pick the half-way point in a slice to get the color. I.e., if the input table is continuous then we pick the z-value at the middle of the output slice and determine the nearest input slice to "sample" the colors from the slice. The alternative would be to just pick the start output z-value and find its nearest input slice. Below you seen the difference. The top is the new output by picking the lower (this accentuates the hinge color change) while the lower is the old output that picks the mid-point of the z-slice (this picks a color far from the hinge color change in most cases, especially when n_in >> n_out). You can see the new scheme picks the strong green just above sea level while the old would pick a color much higher up in the input table:

NEW SCHEME:
new

OLD SCHEME:
old

If we retain the old scheme then we have 3 failures, while the new scheme adds several of these M appendix plots plus a few others. Either scheme introduces some sort of aliasing, but perhaps a hinge should yield a clear difference across it for the discrete CPT as well, so I think the new scheme is better. Comments, @joa-quim and @seisman ?

I also think we should be more clear in saying that selecting discrete CPTs from continuous tables is a bad idea. Some of this comes from old GMT4 usage where we would run makecpt with zmin/zmax/zinc, but since GMT 5 we avoid the zinc unless you want a discrete table.

@joa-quim

Copy link
Copy Markdown
Member

The fact that the new scheme respects the hinge color transition makes a strong point in its favor.

@PaulWessel

Copy link
Copy Markdown
Contributor Author

What say you, @seisman? Maybe like @joa-quim says if we have to alias we might as well pick an alias that also accentuates the hinge?

@seisman

seisman commented Dec 23, 2019

Copy link
Copy Markdown
Member

Yes, I also favor the new scheme.

@PaulWessel

Copy link
Copy Markdown
Contributor Author

OK, I have implemented new aliasing scheme and update the PS files that changed. Test pass again now. Please review.

@PaulWessel
PaulWessel merged commit 0804a49 into 6.0 Dec 24, 2019
@PaulWessel
PaulWessel deleted the samplecptfix branch December 24, 2019 19:46
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.

3 participants