You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
makecpt in externals produce wrong CPTs when master has hinge #2327
Should be !mxIsNaN (hinge[0]), no? If NaN then no hinge, else there is a hinge at that value.
And should not P->hinge be set to hinge[0] if true? (default to zero so probably not the issue in this example, but the if-test is.
Problem is makecpt which is not doing the same thing as the auto-stretching (which does honor the hinge). Still think the mex code is wrong but that is not the problem here though. Will have to see where to fix it.
Fixing the lack of hinge-implementation in sample_cpt. Getting a few failures:
125 - GMT_tut_17.sh (Failed)
407 - grdmath/ops.sh (Failed)
458 - makecpt/logcpt.sh (Failed)
Looking at tut 17 we have the case that we now actually are honoring the hinge. Top is the new plot, bottom is the old:
You can see that since we run gmt makecpt -Cno_green -T-2/30/2 with a hinge at 0, then all the blue colors get squashed into the -2/0 range. Below is the original CPT from -1 to +1 with hinge at 0:
Only T = -2 and T = 0 (the hinge) samples the left half of the color scale. The resampled CPT is
You can clearly see that the colors right after the hinge (0) has red = 255, which is what the new resample does while the old makecpt with the bug does not convert to red until z = 14, way past the hinge. Thus I am pretty sure my revised sample_cpt fixes the bug. Agree @joa-quim and @seisman ?
No. One one hand the designer of the CPT deliberately designed it this way to use that hinge, so to override it could give usages that may look bad. On the other hand we want GMT to do anything, so perhaps makecpt and grd2cpt should have the ability to turn off the hinge. Running out of letters, so while makecpt -L is not used, there are no upper-case letters left for grd2cpt, meaning perhaps we use --ignore-hinge?
Another point to make is the pointlessness of people using things like -T-10000/2000/100. This is asking for degraded plots. Here is what @seisman example looks like after my fix:
You can see the 100 m discrete sampling in the CPT. Perhaps @joa-quim wanted that, perhaps not. By running the same example with just -T-10000/2000 we get this:
with a continuous change in color. This is preferred for images etc but perhaps the former is OK if you want to point constant color between contours in a colormap. As that interval gets larger, the aliasing gets worse.
Activity
PaulWessel commentedon Dec 22, 2019
This section in gmtmex_parser.c looks suspicious:
Should be
!mxIsNaN (hinge[0]), no? If NaN then no hinge, else there is a hinge at that value.And should not P->hinge be set to hinge[0] if true? (default to zero so probably not the issue in this example, but the if-test is.
seisman commentedon Dec 22, 2019
GMT command line gives the same result.
PaulWessel commentedon Dec 22, 2019
Problem is makecpt which is not doing the same thing as the auto-stretching (which does honor the hinge). Still think the mex code is wrong but that is not the problem here though. Will have to see where to fix it.
PaulWessel commentedon Dec 23, 2019
Fixing the lack of hinge-implementation in sample_cpt. Getting a few failures:
125 - GMT_tut_17.sh (Failed)
407 - grdmath/ops.sh (Failed)
458 - makecpt/logcpt.sh (Failed)
Looking at tut 17 we have the case that we now actually are honoring the hinge. Top is the new plot, bottom is the old:
You can see that since we run gmt makecpt -Cno_green -T-2/30/2 with a hinge at 0, then all the blue colors get squashed into the -2/0 range. Below is the original CPT from -1 to +1 with hinge at 0:
Only T = -2 and T = 0 (the hinge) samples the left half of the color scale. The resampled CPT is
while before the bug fix we get
with the original no_green (from -1 to +1 with hinge at 0):
You can clearly see that the colors right after the hinge (0) has red = 255, which is what the new resample does while the old makecpt with the bug does not convert to red until z = 14, way past the hinge. Thus I am pretty sure my revised sample_cpt fixes the bug. Agree @joa-quim and @seisman ?
PaulWessel commentedon Dec 23, 2019
BTW, the bug fix corrects @seisman's bug plot above as well.
seisman commentedon Dec 23, 2019
Looks good to me. BTW, is there an option to ignore hinge in the master CPT?
PaulWessel commentedon Dec 23, 2019
No. One one hand the designer of the CPT deliberately designed it this way to use that hinge, so to override it could give usages that may look bad. On the other hand we want GMT to do anything, so perhaps makecpt and grd2cpt should have the ability to turn off the hinge. Running out of letters, so while makecpt -L is not used, there are no upper-case letters left for grd2cpt, meaning perhaps we use --ignore-hinge?
PaulWessel commentedon Dec 23, 2019
Another point to make is the pointlessness of people using things like -T-10000/2000/100. This is asking for degraded plots. Here is what @seisman example looks like after my fix:
You can see the 100 m discrete sampling in the CPT. Perhaps @joa-quim wanted that, perhaps not. By running the same example with just -T-10000/2000 we get this:
with a continuous change in color. This is preferred for images etc but perhaps the former is OK if you want to point constant color between contours in a colormap. As that interval gets larger, the aliasing gets worse.
PaulWessel commentedon Dec 24, 2019
Please open a feature request if you feel ignoring the hinge is a needed option, @seisman.