diff --git a/doc/examples/ex19/ex19.sh b/doc/examples/ex19/ex19.sh index e410df353e2..75654457130 100755 --- a/doc/examples/ex19/ex19.sh +++ b/doc/examples/ex19/ex19.sh @@ -7,7 +7,7 @@ gmt begin ex19 gmt grdmath -Rd -I1 -r Y COSD 2 POW = lat.nc gmt grdmath X = lon.nc - gmt makecpt -Cwhite,blue -T0,1 -Z -N -H > lat.cpt + gmt makecpt -Cwhite,blue -T0/1 -N -H > lat.cpt gmt makecpt -Crainbow -T-180/180 -H > lon.cpt gmt subplot begin 3x1 -Fs6.5i/0 -M0 -Bbltr -Rd -JI0/6.5i # First make a worldmap with graded blue oceans and rainbow continents diff --git a/doc/rst/source/colorbar_common.rst_ b/doc/rst/source/colorbar_common.rst_ index 659a71f8e39..2f29c9866ef 100644 --- a/doc/rst/source/colorbar_common.rst_ +++ b/doc/rst/source/colorbar_common.rst_ @@ -48,8 +48,7 @@ Optional Arguments is given then we read stdin. By default all color changes are annotated. To use a subset, add an extra column to the CPT with a L, U, or B to annotate Lower, Upper, or Both - color segment boundaries (but see **-B**). If not given, the module - will read stdin. Like :doc:`grdview`, we can understand + color segment boundaries (but see **-B**). Like :doc:`grdview`, we can understand pattern specifications in the CPT. For CPTs where the *z* range is in meters, it may be useful to change to another unit when plotting. To do so, append **+U**\ *unit* to the file name. diff --git a/doc/rst/source/common_SYN_OPTs.rst_ b/doc/rst/source/common_SYN_OPTs.rst_ index baf0d18416f..93e8b8c066e 100644 --- a/doc/rst/source/common_SYN_OPTs.rst_ +++ b/doc/rst/source/common_SYN_OPTs.rst_ @@ -40,7 +40,7 @@ .. |SYN_OPT-i| replace:: **-i**\ :ref:`flags <-icols_full>` -.. |SYN_OPT-j| replace:: **-j**\ :ref:`flags ` +.. |SYN_OPT-j| replace:: **-j**\ :ref:`flags <-distcalc_full>` .. |SYN_OPT-l| replace:: **-l**\ :ref:`flags <-l_full>` diff --git a/doc/rst/source/cookbook/cpts.rst b/doc/rst/source/cookbook/cpts.rst index d74da597ed3..14f04a3eee2 100644 --- a/doc/rst/source/cookbook/cpts.rst +++ b/doc/rst/source/cookbook/cpts.rst @@ -17,6 +17,8 @@ original color scale, which can be either discrete or continuous, though some (like **globe**) are a mix of the two. The bottom half the color bar are built by using :doc:`/makecpt` **-T**-1/1/0.25, thus splitting the color scale into 8 discrete colors. +Black and white triangles indicate which tables have hard or soft hinges, +respectively. .. _CPT_files_a: diff --git a/doc/rst/source/cookbook/features.rst b/doc/rst/source/cookbook/features.rst index f3e5eb60f4c..791f011113a 100644 --- a/doc/rst/source/cookbook/features.rst +++ b/doc/rst/source/cookbook/features.rst @@ -1128,17 +1128,31 @@ Master (dynamic) CPTs The CPTs distributed with GMT are *dynamic*. This means they have several special properties that modify the behavior of programs that use them. -All dynamic CPTs are normalized in one of two ways: If a CPT was designed +Dynamic CPTs comes in a few different flavors: Some CPTs were designed to behave differently across a *hinge* value (e.g., a CPT designed specifically for topographic relief may include a discontinuity in color across the -coastline at *z = 0*), then the CPT's *z*-values will range from -1, via 0 -at the hinge, to +1 at the other end. The hinge value is specified via the special -comment - -| ``# HINGE = `` - -CPTs without a hinge are instead normalized with *z*-values from 0 to 1. -Dynamic CPTs will need to be stretched to the user's preferred range, and there +coastline at *z = 0*), and when users select these CPTs they will be stretched +to fit the user's desired data range separately for each side of this *hard* hinge. +Basically, a *hard* hinge CPT is the juxtaposition of two different CPTs joined +at the hinge and these sections are stretched independently. Such CPT files +are identified as such via the special comment + +| ``# HARD_HINGE`` + +and all hard hinges occur at data value *z = 0* (but you can change this value by +adding **+h**\ *value* to the name of the CPT). +Other CPTs may instead have a *soft* hinge which indicates a natural hinge or transition +point in the CPT itself, unrelated to any natural data set *per se*. These CPTs +are flagged by the special comment + +| ``# SOFT_HINGE`` + +CPTs with soft hinges behave as regular (non-hinge) CPTs *unless* the user activates then by +appending **+h**\ [*hinge*] to the CPT name. This modifier will convert the soft +hinge into a hard hinge at the user-specified data value *hinge* [which defaults to 0]. +Note that if your specified data range *excludes* an activated soft or hard hinge then we +only perform color sampling from the *half* of the CPT that pertains to the data range. +All dynamic CPTs will need to be stretched to the user's preferred range, and there are two modes of such scaling: Some CPTs designed for a specific application (again, the topographic relief is a good example) have a *default range* specified in the master table via the special comment @@ -1146,27 +1160,59 @@ specified in the master table via the special comment | ``# RANGE = `` -and when used by applications the normalized *z*-values will be stretched to reflect -this natural range. In contrast, CPTs without a natural range are instead +and when used by applications the CPT may be automatically stretched to reflect +this natural range. In contrast, dynamic CPTs *without* a natural range are instead stretched to fit the range of the data in question (e.g., a grid's range). -Exceptions to these rules are implemented in the two CPT-producing modules +Exceptions to these rules are implemented in the two *CPT-producing* modules :doc:`/makecpt` and :doc:`/grd2cpt`, both of which can read dynamic CPTs and produce *static* CPTs satisfying a user's specific range needs. These -tools can also read static CPTs where the new range must be specified (or computed +tools can also read static CPTs for which a new range must be specified (or computed from data), reversing the order of colors, and even isolating a section -of an incoming CPT. Here, :doc:`/makecpt` can be told the range of compute it from data tables -while :doc:`/grd2cpt` can derive the range from one or more grids. +of an incoming CPT. Here, :doc:`/makecpt` can be told the data range or compute +it from data tables while :doc:`/grd2cpt` can derive the range from one or more grids. .. figure:: /_images/GMT_hinge.* :width: 500 px :align: center - The top color bar is a dynamic master CPT (here, globe) with a hinge at sea level and + The top color bar is a dynamic master CPT (here, globe) with a hard hinge at sea level and a natural range from -10,000 to +10,000 meters. However, our data range is asymmetrical, going from -8,000 meter depths up to +3,000 meter elevations. Because of the hinge, the two sides of the CPT will be stretched separately to honor the desired range while utilizing the full color range. +All CPT master tables can be found in Chapter :ref:`Of Colors and Color Legends` +where those with hard or soft hinges are identified by triangles at their hinges. + +CPTs from color lists +~~~~~~~~~~~~~~~~~~~~~ + +GMT can build color tables "on the fly" from a comma-separated list of colors +and a range of *z*-values to go with them. As illustrated below, there are +four different ways to create such CPTs. In this example, we will operate with +a list of three colors: red,yellow and purple, given to modules with the option **-C**\ red,yellow,purple, +and utilize a fixed data range of *z = 0-6*. +Four different CPTs result because we either select a *continuous* or *discrete table*, and because the *z*-intervals are +either *equidistant* or *arbitrary*. The top continuous color table with equidistant spacing (a) is selected +with the range **-T**\ 0/6, meaning the colors will continuously change from red (at *z = 0*) via +yellow (at *z = 3*) to purple (at *z = 6*). Next, a discrete table with the same range (b) +is obtained with **-T**\ 0/6/2, yielding colors that are either constant red (*z = 0-2*), yellow (*z = 2-4*) +or purple (*z = 4-6*). The next discrete table (c) illustrates how to specify arbitrary +node points in the CPT by providing a comma-separated list of values (**-T**\ 0,4,5.5,6). Now, the constant +color intervals have unequal ranges, illustrated by red (*z = 0-4*), yellow (*z = 4-5.5*) and purple (*z = 5.5-6*). Finally, we +create a continuous color table (d) with arbitrary nodes by giving **-T**\ 0,2,6 and adding **-Z**; +the latter option forces a continuous CPT pinned to a given list of node values. Now, the colors +continuously change from red (at *z = 0*) via yellow (at *z = 2*) to purple (at *z = 6*). +Modules that obtain the *z*-range indirectly (e.g., :doc:`/grdimage`) may use the exact data range +to set the quivalent of a **-T**\ *min/max* option. You may append **+i**\ *dz* to the +color list to have the *min* and *max* values rounded down and up to nearest multiple of *dz*, respectively. + +.. figure:: /_images/GMT_colorlist.* + :width: 500 px + :align: center + + Lists of colors (here red,yellow,purple) can be turned into discrete or continuous CPT tables on the fly. + Cyclic (wrapped) CPTs ~~~~~~~~~~~~~~~~~~~~~ @@ -1227,7 +1273,10 @@ A few modules (:doc:`/grdimage`, :doc:`/grdview`) that expects a CPT option will provide a default CPT if none is provided. By default, the default CPT is the "turbo" color table, but this is overridden if the user uses the @eart_relief (we select "geo") or @srtm_relief (we select "srtm") data sets. After selection, -these CPTs are read and scaled to match the range of the grid values. +these CPTs are read and scaled to match the range of the grid values. You may append +**+i**\ *dz* to the CPT to have the exact range rounded to nearest multiple of *dz*. +THis is helpful if you plan to place a colorbar and prefer start and stop *z*-values +that are multiples of *dz*. The Drawing of Vectors ---------------------- @@ -2544,4 +2593,3 @@ any of these directories. .. [19] Requires building GMT with GDAL. - diff --git a/doc/rst/source/explain_cpt.rst_ b/doc/rst/source/cpt_notes.rst_ similarity index 100% rename from doc/rst/source/explain_cpt.rst_ rename to doc/rst/source/cpt_notes.rst_ diff --git a/doc/rst/source/create_cpt.rst_ b/doc/rst/source/create_cpt.rst_ new file mode 100644 index 00000000000..02fa4d71341 --- /dev/null +++ b/doc/rst/source/create_cpt.rst_ @@ -0,0 +1,11 @@ +**-C**\ [*cpt*\ \|\ *master*\ [**+h**\ [*hinge*]][**+i**\ *zinc*][**+u**\ \|\ **U**\ *unit*] \|\ *color1,color2*\ [,\ *color3*\ ,...]] + Name of the CPT. If given a GMT Master soft-hinge CPT (see :ref:`Of Colors and Color Legends`) then + you can enable the hinge at data value *hinge* [0] via **+h**, whereas for hard-hinge CPTs you + can adjust the location of the hinge [0]. For other CPTs, you may convert their *z*-values + from meter to another distance unit (append **+U**\ *unit*) or from another unit to meter (append **+u**\ *unit*), + with *unit* taken from **e**\ \|\ **f**\ \|\ **k**\ \|\ **M**\ \|\ **n**\ \|\ **u**. + Alternatively, give *color1,color2*\ [*,color3*\ ,...] + to build a linear continuous CPT from those colors automatically, + where *z* starts at 0 and is incremented by one for each color. + In this case *color*\ **n** can be a r/g/b triplet, a color name, + or an HTML hexadecimal color (e.g. #aabbcc). diff --git a/doc/rst/source/explain_distcalc.rst_ b/doc/rst/source/explain_distcalc.rst_ index 3cf41345c79..b22e5535f07 100644 --- a/doc/rst/source/explain_distcalc.rst_ +++ b/doc/rst/source/explain_distcalc.rst_ @@ -1,2 +1,2 @@ -**-je**\ \|\ **f**\ \|\ **g** :ref:`(more ...) ` +**-je**\ \|\ **f**\ \|\ **g** :ref:`(more ...) <-distcalc_full>` Determine how spherical distances are calculated. diff --git a/doc/rst/source/explain_distcalc_full.rst_ b/doc/rst/source/explain_distcalc_full.rst_ index 89bb88c14df..e6df35f0441 100644 --- a/doc/rst/source/explain_distcalc_full.rst_ +++ b/doc/rst/source/explain_distcalc_full.rst_ @@ -1,4 +1,4 @@ -.. _distcalc_full: +.. _-distcalc_full: **-je**\ \|\ **f**\ \|\ **g** Determine how spherical distances are calculated in modules that support this. diff --git a/doc/rst/source/grd2cpt.rst b/doc/rst/source/grd2cpt.rst index 5eb1848a6ee..9c965838951 100644 --- a/doc/rst/source/grd2cpt.rst +++ b/doc/rst/source/grd2cpt.rst @@ -90,15 +90,7 @@ Optional Arguments .. _-C: - -**-C**\ *cpt* - Selects the master color table to use in the interpolation. Choose - among the built-in tables (type **grd2cpt** to see the list) or give - the name of an existing CPT [Default gives the turbo CPT]. - Yet another option is to specify -Ccolor1,color2[,color3,...] - to build a linear continuous CPT from those colors automatically. - In this case *color*\ **n** can be a r/g/b triplet, a color name, - or an HTML hexadecimal color (e.g. #aabbcc ). +.. include:: create_cpt.rst_ .. _-D: @@ -213,15 +205,13 @@ Optional Arguments **-W**\ [**w**] Do not interpolate the input color table but pick the output colors starting at the beginning of the map. This is particularly useful in - combination with a categorical color table. Cannot be used in - combination with **-Z**. Alternatively, use **-Ww** to produce - a wrapped (cyclic) color table that endlessly repeats its range. + combination with a categorical color table. Alternatively, use **-Ww** + to produce a wrapped (cyclic) color table that endlessly repeats its range. .. _-Z: **-Z** - Will create a continuous color palette. [Default is discontinuous, - i.e., constant color intervals] + Force a continuous CPT [Default is discontinuous]. .. include:: explain_help.rst_ @@ -229,14 +219,28 @@ Optional Arguments .. include:: explain_transparency.rst_ -Color Aliasing --------------- - -For best result when **-E** is used we recommend you do no append -a specific *nlevels*. This way the original CPT is used exactly -as is but the *z* boundaries are adjusted to match the grid limits. -Otherwise you may, depending on the nature of the input CPT, miss -aspects of the color changes by aliasing the signal. +Color Hinges +------------ + +Some of the GMT master dynamic CPTs are actually two separate CPTs +meeting at a *hinge*. Usually, colors may change dramatically across +the hinge, which is used to separate two different domains (e.g., land +and ocean across the shoreline, for instance). CPTs with a hinge will +have their two parts stretched to the required range separately, i.e., +the bottom part up to the hinge will be stretched independently of the +part from the hinge to the top, according to the prescribed new range. +Hinges are either *hard* or *soft*. Soft hinges must be *activated* by +appending **+h**\ [*hinge*] to the CPT name. +If the selected range does not include an activated soft or hard hinge then +we only resample colors from the half of the CPT that pertains to the range. +See :ref:`Of Colors and Color Legends` for more information. + +Discrete versus Continuous CPT +------------------------------ + +All CPTs can be stretched, but only continuous CPTs can be sampled +at new nodes (i.e., by given an increment in **-T**). We impose this +limitation to avoid aliasing the original CPT. Examples -------- @@ -265,7 +269,7 @@ file relief, run gmt grd2cpt mydata.nc -Crelief -L0/10000 -T0/200/20 > mydata.cpt -.. include:: explain_cpt.rst_ +.. include:: cpt_notes.rst_ See Also -------- diff --git a/doc/rst/source/grd2kml.rst b/doc/rst/source/grd2kml.rst index 43354582626..9b4d6dc7bc0 100644 --- a/doc/rst/source/grd2kml.rst +++ b/doc/rst/source/grd2kml.rst @@ -54,17 +54,7 @@ Optional Arguments .. _-C: -**-C**\ [*cpt* \|\ *master*\ [**+i**\ *zinc*] \|\ *color1,color2*\ [,\ *color3*\ ,...]] - Name of the CPT (for *grd_z* only). Alternatively, - supply the name of a GMT color master dynamic CPT [turbo, but geo - for @earth_relief and srtm for @srtm_relief data] to - automatically determine a continuous CPT from - the grid's z-range; you may round up/down the z-range by adding **+i**\ *zinc*. - Yet another option is to specify **-C**\ *color1*\ ,\ *color2*\ [,\ *color3*\ ,...] - to build a linear continuous CPT from those colors automatically. - In this case *color1* etc can be a r/g/b triplet, a color name, - or an HTML hexadecimal color (e.g. #aabbcc ). If no argument is given to **-C** - then under modern mode we select the current CPT. +.. include:: use_cpt_grd.rst_ .. _-E: diff --git a/doc/rst/source/grdimage.rst b/doc/rst/source/grdimage.rst index f8e9d804217..13c345db1b8 100644 --- a/doc/rst/source/grdimage.rst +++ b/doc/rst/source/grdimage.rst @@ -75,7 +75,7 @@ remotely located Jessica Rabbit:: gmt grdimage -JI15c -Rd http://larryfire.files.wordpress.com/2009/07/untooned_jessicarabbit.jpg -pdf jess -.. include:: explain_cpt.rst_ +.. include:: cpt_notes.rst_ See Also -------- diff --git a/doc/rst/source/grdimage_common.rst_ b/doc/rst/source/grdimage_common.rst_ index deae3d709a5..fb11261afae 100644 --- a/doc/rst/source/grdimage_common.rst_ +++ b/doc/rst/source/grdimage_common.rst_ @@ -66,17 +66,7 @@ Optional Arguments .. _-C: -**-C**\ [*cpt* \|\ *master*\ [**+i**\ *zinc*] \|\ *color1,color2*\ [,\ *color3*\ ,...]] - Name of the CPT (for *grd_z* only). Alternatively, - supply the name of a GMT color master dynamic CPT [turbo, but geo - for @earth_relief and srtm for @srtm_relief data] to - automatically determine a continuous CPT from - the grid's z-range; you may round up/down the z-range by adding **+i**\ *zinc*. - Yet another option is to specify **-C**\ *color1*\ ,\ *color2*\ [,\ *color3*\ ,...] - to build a linear continuous CPT from those colors automatically. - In this case *color1* etc can be a r/g/b triplet, a color name, - or an HTML hexadecimal color (e.g. #aabbcc ). If no argument is given to **-C** - then under modern mode we select the current CPT. +.. include:: use_cpt_grd.rst_ .. _-D: diff --git a/doc/rst/source/grdvector_common.rst_ b/doc/rst/source/grdvector_common.rst_ index ff4ae2b71fc..d57bf84e507 100644 --- a/doc/rst/source/grdvector_common.rst_ +++ b/doc/rst/source/grdvector_common.rst_ @@ -37,16 +37,7 @@ Optional Arguments .. _-C: -**-C**\ [*cpt* \|\ *master*\ [**+i**\ *zinc*] \|\ *color1,color2*\ [,\ *color3*,...]] - Use *cpt* to assign colors based on vector length. Alternatively, - supply the name of a GMT color master dynamic CPT [turbo] to - automatically determine a continuous CPT from - the grid's z-range; you may round up/down the z-range by adding **+i**\ *zinc*.. - Yet another option is to specify **-C**\ *color1,color2*\ [,\ *color3*,...] - to build a linear continuous cpt from those colors automatically. - In this case *color*\ **n** can be a r/g/b triplet, a color name, - or an HTML hexadecimal color (e.g. #aabbcc ). If no argument is given to **-C** - then under modern mode we select the current CPT. +.. include:: use_cpt_grd.rst_ .. _-G: diff --git a/doc/rst/source/grdview_common.rst_ b/doc/rst/source/grdview_common.rst_ index 313c634c1fe..a1227a58caf 100644 --- a/doc/rst/source/grdview_common.rst_ +++ b/doc/rst/source/grdview_common.rst_ @@ -33,18 +33,7 @@ Optional Arguments .. _-C: -**-C**\ [*cpt* \|\ *master*\ [**+i**\ *zinc*] \|\ *color1,color2*\ [,\ *color3*\ ,...]] - The name of the CPT. Must be present if you want - (1) mesh plot with contours (**-Qm**), or - (2) shaded/colored perspective image (**-Qs** or - **-Qi**). For **-Qs**: You can specify that you want to skip a - z-slice by setting the red r/g/b component to -; to use a pattern give red = - **P\|p**\ *pattern*\ [**+b**\ *color*\ ][**+f**\ *color*\ ][**+r**\ *dpi*\ ]. - Alternatively, supply the name of a GMT color master dynamic CPT [turbo, but - geo for @earth_relief and srtm for @srtm_relief data] to - automatically determine a continuous CPT from - the grid's z-range; you may round up/down the z-range by adding **+i**\ *zinc*. - If no argument is given to **-C** then under modern mode we select the current CPT. +.. include:: use_cpt_grd.rst_ .. _-G: diff --git a/doc/rst/source/makecpt.rst b/doc/rst/source/makecpt.rst index 61c24dcbf52..1a9a9eb1e91 100644 --- a/doc/rst/source/makecpt.rst +++ b/doc/rst/source/makecpt.rst @@ -84,14 +84,7 @@ Optional Arguments .. _-C: -**-C**\ *cpt* - Selects the master color table CPT to use in the interpolation. - Choose among the built-in tables (type **makecpt** to see the list) - or give the name of an existing CPT [Default gives the turbo CPT]. - Yet another option is to specify -Ccolor1,color2[,color3,...] - to build a linear continuous cpt from those colors automatically. - In this case *color*\ **n** can be a r/g/b triplet, a color name, - or an HTML hexadecimal color (e.g. #aabbcc ). +.. include:: create_cpt.rst_ .. _-D: @@ -206,18 +199,14 @@ Optional Arguments Do not interpolate the input color table but pick the output colors starting at the beginning of the color table, until colors for all intervals are assigned. This is particularly useful in combination - with a categorical color table, like "categorical". Cannot be used - in combination with **-Z**. Alternatively, use **-Ww** to produce - a wrapped (cyclic) color table that endlessly repeats its range. + with a categorical color table, like "categorical". Alternatively, + use **-Ww** to produce a wrapped (cyclic) color table that endlessly + repeats its range. .. _-Z: **-Z** - Creates a continuous CPT [Default is discontinuous, i.e., - constant colors for each interval]. This option has no effect when no **-T** - is used, or when using **-T**\ *z_min*/*z_max*; in the first case the input - CPT remains untouched, in the second case it is only scaled to match the - range *z_min*/*z_max*. + Force a continuous CPT when building from a list of colors and a list of *z*-values [discrete]. .. |Add_-bi| replace:: [Default is the required number of columns given the chosen settings]. .. include:: explain_-bi.rst_ @@ -243,17 +232,18 @@ and ocean across the shoreline, for instance). CPTs with a hinge will have their two parts stretched to the required range separately, i.e., the bottom part up to the hinge will be stretched independently of the part from the hinge to the top, according to the prescribed new range. -If the selected range does not include the hinge then no such partitioning -takes place. +Hinges are either *hard* or *soft*. Soft hinges must be *activated* by +appending **+h**\ [*hinge*] to the CPT name. +If the selected range does not include an activated soft or hard hinge then +we only resample colors from the half of the CPT that pertains to the range. +See :ref:`Of Colors and Color Legends` for more information. -Color Aliasing --------------- +Discrete versus Continuous CPT +------------------------------ -For best result when **-T -Z** is used we recommend you do no append -a specific *z_inc*. This way the original CPT is used exactly -as is but the *z* boundaries are adjusted to match the stated limits. -Otherwise you may, depending on the nature of the input CPT, miss -aspects of the color changes by aliasing the signal. +All CPTs can be stretched, but only continuous CPTs can be sampled +at new nodes (i.e., by given an increment in **-T**). We impose this +limitation to avoid aliasing the original CPT. Examples -------- @@ -272,7 +262,7 @@ continuous default turbo rainbow of colors: :: - gmt makecpt -T-2/6 -Z > colors.cpt + gmt makecpt -T-2/6 > colors.cpt To use the GEBCO look-alike CPT with its default range for bathymetry, run @@ -286,7 +276,7 @@ the remote ata table v3206_06.txt (with lon, lat, depths), run :: - gmt makecpt -Cgebco @v3206_06.txt -i2 -Z -E24 > my_depths.cpt + gmt makecpt -Cgebco @v3206_06.txt -E24 > my_depths.cpt To use the gebco color table but reverse the z-values so it can be used for positive depth values, try @@ -307,8 +297,8 @@ To make a continuous CPT from white to blue as z goes from 3 to 10, try :: - - gmt makecpt -Cwhite,blue -T3,10 -Z > cold.cpt + + gmt makecpt -Cwhite,blue -T3/10 > cold.cpt To make a wrapped (cyclic) CPT from the jet table over the interval 0 to 500, i.e., the color will be wrapped every 500 z-units so that @@ -318,7 +308,7 @@ we always get a color regardless of the *z* value, try gmt makecpt -Cjet -T0/500 -Ww > wrapped.cpt -.. include:: explain_cpt.rst_ +.. include:: cpt_notes.rst_ Bugs ---- diff --git a/doc/rst/source/std_opts.rst b/doc/rst/source/std_opts.rst index 202ab1b058c..e0a60d052b9 100644 --- a/doc/rst/source/std_opts.rst +++ b/doc/rst/source/std_opts.rst @@ -42,7 +42,7 @@ Common Options +--------------------------------------------------------------------------+--------------------------------------------------------------------------+ | **-i**\ *columns* | Selection of input columns :ref:`(...) <-icols_full>` | +--------------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-je**\ \|\ **f**\ \|\ **g** | Mode of spherical distance calculation :ref:`(...) ` | +| **-je**\ \|\ **f**\ \|\ **g** | Mode of spherical distance calculation :ref:`(...) <-distcalc_full>` | +--------------------------------------------------------------------------+--------------------------------------------------------------------------+ | **-l**\ [*label*]\ [*modifiers*] | Add an item to the automatic plot legend :ref:`(...) <-l_full>` | +--------------------------------------------------------------------------+--------------------------------------------------------------------------+ diff --git a/doc/rst/source/use_cpt_grd.rst_ b/doc/rst/source/use_cpt_grd.rst_ new file mode 100644 index 00000000000..57318d8aac8 --- /dev/null +++ b/doc/rst/source/use_cpt_grd.rst_ @@ -0,0 +1,15 @@ +**-C**\ [*cpt*\ \|\ *master*\ [**+h**\ [*hinge*]][**+i**\ *zinc*][**+u**\ \|\ **U**\ *unit*] \|\ *color1,color2*\ [,\ *color3*\ ,...]] + Name of the CPT. Alternatively, supply the name of a GMT color master + dynamic CPT [*turbo*, but we use *geo* for @earth_relief and *srtm* for @srtm_relief data] to + automatically determine a continuous CPT from the grid's *z*-range; you may round the range + to the nearest multiple of *zinc* by adding **+i**\ *zinc*. If given a GMT Master soft-hinge CPT + (see :ref:`Of Colors and Color Legends`) then you can enable the hinge at data value *hinge* [0] via **+h**, + whereas for hard-hinge CPTs you can adjust the location of the hinge [0]. + For other CPTs, you may convert their *z*-values from meter to another distance unit (append **+U**\ *unit*) + or from another unit to meter (append **+u**\ *unit*), with *unit* taken from + **e**\ \|\ **f**\ \|\ **k**\ \|\ **M**\ \|\ **n**\ \|\ **u**. + Yet another option is to specify **-C**\ *color1*\ ,\ *color2*\ [,\ *color3*\ ,...] + to build a linear continuous CPT from those colors automatically. + In this case *color*\ **n** can be a r/g/b triplet, a color name, + or an HTML hexadecimal color (e.g. #aabbcc). If no argument is given to **-C** + then under modern mode we select the current CPT. diff --git a/doc/scripts/GMT_App_M_1a.ps b/doc/scripts/GMT_App_M_1a.ps index 03f22202637..0b2727de107 100644 Binary files a/doc/scripts/GMT_App_M_1a.ps and b/doc/scripts/GMT_App_M_1a.ps differ diff --git a/doc/scripts/GMT_App_M_1a.sh b/doc/scripts/GMT_App_M_1a.sh index fc659bc9b96..670c38fd433 100755 --- a/doc/scripts/GMT_App_M_1a.sh +++ b/doc/scripts/GMT_App_M_1a.sh @@ -7,6 +7,8 @@ # 44 original GMT 5 CPTs and the last page has 24 scientific colormaps # from Fabio [www.fabiocrameri.ch/visualisation] +GMT_SHAREDIR=`gmt --show-sharedir` + cat << EOF > skip.lis acton bamako @@ -57,9 +59,17 @@ do j=`expr $i + 1` left=`sed -n ${j}p tt.lis` right=`sed -n ${i}p tt.lis` - gmt makecpt -H -C$left > tt.left.cpt + if [ "$left" = "categorical" ]; then + gmt makecpt -H -C$left > tt.left.cpt + else + gmt makecpt -H -C$left -T-1/1 > tt.left.cpt + fi gmt makecpt -H -C$left -T-1/1/0.25 > tt.left2.cpt - gmt makecpt -H -C$right > tt.right.cpt + if [ "$right" = "categorical" ]; then + gmt makecpt -H -C$right > tt.right.cpt + else + gmt makecpt -H -C$right -T-1/1 > tt.right.cpt + fi gmt makecpt -H -C$right -T-1/1/0.25 > tt.right2.cpt gmt colorbar -D1.55i/${y}i+w2.70i/0.125i+h+jTC -Ctt.left.cpt -B0 gmt colorbar -D4.50i/${y}i+w2.70i/0.125i+h+jTC -Ctt.right.cpt -B0 @@ -69,6 +79,16 @@ do 1.55 $y ${left} 4.50 $y ${right} END + if [ `grep -c HARD_HINGE ${GMT_SHAREDIR}/cpt/${left}.cpt` -eq 1 ]; then # Plot hard hinge symbol for left CPT + echo 1.55 $y | gmt plot -St0.2c -Gblack -Wfaint -D0/-0.29i + elif [ `grep -c SOFT_HINGE ${GMT_SHAREDIR}/cpt/${left}.cpt` -eq 1 ]; then # Plot soft hinge symbol for left CPT + echo 1.55 $y | gmt plot -St0.2c -Gwhite -Wfaint -D0/-0.29i + fi + if [ `grep -c HARD_HINGE ${GMT_SHAREDIR}/cpt/${right}.cpt` -eq 1 ]; then # Plot hard hinge symbol for right CPT + echo 4.50 $y | gmt plot -St0.2c -Gblack -Wfaint -D0/-0.29i + elif [ `grep -c SOFT_HINGE ${GMT_SHAREDIR}/cpt/${right}.cpt` -eq 1 ]; then # Plot soft hinge symbol for right CPT + echo 4.50 $y | gmt plot -St0.2c -Gwhite -Wfaint -D0/-0.29i + fi i=`expr $i + 2` y=`gmt math -Q $y $dy ADD =` y2=`gmt math -Q $y2 $dy ADD =` diff --git a/doc/scripts/GMT_App_M_1b.ps b/doc/scripts/GMT_App_M_1b.ps index 3083f1815d0..b6d9c3bb4b0 100644 Binary files a/doc/scripts/GMT_App_M_1b.ps and b/doc/scripts/GMT_App_M_1b.ps differ diff --git a/doc/scripts/GMT_App_M_1b.sh b/doc/scripts/GMT_App_M_1b.sh index f34c1a730e0..b7876e12d91 100755 --- a/doc/scripts/GMT_App_M_1b.sh +++ b/doc/scripts/GMT_App_M_1b.sh @@ -7,6 +7,8 @@ # 44 original GMT 5 CPTs and the last page has 24 scientific colormaps # from Fabio [www.fabiocrameri.ch/visualisation] +GMT_SHAREDIR=`gmt --show-sharedir` + cat << EOF > skip.lis acton bamako @@ -56,9 +58,17 @@ do j=`expr $i + 1` left=`sed -n ${j}p tt.lis` right=`sed -n ${i}p tt.lis` - gmt makecpt -H -C$left > tt.left.cpt + if [ "$left" = "paired" ]; then + gmt makecpt -H -C$left > tt.left.cpt + else + gmt makecpt -H -C$left -T-1/1 > tt.left.cpt + fi gmt makecpt -H -C$left -T-1/1/0.25 > tt.left2.cpt - gmt makecpt -H -C$right > tt.right.cpt + if [ "$right" = "paired" ]; then + gmt makecpt -H -C$right > tt.right.cpt + else + gmt makecpt -H -C$right -T-1/1 > tt.right.cpt + fi gmt makecpt -H -C$right -T-1/1/0.25 > tt.right2.cpt gmt colorbar -D1.55i/${y}i+w2.70i/0.125i+h+jTC -Ctt.left.cpt -B0 gmt colorbar -D4.50i/${y}i+w2.70i/0.125i+h+jTC -Ctt.right.cpt -B0 @@ -68,6 +78,16 @@ do 1.55 $y ${left} 4.50 $y ${right} END + if [ `grep -c HARD_HINGE ${GMT_SHAREDIR}/cpt/${left}.cpt` -eq 1 ]; then # Plot hard hinge symbol for left CPT + echo 1.55 $y | gmt plot -St0.2c -Gblack -Wfaint -D0/-0.29i + elif [ `grep -c SOFT_HINGE ${GMT_SHAREDIR}/cpt/${left}.cpt` -eq 1 ]; then # Plot soft hinge symbol for left CPT + echo 1.55 $y | gmt plot -St0.2c -Gwhite -Wfaint -D0/-0.29i + fi + if [ `grep -c HARD_HINGE ${GMT_SHAREDIR}/cpt/${right}.cpt` -eq 1 ]; then # Plot hard hinge symbol for right CPT + echo 4.50 $y | gmt plot -St0.2c -Gblack -Wfaint -D0/-0.29i + elif [ `grep -c SOFT_HINGE ${GMT_SHAREDIR}/cpt/${right}.cpt` -eq 1 ]; then # Plot soft hinge symbol for right CPT + echo 4.50 $y | gmt plot -St0.2c -Gwhite -Wfaint -D0/-0.29i + fi i=`expr $i + 2` y=`gmt math -Q $y $dy ADD =` y2=`gmt math -Q $y2 $dy ADD =` diff --git a/doc/scripts/GMT_App_M_1c.ps b/doc/scripts/GMT_App_M_1c.ps index 4b111ffb9da..2425f22ffb3 100644 Binary files a/doc/scripts/GMT_App_M_1c.ps and b/doc/scripts/GMT_App_M_1c.ps differ diff --git a/doc/scripts/GMT_App_M_1c.sh b/doc/scripts/GMT_App_M_1c.sh index 94aa434e445..3a234f836b0 100755 --- a/doc/scripts/GMT_App_M_1c.sh +++ b/doc/scripts/GMT_App_M_1c.sh @@ -7,6 +7,8 @@ # 44 original GMT 5 CPTs and the last page has 24 scientific colormaps # from Fabio [www.fabiocrameri.ch/visualisation] +GMT_SHAREDIR=`gmt --show-sharedir` + cat << EOF > tt.lis acton bamako @@ -53,9 +55,9 @@ do j=`expr $i + 1` left=`sed -n ${j}p tt.lis` right=`sed -n ${i}p tt.lis` - gmt makecpt -H -C$left > tt.left.cpt + gmt makecpt -H -C$left -T-1/1 > tt.left.cpt gmt makecpt -H -C$left -T-1/1/0.25 > tt.left2.cpt - gmt makecpt -H -C$right > tt.right.cpt + gmt makecpt -H -C$right -T-1/1 > tt.right.cpt gmt makecpt -H -C$right -T-1/1/0.25 > tt.right2.cpt gmt colorbar -D1.55i/${y}i+w2.70i/0.125i+h+jTC -Ctt.left.cpt -B0 gmt colorbar -D4.50i/${y}i+w2.70i/0.125i+h+jTC -Ctt.right.cpt -B0 @@ -65,6 +67,16 @@ do 1.55 $y ${left} 4.50 $y ${right} END + if [ `grep -c HARD_HINGE ${GMT_SHAREDIR}/cpt/${left}.cpt` -eq 1 ]; then # Plot hard hinge symbol for left CPT + echo 1.55 $y | gmt plot -St0.2c -Gblack -Wfaint -D0/-0.29i + elif [ `grep -c SOFT_HINGE ${GMT_SHAREDIR}/cpt/${left}.cpt` -eq 1 ]; then # Plot soft hinge symbol for left CPT + echo 1.55 $y | gmt plot -St0.2c -Gwhite -Wfaint -D0/-0.29i + fi + if [ `grep -c HARD_HINGE ${GMT_SHAREDIR}/cpt/${right}.cpt` -eq 1 ]; then # Plot hard hinge symbol for right CPT + echo 4.50 $y | gmt plot -St0.2c -Gblack -Wfaint -D0/-0.29i + elif [ `grep -c SOFT_HINGE ${GMT_SHAREDIR}/cpt/${right}.cpt` -eq 1 ]; then # Plot soft hinge symbol for right CPT + echo 4.50 $y | gmt plot -St0.2c -Gwhite -Wfaint -D0/-0.29i + fi i=`expr $i + 2` y=`gmt math -Q $y $dy ADD =` y2=`gmt math -Q $y2 $dy ADD =` diff --git a/doc/scripts/GMT_colorlist.ps b/doc/scripts/GMT_colorlist.ps new file mode 100644 index 00000000000..7c5cb00b806 Binary files /dev/null and b/doc/scripts/GMT_colorlist.ps differ diff --git a/doc/scripts/GMT_colorlist.sh b/doc/scripts/GMT_colorlist.sh new file mode 100755 index 00000000000..994c731cbe0 --- /dev/null +++ b/doc/scripts/GMT_colorlist.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Illustrate 4 ways to build a CPT form a list of colors +gmt begin GMT_colorlist + gmt makecpt -T0,2,6 -Cred,yellow,purple -Z + gmt colorbar -R0/4/0/4 -Jx1i -C -Bx -By+l"d)" -Dx0/0+w5i/0.2i+h+mu + echo "5.1 0 -T0,2,6 -Cred,yellow,purple -Z" | gmt text -F+f12p+jLB -N + gmt makecpt -T0,4,5.5,6 -Cred,yellow,purple + gmt colorbar -C -Bxf1 -By+l"c)" -Dx0/0+w5i/0.2i+h+mu -Y0.3i + echo "5.1 0 -T0,4,5.5,6 -Cred,yellow,purple" | gmt text -F+f12p+jLB -N + gmt makecpt -T0/6/2 -Cred,yellow,purple + gmt colorbar -C -Bxf1 -By+l"b)" -Dx0/0+w5i/0.2i+h+mu -Y0.3i + echo "5.1 0 -T0/6/2 -Cred,yellow,purple" | gmt text -F+f12p+jLB -N + gmt makecpt -T0/6 -Cred,yellow,purple + gmt colorbar -C -Bxf1 -By+l"a)" -Dx0/0+w5i/0.2i+h+mu -Y0.3i + echo "5.1 0 -T0/6 -Cred,yellow,purple" | gmt text -F+f12p+jLB -N +gmt end show diff --git a/doc/scripts/GMT_tut_17.ps b/doc/scripts/GMT_tut_17.ps index 0ed59d534e6..d5de993e0f2 100644 Binary files a/doc/scripts/GMT_tut_17.ps and b/doc/scripts/GMT_tut_17.ps differ diff --git a/doc/scripts/GMT_tut_19.ps b/doc/scripts/GMT_tut_19.ps index 6f9ea4423c0..77971547741 100644 Binary files a/doc/scripts/GMT_tut_19.ps and b/doc/scripts/GMT_tut_19.ps differ diff --git a/doc/scripts/GMT_tut_19.sh b/doc/scripts/GMT_tut_19.sh index 83d228cd3be..bce1e68919f 100755 --- a/doc/scripts/GMT_tut_19.sh +++ b/doc/scripts/GMT_tut_19.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash gmt begin GMT_tut_19 - gmt makecpt -Ctopo -T1000/5000 + gmt makecpt -Cdem2 -T1000/5000 gmt grdgradient @tut_relief.nc -Ne0.8 -A100 -fg -Gus_i.nc gmt grdview tut_relief.nc -JM4i -p135/35 -Qi50 -Ius_i.nc -B -JZ0.5i -C gmt end show 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 b6a2d587a42..f43a516492c 100644 --- a/share/cpt/etopo1.cpt +++ b/share/cpt/etopo1.cpt @@ -9,15 +9,15 @@ # #---------------------------------------------------------- # COLOR_MODEL = RGB -# HINGE = -0.001 +# HARD_HINGE # 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/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/haxby.cpt b/share/cpt/haxby.cpt index a332d805183..ab4c33ac8c7 100644 --- a/share/cpt/haxby.cpt +++ b/share/cpt/haxby.cpt @@ -4,36 +4,35 @@ #---------------------------------------------------------- # COLOR_MODEL = RGB #---------------------------------------------------------- -0 10/0/121 0.03125 10/0/121 -0.03125 40/0/150 0.0625 40/0/150 -0.0625 20/5/175 0.09375 20/5/175 -0.09375 0/10/200 0.125 0/10/200 -0.125 0/25/212 0.15625 0/25/212 -0.15625 0/40/224 0.1875 0/40/224 -0.1875 26/102/240 0.21875 26/102/240 -0.21875 13/129/248 0.25 13/129/248 -0.25 25/175/255 0.28125 25/175/255 -0.28125 50/190/255 0.3125 50/190/255 -0.3125 68/202/255 0.34375 68/202/255 -0.34375 97/225/240 0.375 97/225/240 -0.375 106/235/225 0.40625 106/235/225 -0.40625 124/235/200 0.4375 124/235/200 -0.4375 138/236/174 0.46875 138/236/174 -0.46875 172/245/168 0.5 172/245/168 -0.5 205/255/162 0.53125 205/255/162 -0.53125 223/245/141 0.5625 223/245/141 -0.5625 240/236/121 0.59375 240/236/121 -0.59375 247/215/104 0.625 247/215/104 -0.625 255/189/87 0.65625 255/189/87 -0.65625 255/160/69 0.6875 255/160/69 -0.6875 244/117/75 0.71875 244/117/75 -0.71875 238/80/78 0.75 238/80/78 -0.75 255/90/90 0.78125 255/90/90 -0.78125 255/124/124 0.8125 255/124/124 -0.8125 255/158/158 0.84375 255/158/158 -0.84375 245/179/174 0.875 245/179/174 -0.875 255/196/196 0.90625 255/196/196 -0.90625 255/215/215 0.9375 255/215/215 -0.9375 255/235/235 0.96875 255/235/235 -0.96875 255/254/253 1 255/254/253 +0.000000 10/0/121 0.032258 40/0/150 +0.032258 40/0/150 0.064516 20/5/175 +0.064516 20/5/175 0.096774 0/10/200 +0.096774 0/10/200 0.129032 0/25/212 +0.129032 0/25/212 0.161290 0/40/224 +0.161290 0/40/224 0.193548 26/102/240 +0.193548 26/102/240 0.225806 13/129/248 +0.225806 13/129/248 0.258065 25/175/255 +0.258065 25/175/255 0.290323 50/190/255 +0.290323 50/190/255 0.322581 68/202/255 +0.322581 68/202/255 0.354839 97/225/240 +0.354839 97/225/240 0.387097 106/235/225 +0.387097 106/235/225 0.419355 124/235/200 +0.419355 124/235/200 0.451613 138/236/174 +0.451613 138/236/174 0.483871 172/245/168 +0.483871 172/245/168 0.516129 205/255/162 +0.516129 205/255/162 0.548387 223/245/141 +0.548387 223/245/141 0.580645 240/236/121 +0.580645 240/236/121 0.612903 247/215/104 +0.612903 247/215/104 0.645161 255/189/87 +0.645161 255/189/87 0.677419 255/160/69 +0.677419 255/160/69 0.709677 244/117/75 +0.709677 244/117/75 0.741935 238/80/78 +0.741935 238/80/78 0.774194 255/90/90 +0.774194 255/90/90 0.806452 255/124/124 +0.806452 255/124/124 0.838710 255/158/158 +0.838710 255/158/158 0.870968 245/179/174 +0.870968 245/179/174 0.903226 255/196/196 +0.903226 255/196/196 0.935484 255/215/215 +0.935484 255/215/215 0.967742 255/235/235 +0.967742 255/235/235 1.000000 255/254/253 #---------------------------------------------------------- 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..2e9fe49c8be 100644 --- a/share/cpt/no_green.cpt +++ b/share/cpt/no_green.cpt @@ -5,24 +5,22 @@ # #---------------------------------------------------------- # 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 --0.75 32/191/255 -0.625 32/191/255 --0.625 0/207/255 -0.5 0/207/255 --0.5 42/255/255 -0.375 42/255/255 --0.375 85/255/255 -0.25 85/255/255 --0.25 127/255/255 -0.125 127/255/255 --0.125 170/255/255 0 170/255/255 -0 255/255/84 0.125 255/255/84 -0.125 255/240/0 0.25 255/240/0 -0.25 255/191/0 0.375 255/191/0 -0.375 255/168/0 0.5 255/168/0 -0.5 255/138/0 0.625 255/138/0 -0.625 255/112/0 0.75 255/112/0 -0.75 255/77/0 0.875 255/77/0 -0.875 red 1 red +-1.000000 32/96/255 -0.857142 32/159/255 +-0.857142 32/159/255 -0.714285 32/191/255 +-0.714285 32/191/255 -0.571428 0/207/255 +-0.571428 0/207/255 -0.428571 42/255/255 +-0.428571 42/255/255 -0.285714 85/255/255 +-0.285714 85/255/255 -0.142857 127/255/255 +-0.142857 127/255/255 0.000000 170/255/255 + 0.000000 255/255/84 0.142857 255/240/0 +0.142857 255/240/0 0.285714 255/191/0 +0.285714 255/191/0 0.428571 255/168/0 +0.428571 255/168/0 0.571429 255/138/0 +0.571429 255/138/0 0.714286 255/112/0 +0.714286 255/112/0 0.857143 255/77/0 +0.857143 255/77/0 1.000000 red #---------------------------------------------------------- B 32/96/255 F 255/0/0 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/paired.cpt b/share/cpt/paired.cpt index ee38cba08fd..9595c822b64 100644 --- a/share/cpt/paired.cpt +++ b/share/cpt/paired.cpt @@ -3,20 +3,21 @@ # # This color table is based on the specifications and designs # developed by Cynthia Brewer (http://colorbrewer.org/) +# Here reproduced as a categorical table # #---------------------------------------------------------- # COLOR_MODEL = RGB #---------------------------------------------------------- -0 166/206/227 0.0833333333333 166/206/227 -0.0833333333333 31/120/180 0.166666666667 31/120/180 -0.166666666667 178/223/138 0.25 178/223/138 -0.25 51/160/44 0.333333333333 51/160/44 -0.333333333333 251/154/153 0.416666666667 251/154/153 -0.416666666667 227/26/28 0.5 227/26/28 -0.5 253/191/111 0.583333333333 253/191/111 -0.583333333333 darkorange1 0.666666666667 darkorange1 -0.666666666667 202/178/214 0.75 202/178/214 -0.75 106/61/154 0.833333333333 106/61/154 -0.833333333333 255/255/153 0.916666666667 255/255/153 -0.916666666667 177/89/40 1 177/89/40 +0 166/206/227 +1 31/120/180 +2 178/223/138 +3 51/160/44 +4 251/154/153 +5 227/26/28 +6 253/191/111 +7 darkorange1 +8 202/178/214 +9 106/61/154 +10 255/255/153 +11 177/89/40 #---------------------------------------------------------- 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 532e674fe0e..5fc82ba6e0a 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 +# HARD_HINGE +# 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 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..c14fb98e8dd 100644 --- a/share/cpt/world.cpt +++ b/share/cpt/world.cpt @@ -1,27 +1,26 @@ # -# Color table for Earth's relief combining the gebco -# and dem2 CPTs with a hinge at 0. +# Color table for Earth's relief combining a continuous gebco +# and dem2 CPTs with a hard hinge at 0. # Designed by P. Wessel, SOEST #---------------------------------------------------------- # COLOR_MODEL = RGB -# HINGE = 0 +# HARD_HINGE # RANGE = -7000/7000 #---------------------------------------------------------- --1 0/240/255 -0.857142857143 0/240/255 --0.857142857143 35/255/255 -0.714285714286 35/255/255 --0.714285714286 90/255/255 -0.571428571429 90/255/255 --0.571428571429 140/255/230 -0.428571428571 140/255/230 --0.428571428571 165/255/215 -0.285714285714 165/255/215 --0.285714285714 195/255/215 -0.142857142857 195/255/215 --0.142857142857 210/255/215 -0.071428571429 210/255/215 --0.071428571429 230/255/240 -0.028571428571 230/255/240 --0.028571428571 235/255/255 0 235/255/255 -0 51/102/0 0.125 129/195/31 -0.125 129/195/31 0.25 255/255/204 -0.25 255/255/204 0.5 244/189/69 -0.5 244/189/69 0.625 102/51/12 -0.625 102/51/12 0.75 102/51/0 -0.75 102/51/0 1 255/254/253 +-1.000 0/240/255 -0.875 35/255/255 +-0.875 35/255/255 -0.750 90/255/255 +-0.750 90/255/255 -0.625 140/255/230 +-0.625 140/255/230 -0.500 165/255/215 +-0.500 165/255/215 -0.375 195/255/215 +-0.375 195/255/215 -0.250 210/255/215 +-0.250 210/255/215 -0.125 230/255/240 +-0.125 230/255/240 0.000 235/255/255 +0.0000 51/102/0 0.125 129/195/31 +0.125 129/195/31 0.250 255/255/204 +0.250 255/255/204 0.500 244/189/69 +0.500 244/189/69 0.625 102/51/12 +0.625 102/51/12 0.750 102/51/0 +0.750 102/51/0 1.000 255/254/253 #---------------------------------------------------------- B 51/102/0 F white diff --git a/share/cpt/wysiwyg.cpt b/share/cpt/wysiwyg.cpt index 561e0d1852f..6f7c03cdd54 100644 --- a/share/cpt/wysiwyg.cpt +++ b/share/cpt/wysiwyg.cpt @@ -5,24 +5,23 @@ #---------------------------------------------------------- # COLOR_MODEL = RGB #---------------------------------------------------------- -0 64/0/64 0.05 64/0/64 -0.05 64/0/192 0.1 64/0/192 -0.1 0/64/255 0.15 0/64/255 -0.15 0/128/255 0.2 0/128/255 -0.2 0/160/255 0.25 0/160/255 -0.25 64/192/255 0.3 64/192/255 -0.3 64/224/255 0.35 64/224/255 -0.35 64/255/255 0.4 64/255/255 -0.4 64/255/192 0.45 64/255/192 -0.45 64/255/64 0.5 64/255/64 -0.5 128/255/64 0.55 128/255/64 -0.55 192/255/64 0.6 192/255/64 -0.6 255/255/64 0.65 255/255/64 -0.65 255/224/64 0.7 255/224/64 -0.7 255/160/64 0.75 255/160/64 -0.75 255/96/64 0.8 255/96/64 -0.8 255/32/64 0.85 255/32/64 -0.85 255/96/192 0.9 255/96/192 -0.9 255/160/255 0.95 255/160/255 -0.95 255/224/255 1 255/224/255 +0.000000 64/0/64 0.052632 64/0/192 +0.052632 64/0/192 0.105263 0/64/255 +0.105263 0/64/255 0.157895 0/128/255 +0.157895 0/128/255 0.210526 0/160/255 +0.210526 0/160/255 0.263158 64/192/255 +0.263158 64/192/255 0.315789 64/224/255 +0.315789 64/224/255 0.368421 64/255/255 +0.368421 64/255/255 0.421053 64/255/192 +0.421053 64/255/192 0.473684 64/255/64 +0.473684 64/255/64 0.526316 128/255/64 +0.526316 128/255/64 0.578947 192/255/64 +0.578947 192/255/64 0.631579 255/255/64 +0.631579 255/255/64 0.684211 255/224/64 +0.684211 255/224/64 0.736842 255/160/64 +0.736842 255/160/64 0.789474 255/96/64 +0.789474 255/96/64 0.842105 255/32/64 +0.842105 255/32/64 0.894737 255/96/192 +0.894737 255/96/192 0.947368 255/160/255 +0.947368 255/160/255 1.000000 255/224/255 #---------------------------------------------------------- diff --git a/src/gmt_api.c b/src/gmt_api.c index b44dd169cd9..abcc6d362ed 100644 --- a/src/gmt_api.c +++ b/src/gmt_api.c @@ -5668,6 +5668,7 @@ GMT_LOCAL int api_colors2cpt (struct GMTAPI_CTRL *API, char **str, unsigned int GMT_Report (API, GMT_MSG_NORMAL, "Unable to open file %s file for writing\n", tmp_file); return (GMT_NOTSET); } + fprintf (fp, "# COLOR_LIST\n"); /* Flag that we are building a CPT from a list of discrete colors */ if ((*mode) & GMT_CPT_CONTINUOUS) { /* Make a continuous cpt from the colors */ char last_color[GMT_LEN256] = {""}; @@ -7145,7 +7146,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_constants.h b/src/gmt_constants.h index 7e94a896cda..cca772e264a 100644 --- a/src/gmt_constants.h +++ b/src/gmt_constants.h @@ -212,7 +212,7 @@ enum GMT_swap_direction { #define GMT_IMAGE_LAYOUT "TRBa" /* Standard GMT scanline band-interleaved image */ #define GMT_CPT_CONTINUOUS 8 /* Final CPT should be continuous */ -#define GMT_CPT_TEMPORARY 16 /* CPT was built from list of colors, e.g., red,green,255,blue,... */ +#define GMT_CPT_TEMPORARY 1024 /* CPT was built from list of colors, e.g., red,green,255,blue,... */ #define GMT_CPT_C_REVERSE 1 /* Reverse CPT colors */ #define GMT_CPT_Z_REVERSE 2 /* Reverse CPT z-values */ diff --git a/src/gmt_cpt_masters.h b/src/gmt_cpt_masters.h index 32e58dfbc3d..2165726eb06 100644 --- a/src/gmt_cpt_masters.h +++ b/src/gmt_cpt_masters.h @@ -3,14 +3,14 @@ "bamako : Perceptually uniform, low-lightness gradient colormap by Fabio Crameri [C=RGB]", "bathy : Like abyss but via aquamarine at mid-depths [R=-8000/0, C=RGB]", "batlow : Perceptually uniform sequential \'rainbow\' colormap by, Fabio Crameri [C=RGB]", -"berlin : Perceptually uniform bimodal colormap, dark, by Fabio Crameri [H=0,C=RGB]", +"berlin : Perceptually uniform bimodal colormap, dark, by Fabio Crameri [S,C=RGB]", "bilbao : Perceptually uniform colormap by Fabio Crameri [C=RGB]", -"broc : Perceptually uniform bimodal colormap, light, by Fabio Crameri [H=0,C=RGB]", +"broc : Perceptually uniform bimodal colormap, light, by Fabio Crameri [S,C=RGB]", "buda : Perceptually uniform, low-lightness gradient colormap, by Fabio Crameri [C=RGB]", "categorical : Color table particularly suitable for categorical data [vRGB]", "cool : Linear change from blue to magenta [C=RGB]", "copper : Dark to light copper brown [C=RGB]", -"cork : Perceptually uniform bimodal colormap, light, by Fabio Crameri [H=0,C=RGB]", +"cork : Perceptually uniform bimodal colormap, light, by Fabio Crameri [S,C=RGB]", "cubhelix : Intensity colormap via cube helix by Dave Green [C=RGB]", "cyclic : Cyclic colormap, spans 360 degrees of hue [C=HSV]", "davos : Perceptually uniform colormap by Fabio Crameri [C=RGB]", @@ -20,12 +20,12 @@ "dem4 : Digital Elevation Model (DEM) scale for Wikipedia figures [R=0/1500, C=RGB]", "devon : Perceptually uniform sequential colormap, by Fabio Crameri [C=RGB]", "drywet : Goes from dry to wet colors [C=RGB]", -"earth : Colors for global bathymetry/topography relief [R=-11000/9000, H=0, C=RGB]", +"earth : Colors for global bathymetry/topography relief [R=-11000/9000, H, C=RGB]", "elevation : Washed-out colors for topography [R=0/7000, C=RGB]", -"etopo1 : Colormap used in the ETOPO1 global relief map [R=-11000/8500, H=0, C=RGB]", +"etopo1 : Colormap used in the ETOPO1 global relief map [R=-11000/8500, H, C=RGB]", "gebco : Colors for GEBCO bathymetric charts [R=-7000/0, C=RGB]", -"geo : Colors for global bathymetry/topography relief [R=-8000/8000, H=0, C=RGB]", -"globe : Colors for global bathymetry/topography relief [R=-10000/10000, H=0, C=RGB]", +"geo : Colors for global bathymetry/topography relief [R=-8000/8000, H, C=RGB]", +"globe : Colors for global bathymetry/topography relief [R=-10000/10000, H, C=RGB]", "gray : Gray linear ramp from black to white [C=RGB]", "grayC : Perceptually uniform \'gray\' colormap, by Fabio Crameri [C=RGB]", "hawaii : Perceptually uniform sequential colormap, by Fabio Crameri [C=RGB]", @@ -37,35 +37,35 @@ "jet : Dark to light blue, white, yellow and red [C=RGB]", "lajolla : Perceptually uniform colormap, without black or white, by Fabio Crameri [C=RGB]", "lapaz : Perceptually uniform \'rainbow\' colormap, by Fabio Crameri [C=RGB]", -"lisbon : Perceptually uniform bimodal colormap, dark, by Fabio Crameri [H=0,C=RGB]", +"lisbon : Perceptually uniform bimodal colormap, dark, by Fabio Crameri [S,C=RGB]", "mag : Colors for magnetic anomaly maps [C=RGB]", "magma : New colormap Option A from matplotlib [C=RGB]", "nighttime : Colors for DMSP-OLS Nighttime Lights Time Series [C=HSV]", -"no_green : For those who hate green [H=0, C=RGB]", +"no_green : For those who hate green [S, C=RGB]", "nuuk : Perceptually uniform, low-lightness gradient colormap, by Fabio Crameri [C=RGB]", "ocean : White-green-blue bathymetry scale [R=-8000/0, C=RGB]", -"oleron : Perceptually uniform topography colormap, by Fabio Crameri [H=0,C=RGB]", +"oleron : Perceptually uniform topography colormap, by Fabio Crameri [H,C=RGB]", "oslo : Perceptually uniform, black & white limits, by Fabio Crameri [C=RGB]", "paired : Qualitative color map with 6 pairs of colors [C=RGB]", "panoply : Default colormap of Panoply [C=RGB]", "plasma : New colormap Option C from matplotlib [C=RGB]", -"polar : Blue via white to red [H=0, C=RGB]", +"polar : Blue via white to red [S, C=RGB]", "rainbow : Rainbow: magenta-blue-cyan-green-yellow-red [C=HSV]", -"red2green : Polar scale from red to green via white [H=0, C=RGB]", -"relief : Wessel/Martinez colors for topography [R=-8000/+8000, H=0, C=RGB]", +"red2green : Polar scale from red to green via white [S, C=RGB]", +"relief : Wessel/Martinez colors for topography [R=-8000/+8000, H, C=RGB]", "roma : Perceptually uniform \'seis\' colormap, by Fabio Crameri [C=RGB]", "seafloor : Purple-blue-white bathymetry scale [R=-6000/0, C=RGB]", -"sealand : Smith bathymetry/topography scale [R=-6000/+3000, H=0, C=HSV]", +"sealand : Smith bathymetry/topography scale [R=-6000/+3000, H, C=HSV]", "seis : R-O-Y-G-B seismic tomography colors [C=RGB]", -"split : Like polar, but via black instead of white [H=0, C=RGB]", -"srtm : Like dem2, but with blue for oceans [H=1, C=RGB]", -"terra : Colors for global bathymetry/topography relief [R=-7000/7000, H=0, C=RGB]", -"tofino : Perceptually uniform bimodal colormap, dark, by Fabio Crameri [H=0,C=RGB]", +"split : Like polar, but via black instead of white [S, C=RGB]", +"srtm : Like dem2, but with blue for oceans [H, C=RGB]", +"terra : Colors for global bathymetry/topography relief [R=-7000/7000, H, C=RGB]", +"tofino : Perceptually uniform bimodal colormap, dark, by Fabio Crameri [S,C=RGB]", "tokyo : Perceptually uniform colormap without black or white, by Fabio Crameri [C=RGB]", -"topo : Sandwell/Anderson colors for topography [R=-7000/+7000, H=0, C=HSV]", +"topo : Sandwell/Anderson colors for topography [R=-7000/+7000, H, C=HSV]", "turku : Perceptually uniform colormap by Fabio Crameri [C=RGB]", "turbo : Google's Improved Rainbow Colormap for Visualization [C=RGB]", -"vik : Perceptually uniform bimodal colormap, light, by Fabio Crameri [H=0,C=RGB]", +"vik : Perceptually uniform bimodal colormap, light, by Fabio Crameri [S,C=RGB]", "viridis : New colormap Option D from matplotlib [C=RGB]", -"world : Colors for global bathymetry/topography relief [R=-7000/7000, H=0, C=RGB]", +"world : Colors for global bathymetry/topography relief [R=-7000/7000, H, C=RGB]", "wysiwyg : 20 well-separated RGB colors [C=RGB]", diff --git a/src/gmt_io.c b/src/gmt_io.c index 5443308ca36..52beab1e757 100644 --- a/src/gmt_io.c +++ b/src/gmt_io.c @@ -5093,7 +5093,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_prototypes.h b/src/gmt_prototypes.h index 5b6e9293028..f80504405a1 100644 --- a/src/gmt_prototypes.h +++ b/src/gmt_prototypes.h @@ -344,6 +344,7 @@ EXTERN_MSC bool gmt_this_alloc_level (struct GMT_CTRL *GMT, unsigned int alloc_l /* gmt_support.c: */ +EXTERN_MSC unsigned int gmt_validate_cpt_parameters (struct GMT_CTRL *GMT, struct GMT_PALETTE *P, char *file, bool *interpolate, bool *force_continuous); EXTERN_MSC void gmt_extend_region (struct GMT_CTRL *GMT, double wesn[], unsigned int mode, double inc[]); EXTERN_MSC void gmt_rgb_to_hsv (double rgb[], double hsv[]); EXTERN_MSC void gmt_hsv_to_rgb (double rgb[], double hsv[]); diff --git a/src/gmt_resources.h b/src/gmt_resources.h index fe92f6fa6f3..909400a2afa 100644 --- a/src/gmt_resources.h +++ b/src/gmt_resources.h @@ -563,8 +563,11 @@ 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_COLORLIST = 32, + 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 1ea9cb3924d..f566150238b 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] + * or to adjust the location of the hinge for an hard hinge CPT. */ 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; @@ -7152,7 +7174,7 @@ void gmtlib_free_palette (struct GMT_CTRL *GMT, struct GMT_PALETTE **P) { /*! Adds listing of available GMT cpt choices to a program's usage message */ int gmt_list_cpt (struct GMT_CTRL *GMT, char option) { gmt_message (GMT, "\t-%c Specify a colortable [Default is %s]:\n", option, GMT_DEFAULT_CPT_NAME); - gmt_message (GMT, "\t [Notes: R=Default z-range, H=Hinge, C=colormodel]\n"); + gmt_message (GMT, "\t [Legend: R = Default z-range, H = Hard Hinge, S = Soft Hinge, C = Colormodel]\n"); gmt_message (GMT, "\t ---------------------------------------------------------------------------------------\n"); for (unsigned int k = 0; k < GMT_N_CPT_MASTERS; k++) gmt_message (GMT, "\t %s\n", GMT_CPT_master[k]); gmt_message (GMT, "\t ---------------------------------------------------------------------------------------\n"); @@ -7163,6 +7185,46 @@ int gmt_list_cpt (struct GMT_CTRL *GMT, char option) { return (GMT_NOERROR); } +/*! . */ +void gmtlib_make_continuous_colorlist (struct GMT_CTRL *GMT, struct GMT_PALETTE *P) { + /* Convert a (by default) discrete CPT made from a color list to a continuous CPT instead */ + unsigned int k, i; + gmt_M_unused(GMT); + if (P->is_continuous) return; /* Nothing to do */ + P->n_colors--; /* One less slice */ + for (k = 0; k < P->n_colors; k++) { /* Copy next low color to previous high color */ + gmt_M_rgb_copy (P->data[k].rgb_high, P->data[k+1].rgb_low); + gmt_M_rgb_copy (P->data[k].hsv_high, P->data[k+1].hsv_low); + /* Update color differences for interpolation function later (dz remains the same == 1) */ + for (i = 0; i < 4; i++) P->data[k].rgb_diff[i] = P->data[k].rgb_high[i] - P->data[k].rgb_low[i]; + for (i = 0; i < 4; i++) P->data[k].hsv_diff[i] = P->data[k].hsv_high[i] - P->data[k].hsv_low[i]; + } + P->is_continuous = true; /* Flag this as a continuous CPT */ +} + +/*! . */ +unsigned int gmt_validate_cpt_parameters (struct GMT_CTRL *GMT, struct GMT_PALETTE *P, char *file, bool *interpolate, bool *force_continuous) { + if (P->mode & GMT_CPT_COLORLIST && !P->categorical && !(*interpolate)) { /* Color list with -T/min/max should be seen as continuous */ + *force_continuous = true, P->mode |= GMT_CPT_CONTINUOUS; + gmtlib_make_continuous_colorlist (GMT, P); + } + if (*interpolate) { + if (!P->is_continuous && !(P->mode & GMT_CPT_COLORLIST)) { + GMT_Report (GMT->parent, GMT_MSG_VERBOSE, "%s is a discrete CPT. You can stretch it (-T/) but not interpolate it (-T//).\n", file); + GMT_Report (GMT->parent, GMT_MSG_VERBOSE, "Selecting the given range and ignoring the increment setting.\n"); + *interpolate = false; + } + } + else { /* Did not request resampling */ + if (P->categorical) { + GMT_Report (GMT->parent, GMT_MSG_NORMAL, "%s is a special categorical, discrete CPT. You can select a subset only via (-Tmin/max/inc).\n", file); + GMT_Report (GMT->parent, GMT_MSG_NORMAL, "This will yield a subset categorical CPT with [(max-min)/inc] - 1 entries.\n", file); + return GMT_RUNTIME_ERROR; + } + } + return GMT_NOERROR; +} + /*! . */ struct GMT_PALETTE * gmtlib_read_cpt (struct GMT_CTRL *GMT, void *source, unsigned int source_type, unsigned int cpt_flags) { /* Opens and reads a color palette file in RGB, HSV, or CMYK of arbitrary length. @@ -7173,11 +7235,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] = {""}; @@ -7191,7 +7253,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); @@ -7271,11 +7333,18 @@ 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); + else if (strstr (line, "HINGE")) { /* CPT has either a soft or hard hinge */ + if (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; + } + else if (strstr (line, "HARD_HINGE")) { /* Hard hinge is always active */ + X->mode |= GMT_CPT_HARD_HINGE; + X->has_hinge = 1; + } + else if (strstr (line, "SOFT_HINGE")) /* Soft hinge the user can activate to a hard hinge 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 */ @@ -7296,6 +7365,8 @@ struct GMT_PALETTE * gmtlib_read_cpt (struct GMT_CTRL *GMT, void *source, unsign X->is_wrapping = 1; else if ((h = strstr (line, "ENABLE_B_OPTION"))) /* CPT was stretched to exact min/max with no dz rounding */ XH->auto_scale = 1; + else if ((h = strstr (line, "COLOR_LIST"))) /* CPT was created from a list of colors */ + X->mode |= GMT_CPT_COLORLIST; GMT->current.setting.color_model = X->model; @@ -7373,6 +7444,11 @@ struct GMT_PALETTE * gmtlib_read_cpt (struct GMT_CTRL *GMT, void *source, unsign continue; } + if (hinge_mode && ((X->mode & GMT_CPT_SOFT_HINGE) || (X->mode & GMT_CPT_HARD_HINGE))) { /* Activate a soft hinge for the CPT and/or adjust the hinge */ + X->has_hinge = 1; + X->hinge = z_hinge; /* This is now the user-selected hinge value */ + } + /* Here we have regular z-slices. Allowable formats are * * key [;