From 89de73459298a981c092d92ed8f956b73470ac24 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Mon, 6 Jan 2020 17:29:02 -1000 Subject: [PATCH 01/40] Update how CPT hinges are done Separate between soft and hard hinges. Hard hinges are data driven like those for bathymetry or magnetics, while soft hinges are ignored unless +h[hinge] is given. --- doc/scripts/GMT_App_M_1a.ps | Bin 115041 -> 115085 bytes share/cpt/etopo1.cpt | 16 ++++++++-------- share/cpt/srtm.cpt | 21 +++++++++++---------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/doc/scripts/GMT_App_M_1a.ps b/doc/scripts/GMT_App_M_1a.ps index 03f22202637f6597897562698434d8cda0824d4a..e4b6a61df9416b4f39b54faf0d0abf8e4deb4c02 100644 GIT binary patch delta 3628 zcmWlb%kF}XoyF6nlO`tJbvcW_7ZgN5?gA<*iYTZEDhOTx1@VI5Z82Sp$;@_|bTW%R z$o~QQ2;KArn%T}n%&*(;cXM)*bI#`<|M9y&{paugeEe4&t?v&k7t{|2yS_G;|m_pwiFX=ej@_lg`xE3n7l`4v&(abrrJEy&jNwmnxg?MH4i!U62qtSkf z0xfWx`8mCOZOQ{+H+iBBV?ITFtNdYy{D_&e@E-0Np&o8DBHXB`0Tm-z|wWbk{(8sdvqXY%wvPn4$vO={?bbkz#?7f zSg;fsJee&^s(a`njZd(CR^UyYVU5U^D8+M0u=*~6oO5lJ1ytet z)jhf^d1D6-_OJ3K!_LjuW=}Tr>Cg}rh23hqkkjoxmHSE+ji?;J(#sGw0Q_EM^+ks$ zN5Ym>4D_JB#^oBNHjsz^9Bp-}+Ai+q#$BkCJ~dAA!v!bmyevZvt(o!7Q5j(D7e3px z5Et@z<*zL%H{xc>#Qb<<@|M72O3$wc zA~7tSwBR$?yV$0*4%Lv*=s87hB+S*KXNrvXmv&UGR&te?E8Z^W{vGEv{6joCsKX4h zAb1Bb{Z24|uiEbCiO|@rV7&Vu*sYSVe0q3~MNgH?FActd_l^wi^KQlKem*`-v)~5? z?Lq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2+m#+Kz6jyQEzAW@Y0$PB3gE>0{0jI;qYY1oQ2ALhF;18Yg5Xvca=kxYwm{&c6ezR84Bp zYjM8hNN-bltHKb%&eB8d-qAk(_3>TvE+$PkWmmI4&@W7Q{P3JDc26h0I)#L>A}Xz+ z`)a96JRTa;C=4HEY&~ek6V}D%*F`fk%=h?)6XkyHeqGkKx;Kl9!AcX78$oqOO3iB$ zuNplVNfIsTrO__wWX?%oMDf!&ux9Te2jtgUp(pM;vw;=4 z(zbbA;z{m#`oKfC-*%A|j&Irl5b~Fx21?Yi$If3%n~;jhsb);4-XXnR88CM3RzD=V z!VL}lWc}piM9hI4WxUiR)-?TyE$l?Y+q*{6+UlkQOwI$K?Z-uqT~fB915jy{qA3q`Q1Qiaa& zIV%R6j*Q3qmLEk+=v3bcr?>Bk8 z)$Pia7L;yzaYYWL$%k~d-Imhlo8KDGnmcJfl+}BlcQo;w(@GJbxHY2->Y-uekGD}@`}kHY zn%=ptmfu#sFPP>FyV2#7-Wh7_dGZaK)IF~ zWA6GW&TV#Bf;X(1yFHKfN=rK}m2d0aP7YZQu&YriO}X$SK0IKaC<2KO+9MJsg*zbh zps7Fv!C1g2c~5@9EP>`c)!0WxR(@jG1h$#9$A2mY(IIOx%ca|<=$i`H?Q`JrSfdWu6J2W gM9NiY{wLy}fBm)pztO+{MnmWKU;q4nfB(n7074cOX#fBK diff --git a/share/cpt/etopo1.cpt b/share/cpt/etopo1.cpt index b6a2d587a42..ca50fc965f1 100644 --- a/share/cpt/etopo1.cpt +++ b/share/cpt/etopo1.cpt @@ -9,15 +9,15 @@ # #---------------------------------------------------------- # COLOR_MODEL = RGB -# HINGE = -0.001 +# HINGE = 0 # RANGE = -11000/8500 #---------------------------------------------------------- --1 10/0/121 -0.954590904963 26/0/137 +-1.000000000000 10/0/121 -0.954590904963 26/0/137 -0.954590904963 26/0/137 -0.909181809926 38/0/152 -0.909181809926 38/0/152 -0.863772714888 27/3/166 -0.863772714888 27/3/166 -0.818363619851 16/6/180 -0.818363619851 16/6/180 -0.772954524814 5/9/193 --0.772954524814 5/9/193 -0.727545429777 0/14/203 +-0.772954524814 5/9/193 -0.727545429777 0/14/203 -0.727545429777 0/14/203 -0.68213633474 0/22/210 -0.68213633474 0/22/210 -0.636727239702 0/30/216 -0.636727239702 0/30/216 -0.591318144665 0/39/223 @@ -31,10 +31,10 @@ -0.273454479405 43/186/255 -0.228045384368 55/193/255 -0.228045384368 55/193/255 -0.182636289331 65/200/255 -0.182636289331 65/200/255 -0.137227194293 79/210/255 --0.137227194293 79/210/255 -0.0918180992562 94/223/255 --0.0918180992562 94/223/255 -0.046409004219 138/227/255 --0.046409004219 138/227/255 -0.001 188/230/255 --0.001 51/102/0 0.0107765869675 51/204/102 +-0.137227194293 79/210/255 -0.091818099256 94/223/255 +-0.091818099256 94/223/255 -0.046409004219 138/227/255 +-0.046409004219 138/227/255 0.0000000000000 188/230/255 +0.0000000000000 51/102/0 0.0107765869675 51/204/102 0.0107765869675 51/204/102 0.0225530561702 187/228/146 0.0225530561702 187/228/146 0.0578824637785 255/220/185 0.0578824637785 255/220/185 0.116764809792 243/202/137 @@ -52,7 +52,7 @@ 0.764470615945 183/147/147 0.823352961958 194/176/176 0.823352961958 194/176/176 0.882235307972 205/204/203 0.882235307972 205/204/203 0.941117653986 230/229/228 -0.941117653986 230/229/228 1 255/254/253 +0.941117653986 230/229/228 1.000000000000 255/254/253 #---------------------------------------------------------- B 10/0/121 F white diff --git a/share/cpt/srtm.cpt b/share/cpt/srtm.cpt index 532e674fe0e..f39f512e9a0 100644 --- a/share/cpt/srtm.cpt +++ b/share/cpt/srtm.cpt @@ -3,17 +3,18 @@ # Designed by P. Wessel, SOEST #------------------------------------------------ # COLOR_MODEL = RGB -# HINGE = 1 -# RANGE = 1/1500 +# HINGE = 0 +# RANGE = -8000/8000 #------------------------------------------------ --1 blue 1 blue -1 0/97/71 16.2959183674 16/122/47 -16.2959183674 16/122/47 153.959183674 232/215/125 -153.959183674 232/215/125 368.102040817 161/67/0 -368.102040817 161/67/0 521.061224489 100/50/25 -521.061224489 100/50/25 857.571428572 110/109/108 -857.571428572 110/109/108 1224.67346939 255/254/253 -1224.67346939 255/254/253 1500 255/254/253 +-1.000000 blue 0.000000 blue +0.000000 blue 0.000001 blue +0.000001 0/97/71 0.010204 16/122/47 +0.010204 16/122/47 0.102041 232/215/125 +0.102041 232/215/125 0.244898 161/67/0 +0.244898 161/67/0 0.346939 100/50/25 +0.346939 100/50/25 0.571429 110/109/108 +0.571429 110/109/108 0.816327 255/254/253 +0.816327 255/254/253 1.000000 255/254/253 B blue F white N blue From 5cbef760d676448bf5246ff63cb20e4396bcd550 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Tue, 7 Jan 2020 13:01:30 -1000 Subject: [PATCH 02/40] Updates so far - in progress --- share/cpt/berlin.cpt | 2 +- share/cpt/broc.cpt | 4 +- share/cpt/cork.cpt | 4 +- share/cpt/earth.cpt | 4 +- share/cpt/etopo1.cpt | 2 +- share/cpt/geo.cpt | 4 +- share/cpt/globe.cpt | 2 +- share/cpt/lisbon.cpt | 4 +- share/cpt/mag.cpt | 2 +- share/cpt/no_green.cpt | 2 +- share/cpt/oleron.cpt | 4 +- share/cpt/polar.cpt | 2 +- share/cpt/red2green.cpt | 2 +- share/cpt/relief.cpt | 2 +- share/cpt/sealand.cpt | 2 +- share/cpt/split.cpt | 4 +- share/cpt/srtm.cpt | 2 +- share/cpt/terra.cpt | 4 +- share/cpt/tofino.cpt | 4 +- share/cpt/topo.cpt | 2 +- share/cpt/vik.cpt | 4 +- share/cpt/world.cpt | 2 +- src/gmt_api.c | 3 +- src/gmt_io.c | 2 +- src/gmt_resources.h | 6 ++- src/gmt_support.c | 108 ++++++++++++++++++++++++++++------------ src/makecpt.c | 4 +- 27 files changed, 118 insertions(+), 69 deletions(-) diff --git a/share/cpt/berlin.cpt b/share/cpt/berlin.cpt index 5846c34c877..2f9422200f8 100644 --- a/share/cpt/berlin.cpt +++ b/share/cpt/berlin.cpt @@ -11,7 +11,7 @@ # #---------------------------------------------------------- # COLOR_MODEL = RGB -# HINGE = 0 +# SOFT_HINGE #---------------------------------------------------------- -1.000000 158/176/255 -0.992156 156/176/254 -0.992156 156/176/254 -0.984314 154/176/253 diff --git a/share/cpt/broc.cpt b/share/cpt/broc.cpt index f44263828de..02e4bd13eaf 100644 --- a/share/cpt/broc.cpt +++ b/share/cpt/broc.cpt @@ -7,11 +7,11 @@ # Copyright (c) 2018, Fabio Crameri All rights reserved. # Crameri, F., (2018). Scientific colour-maps. Zenodo. http://doi.org/10.5281/zenodo.1243862 # Note: Original file converted to GMT version >= 5 CPT format. -# Note: Range changed from 0-1 to -1/+1 to place hinge at zero. +# Note: Range changed from 0-1 to -1/+1 to place soft hinge at zero. # #---------------------------------------------------------- # COLOR_MODEL = RGB -# HINGE = 0 +# SOFT_HINGE #---------------------------------------------------------- -1.000000 44/26/76 -0.992156 44/27/78 -0.992156 44/27/78 -0.984314 44/29/79 diff --git a/share/cpt/cork.cpt b/share/cpt/cork.cpt index 512d859f00c..e9c75552117 100644 --- a/share/cpt/cork.cpt +++ b/share/cpt/cork.cpt @@ -7,11 +7,11 @@ # Copyright (c) 2018, Fabio Crameri All rights reserved. # Crameri, F., (2018). Scientific colour-maps. Zenodo. http://doi.org/10.5281/zenodo.1243862 # Note: Original file converted to GMT version >= 5 CPT format. -# Note: Range changed from 0-1 to -1/+1 to place hinge at zero. +# Note: Range changed from 0-1 to -1/+1 to place soft hinge at zero. # #---------------------------------------------------------- # COLOR_MODEL = RGB -# HINGE = 0 +# SOFT_HINGE #---------------------------------------------------------- -1.000000 44/26/76 -0.992156 44/27/78 -0.992156 44/27/78 -0.984314 44/29/79 diff --git a/share/cpt/earth.cpt b/share/cpt/earth.cpt index 6ec64c82ff1..6ea955bb61f 100644 --- a/share/cpt/earth.cpt +++ b/share/cpt/earth.cpt @@ -1,10 +1,10 @@ # # Color table for Earth's relief combining the bathy -# and dem4 CPTs with a hinge at 0. +# and dem4 CPTs with a HARD hinge at 0. # Designed by P. Wessel, SOEST #------------------------------------------------ # COLOR_MODEL = RGB -# HINGE = 0 +# HARD_HINGE # RANGE = -11000/9000 #------------------------------------------------ -1 black -0.875 31/40/79 diff --git a/share/cpt/etopo1.cpt b/share/cpt/etopo1.cpt index ca50fc965f1..f43a516492c 100644 --- a/share/cpt/etopo1.cpt +++ b/share/cpt/etopo1.cpt @@ -9,7 +9,7 @@ # #---------------------------------------------------------- # COLOR_MODEL = RGB -# HINGE = 0 +# HARD_HINGE # RANGE = -11000/8500 #---------------------------------------------------------- -1.000000000000 10/0/121 -0.954590904963 26/0/137 diff --git a/share/cpt/geo.cpt b/share/cpt/geo.cpt index e1cef26a576..04857ab69d5 100644 --- a/share/cpt/geo.cpt +++ b/share/cpt/geo.cpt @@ -1,10 +1,10 @@ # # Color table for Earth's relief combining the gebco -# and dem1 CPTs with a hinge at 0. +# and dem1 CPTs with a hard hinge at 0. # Designed by P. Wessel, SOEST #------------------------------------------------ # COLOR_MODEL = RGB -# HINGE = 0 +# HARD_HINGE # RANGE = -8000/8000 #------------------------------------------------ -1 black -0.875 20/30/53 diff --git a/share/cpt/globe.cpt b/share/cpt/globe.cpt index 04031c4be10..f3c4c7aba8b 100644 --- a/share/cpt/globe.cpt +++ b/share/cpt/globe.cpt @@ -6,7 +6,7 @@ # #---------------------------------------------------------- # COLOR_MODEL = RGB -# HINGE = 0 +# HARD_HINGE # RANGE = -10000/10000 #---------------------------------------------------------- -1 153/0/255 -0.95 153/0/255 diff --git a/share/cpt/lisbon.cpt b/share/cpt/lisbon.cpt index ca201116c55..0f8c3430544 100644 --- a/share/cpt/lisbon.cpt +++ b/share/cpt/lisbon.cpt @@ -7,11 +7,11 @@ # Copyright (c) 2018, Fabio Crameri All rights reserved. # Crameri, F., (2018). Scientific colour-maps. Zenodo. http://doi.org/10.5281/zenodo.1243862 # Note: Original file converted to GMT version >= 5 CPT format. -# Note: Range changed from 0-1 to -1/+1 to place hinge at zero. +# Note: Range changed from 0-1 to -1/+1 to place soft hinge at zero. # #---------------------------------------------------------- # COLOR_MODEL = RGB -# HINGE = 0 +# SOFT_HINGE #---------------------------------------------------------- -1.000000 230/229/255 -0.992156 227/227/253 -0.992156 227/227/253 -0.984314 224/226/252 diff --git a/share/cpt/mag.cpt b/share/cpt/mag.cpt index a10d6ff0158..592e51aab88 100644 --- a/share/cpt/mag.cpt +++ b/share/cpt/mag.cpt @@ -2,7 +2,7 @@ # IPGP Color table for magnetic anomaly maps #------------------------------------------------ # COLOR_MODEL = RGB -# HINGE = 0 +# HARD_HINGE # RANGE = -2000/2000 #------------------------------------------------ -1 0/0/204 -0.3 0/0/204 diff --git a/share/cpt/no_green.cpt b/share/cpt/no_green.cpt index d1602ecab30..78366604f7d 100644 --- a/share/cpt/no_green.cpt +++ b/share/cpt/no_green.cpt @@ -5,7 +5,7 @@ # #---------------------------------------------------------- # COLOR_MODEL = RGB -# HINGE = 0 +# SOFT_HINGE #---------------------------------------------------------- -1 32/96/255 -0.875 32/96/255 -0.875 32/159/255 -0.75 32/159/255 diff --git a/share/cpt/oleron.cpt b/share/cpt/oleron.cpt index bdc940ddb84..77aceec202f 100644 --- a/share/cpt/oleron.cpt +++ b/share/cpt/oleron.cpt @@ -7,11 +7,11 @@ # Copyright (c) 2018, Fabio Crameri All rights reserved. # Crameri, F., (2018). Scientific colour-maps. Zenodo. http://doi.org/10.5281/zenodo.1243862 # Note: Original file converted to GMT version >= 5 CPT format. -# Note: Range changed from 0-1 to -1/+1 to place hinge at zero. +# Note: Range changed from 0-1 to -1/+1 to place hard hinge at zero. # #---------------------------------------------------------- # COLOR_MODEL = RGB -# HINGE = 0 +# HARD_HINGE #---------------------------------------------------------- -1.000000 26/38/89 -0.992156 27/40/91 -0.992156 27/40/91 -0.984314 29/41/92 diff --git a/share/cpt/polar.cpt b/share/cpt/polar.cpt index f7678410083..6155b7bcbcc 100644 --- a/share/cpt/polar.cpt +++ b/share/cpt/polar.cpt @@ -3,7 +3,7 @@ # #---------------------------------------------------------- # COLOR_MODEL = RGB -# HINGE = 0 +# SOFT_HINGE #---------------------------------------------------------- -1 blue 0 white 0 white 1 red diff --git a/share/cpt/red2green.cpt b/share/cpt/red2green.cpt index f059519f813..15dd98d6aa7 100644 --- a/share/cpt/red2green.cpt +++ b/share/cpt/red2green.cpt @@ -4,7 +4,7 @@ # #---------------------------------------------------------- # COLOR_MODEL = RGB -# HINGE = 0 +# SOFT_HINGE #---------------------------------------------------------- -1 red 0 white 0 white 1 green diff --git a/share/cpt/relief.cpt b/share/cpt/relief.cpt index d357a59b381..b03c88643ff 100644 --- a/share/cpt/relief.cpt +++ b/share/cpt/relief.cpt @@ -4,7 +4,7 @@ # #---------------------------------------------------------- # COLOR_MODEL = RGB -# HINGE = 0 +# HARD_HINGE # RANGE = -8000/8000 #---------------------------------------------------------- -1 black -0.875 0/5/25 diff --git a/share/cpt/sealand.cpt b/share/cpt/sealand.cpt index 8e6814d87b2..6e6684b0dfd 100644 --- a/share/cpt/sealand.cpt +++ b/share/cpt/sealand.cpt @@ -4,7 +4,7 @@ # #---------------------------------------------------------- # COLOR_MODEL = hsv -# HINGE = 0 +# HARD_HINGE # RANGE = -6000/3000 #---------------------------------------------------------- -1 255-0.6-1 -0.916666666667 240-0.6-1 diff --git a/share/cpt/split.cpt b/share/cpt/split.cpt index 52e274399d0..da4ad4543cb 100644 --- a/share/cpt/split.cpt +++ b/share/cpt/split.cpt @@ -1,10 +1,10 @@ # -# Split colors that has black around midpoint +# Split colors that has black around midpoint hinge # Designed by P. Wessel, SOEST # #---------------------------------------------------------- # COLOR_MODEL = RGB -# HINGE = 0 +# SOFT_HINGE #---------------------------------------------------------- -1 128/128/255 -0.5 0/0/128 -0.5 0/0/128 0 0/0/0 diff --git a/share/cpt/srtm.cpt b/share/cpt/srtm.cpt index f39f512e9a0..5fc82ba6e0a 100644 --- a/share/cpt/srtm.cpt +++ b/share/cpt/srtm.cpt @@ -3,7 +3,7 @@ # Designed by P. Wessel, SOEST #------------------------------------------------ # COLOR_MODEL = RGB -# HINGE = 0 +# HARD_HINGE # RANGE = -8000/8000 #------------------------------------------------ -1.000000 blue 0.000000 blue diff --git a/share/cpt/terra.cpt b/share/cpt/terra.cpt index a635702c9bd..7c542222969 100644 --- a/share/cpt/terra.cpt +++ b/share/cpt/terra.cpt @@ -1,11 +1,11 @@ # # Color table for Earth's relief combining the seafloor -# and elevation CPTs with a hinge at 0. +# and elevation CPTs with a hard hinge at 0. # Designed by P. Wessel, SOEST # #---------------------------------------------------------- # COLOR_MODEL = RGB -# HINGE = 0 +# HARD_HINGE # RANGE = -7000/7000 #---------------------------------------------------------- -1 105/0/182 -0.958333333333 110/0/188 diff --git a/share/cpt/tofino.cpt b/share/cpt/tofino.cpt index 78bd15344c5..41181999de8 100644 --- a/share/cpt/tofino.cpt +++ b/share/cpt/tofino.cpt @@ -7,11 +7,11 @@ # Copyright (c) 2018, Fabio Crameri All rights reserved. # Crameri, F., (2018). Scientific colour-maps. Zenodo. http://doi.org/10.5281/zenodo.1243862 # Note: Original file converted to GMT version >= 5 CPT format. -# Note: Range changed from 0-1 to -1/+1 to place hinge at zero. +# Note: Range changed from 0-1 to -1/+1 to place soft hinge at zero. # #---------------------------------------------------------- # COLOR_MODEL = RGB -# HINGE = 0 +# SOFT_HINGE #---------------------------------------------------------- -1.000000 222/217/255 -0.992156 219/215/254 -0.992156 219/215/254 -0.984314 217/213/253 diff --git a/share/cpt/topo.cpt b/share/cpt/topo.cpt index 5c549335442..12d5ba4b211 100644 --- a/share/cpt/topo.cpt +++ b/share/cpt/topo.cpt @@ -4,7 +4,7 @@ # #---------------------------------------------------------- # COLOR_MODEL = hsv -# HINGE = 0 +# HARD_HINGE # RANGE = -7000/7000 #---------------------------------------------------------- -1 290-0.45-0.85 -0.928571428571 265-0.45-0.85 diff --git a/share/cpt/vik.cpt b/share/cpt/vik.cpt index 9999b93f629..d0b34641767 100644 --- a/share/cpt/vik.cpt +++ b/share/cpt/vik.cpt @@ -7,11 +7,11 @@ # Copyright (c) 2018, Fabio Crameri All rights reserved. # Crameri, F., (2018). Scientific colour-maps. Zenodo. http://doi.org/10.5281/zenodo.1243862 # Note: Original file converted to GMT version >= 5 CPT format. -# Note: Range changed from 0-1 to -1/+1 to place hinge at zero. +# Note: Range changed from 0-1 to -1/+1 to place soft hinge at zero. # #---------------------------------------------------------- # COLOR_MODEL = RGB -# HINGE = 0 +# SOFT_HINGE #---------------------------------------------------------- -1.000000 1/18/97 -0.992156 1/19/98 -0.992156 1/19/98 -0.984314 1/21/99 diff --git a/share/cpt/world.cpt b/share/cpt/world.cpt index 5e3cf5bf564..41117418711 100644 --- a/share/cpt/world.cpt +++ b/share/cpt/world.cpt @@ -4,7 +4,7 @@ # Designed by P. Wessel, SOEST #---------------------------------------------------------- # COLOR_MODEL = RGB -# HINGE = 0 +# HARD_HINGE # RANGE = -7000/7000 #---------------------------------------------------------- -1 0/240/255 -0.857142857143 0/240/255 diff --git a/src/gmt_api.c b/src/gmt_api.c index bd55d574f56..14879267ab4 100644 --- a/src/gmt_api.c +++ b/src/gmt_api.c @@ -7145,7 +7145,8 @@ void *GMT_Read_Data (void *V_API, unsigned int family, unsigned int method, unsi size_t len = strlen (file), elen; char *ext = (len > 4 && strstr (file, ".cpt")) ? "" : ".cpt", *q = NULL; elen = strlen (ext); - if ((q = gmtlib_file_unitscale (file))) q[0] = '\0'; /* Truncate modifier */ + if ((q = gmtlib_file_unitscale (file))) q[0] = '\0'; /* Truncate modifier */ + else if ((q = strstr (file, "+h"))) q[0] = '\0'; /* Truncate +h modifier */ if (elen) /* Master: Append extension and supply path */ gmt_getsharepath (API->GMT, "cpt", file, ext, CPT_file, R_OK); else if (!gmt_getdatapath (API->GMT, file, CPT_file, R_OK)) { /* Use name.cpt as is but look for it */ diff --git a/src/gmt_io.c b/src/gmt_io.c index e0ca6efdee5..eeb3b3c6f3e 100644 --- a/src/gmt_io.c +++ b/src/gmt_io.c @@ -5096,7 +5096,7 @@ int gmt_access (struct GMT_CTRL *GMT, const char* filename, int mode) { return (-1); /* It happens for example when parsing grdmath args and it finds an isolated "=" */ if ((c = gmtlib_file_unitscale (file))) c[0] = '\0'; /* Chop off any x/u unit specification */ - else if ((c = strchr (file, '+')) && strchr ("ons", c[1])) c[0] = '\0'; /* Chop off any z-scaling specification */ + else if ((c = strchr (file, '+')) && strchr ("hons", c[1])) c[0] = '\0'; /* Chop off any +h hinge setting or any z-scaling specification */ if (mode == W_OK) return (access (file, mode)); /* When writing, only look in current directory */ if (mode == R_OK || mode == F_OK) { /* Look in special directories when reading or just checking for existence */ diff --git a/src/gmt_resources.h b/src/gmt_resources.h index 97258a5ce44..764b7ba46e1 100644 --- a/src/gmt_resources.h +++ b/src/gmt_resources.h @@ -563,8 +563,10 @@ enum GMT_enum_cpt { enum GMT_enum_cptflags { GMT_CPT_NO_BNF = 1, GMT_CPT_EXTEND_BNF = 2, - GMT_CPT_HINGED = 4, - GMT_CPT_TIME = 8, + GMT_CPT_HARD_HINGE = 4, + GMT_CPT_SOFT_HINGE = 8, + GMT_CPT_TIME = 16, + GMT_CPT_HINGED = 4 /* Backwards compatibility with 6.0 API */ }; /* Here is the definition of the GMT_PALETTE structure that is used in programs diff --git a/src/gmt_support.c b/src/gmt_support.c index bc302238cde..0270c3eabba 100644 --- a/src/gmt_support.c +++ b/src/gmt_support.c @@ -1197,15 +1197,37 @@ GMT_LOCAL struct CPT_Z_SCALE *support_cpt_parse (struct GMT_CTRL *GMT, char *fil } #endif -/*! Decode the optional +u|U and determine scales */ -GMT_LOCAL struct CPT_Z_SCALE *support_cpt_parse (struct GMT_CTRL *GMT, char *file, unsigned int direction) { +/*! Decode the optional +u|U and determine scales and +h[] for hinge control */ +GMT_LOCAL struct CPT_Z_SCALE *support_cpt_parse (struct GMT_CTRL *GMT, char *file, unsigned int direction, unsigned int *hinge_mode, double *z_hinge) { + /* CPT file arg is [+h[]][+u|U] + * The +h modifier is used to turn a soft hinge in a CPT to a hard hinge at the user-selected z-value [0] + * It has no effect on hard hinges. */ enum gmt_enum_units u_number; unsigned int mode = 0; char *c = NULL; struct CPT_Z_SCALE *Z = NULL; gmt_M_unused(direction); - if ((c = gmtlib_file_unitscale (file)) == NULL) return NULL; /* Did not find any modifier */ + *hinge_mode = 0; /* Default is no hinge modifier */ + if ((c = strstr (file, "+h"))) { /* Gave hinge modifier, examine and set parameters */ + if (c[2]) { /* Gave hinge value for soft hinge */ + if (gmt_verify_expectations (GMT, gmt_M_type (GMT, GMT_IN, GMT_Z), gmt_scanf (GMT, &c[2], gmt_M_type (GMT, GMT_IN, GMT_Z), z_hinge), &c[2])) { + GMT_Report (GMT->parent, GMT_MSG_NORMAL, "support_cpt_parse: CPT hinge modifier %s was not successfully parsed and is ignored.\n", c); + } + else { /* Parsed successfully, this turns a soft CPT hinge to a hard user hinge */ + c[0] = '\0'; /* Chop off the hinge specification from the file name */ + GMT_Report (GMT->parent, GMT_MSG_LONG_VERBOSE, "support_cpt_parse: CPT hard hinge was added at z = %s for file %s\n", &c[2], file); + *hinge_mode = 1; + } + } + else { /* Accept zero as hard hinge value */ + *hinge_mode = 1; + c[0] = '\0'; /* Chop off the hinge specification from the file name */ + GMT_Report (GMT->parent, GMT_MSG_LONG_VERBOSE, "support_cpt_parse: CPT CPT hard hinge was added at z = 0 for file %s\n", file); + } + } + + if ((c = gmtlib_file_unitscale (file)) == NULL) return NULL; /* Did not find any +u|U modifiers */ mode = (c[1] == 'u') ? 0 : 1; u_number = gmtlib_get_unit_number (GMT, c[2]); /* Convert char unit to enumeration constant for this unit */ if (u_number == GMT_IS_NOUNIT) { @@ -1225,11 +1247,11 @@ GMT_LOCAL struct CPT_Z_SCALE *support_cpt_parse (struct GMT_CTRL *GMT, char *fil /*! . */ GMT_LOCAL int support_find_cpt_hinge (struct GMT_CTRL *GMT, struct GMT_PALETTE *P) { - /* Return the slice number where z_low == hinge */ + /* Return the slice number where z_low' = 0 for a CPT with hinge and normalized z' = -1 to +1 */ unsigned int k; - if (!P->has_hinge) return GMT_NOTSET; - for (k = 0; k < P->n_colors; k++) if (doubleAlmostEqualZero (P->hinge, P->data[k].z_low)) { - GMT_Report (GMT->parent, GMT_MSG_DEBUG, "Found CPT hinge = %g for slice k = %u!\n", P->hinge, k); + if (!P->has_hinge) return GMT_NOTSET; /* Does not have any hinge */ + for (k = 0; k < P->n_colors; k++) if (doubleAlmostEqualZero (0.0, P->data[k].z_low)) { + GMT_Report (GMT->parent, GMT_MSG_DEBUG, "Found CPT hinge at z' = 0 for slice k = %u!\n", k); return (int)k; } return GMT_NOTSET; @@ -7172,11 +7194,11 @@ struct GMT_PALETTE * gmtlib_read_cpt (struct GMT_CTRL *GMT, void *source, unsign * GMT_CPT_EXTEND_BNF = Make B and F equal to low and high color */ - unsigned int n = 0, i, nread, annot, id, n_cat_records = 0, color_model; + unsigned int n = 0, i, nread, annot, id, n_cat_records = 0, color_model, hinge_mode = 0; size_t k; bool gap, overlap, error = false, close_file = false, check_headers = true; size_t n_alloc = GMT_SMALL_CHUNK, n_hdr_alloc = 0; - double dz; + double dz, z_hinge; char T0[GMT_LEN64] = {""}, T1[GMT_LEN64] = {""}, T2[GMT_LEN64] = {""}, T3[GMT_LEN64] = {""}, T4[GMT_LEN64] = {""}; char T5[GMT_LEN64] = {""}, T6[GMT_LEN64] = {""}, T7[GMT_LEN64] = {""}, T8[GMT_LEN64] = {""}, T9[GMT_LEN64] = {""}; char line[GMT_BUFSIZ] = {""}, clo[GMT_LEN64] = {""}, chi[GMT_LEN64] = {""}, c, cpt_file[PATH_MAX] = {""}; @@ -7190,7 +7212,7 @@ struct GMT_PALETTE * gmtlib_read_cpt (struct GMT_CTRL *GMT, void *source, unsign if (source_type == GMT_IS_FILE) { /* source is a file name */ strncpy (cpt_file, source, PATH_MAX-1); - Z = support_cpt_parse (GMT, cpt_file, GMT_IN); + Z = support_cpt_parse (GMT, cpt_file, GMT_IN, &hinge_mode, &z_hinge); if ((fp = fopen (cpt_file, "r")) == NULL) { GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Cannot open color palette table %s\n", cpt_file); gmt_M_free (GMT, Z); @@ -7270,12 +7292,22 @@ struct GMT_PALETTE * gmtlib_read_cpt (struct GMT_CTRL *GMT, void *source, unsign } continue; /* Don't want this instruction to be also kept as a comment */ } - else if ((h = strstr (line, "HINGE ="))) { /* CPT is hinged at this z value */ - X->mode &= GMT_CPT_HINGED; - X->has_hinge = 1; - k = 7; while (h[k] == ' ' || h[k] == '\t') k++; /* Skip any leading spaces or tabs */ - gmt_scanf_arg (GMT, &h[k], GMT_IS_UNKNOWN, false, &X->hinge); - continue; /* Don't want this instruction to be also kept as a comment */ + else if (strstr (line, "HINGE")) { /* CPT has either a soft or hard hinge */ + if ((h = strstr (line, "HINGE ="))) { /* Bad mix of old CPTs with new GMT parsing - treat as hard hinge */ + GMT_Report (GMT->parent, GMT_MSG_VERBOSE, "Mixing old CPT master tables with HINGE = in %s. Interpreted as HARD_HINGE.\n", cpt_file); + X->mode |= GMT_CPT_HARD_HINGE; + X->has_hinge = 1; + continue; /* Don't want this instruction to be also kept as a comment */ + } + else if (strstr (line, "HARD_HINGE")) { /* Hard hinge the user cannot override */ + X->mode |= GMT_CPT_HARD_HINGE; + X->has_hinge = 1; + continue; /* Don't want this instruction to be also kept as a comment */ + } + else if (strstr (line, "SOFT_HINGE")) { /* Soft hinge the user can select via +h[] */ + X->mode |= GMT_CPT_SOFT_HINGE; + continue; /* Don't want this instruction to be also kept as a comment */ + } } else if ((h = strstr (line, "RANGE ="))) { /* CPT has a default range */ k = 7; while (h[k] == ' ' || h[k] == '\t') k++; /* Skip any leading spaces or tabs */ @@ -7372,6 +7404,13 @@ struct GMT_PALETTE * gmtlib_read_cpt (struct GMT_CTRL *GMT, void *source, unsign continue; } + if (hinge_mode && X->mode & GMT_CPT_SOFT_HINGE) { /* Add a hard hinge to the CPT */ + X->mode -= GMT_CPT_SOFT_HINGE; + X->mode |= GMT_CPT_HARD_HINGE; + X->has_hinge = 1; + X->hinge = z_hinge; /* THis is now a user-selected hinge value */ + } + /* Here we have regular z-slices. Allowable formats are * * key [;