Repository navigation
Let makecpt honor the hinge during resampling - #2334
Conversation
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.
|
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: 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. |
|
The fact that the new scheme respects the hinge color transition makes a strong point in its favor. |
|
Yes, I also favor the new scheme. |
|
OK, I have implemented new aliasing scheme and update the PS files that changed. Test pass again now. Please review. |


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.