Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

grd2cpt.rst 9.6 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
  1. .. index:: ! grd2cpt
  2. .. include:: module_core_purpose.rst_
  3. *******
  4. grd2cpt
  5. *******
  6. |grd2cpt_purpose|
  7. Synopsis
  8. --------
  9. .. include:: common_SYN_OPTs.rst_
  10. **gmt grd2cpt** *grid* [ |-A|\ *transparency*\ [**+a**] ]
  11. [ |-C|\ *cpt* ] [ |-D|\ [**i**] ]
  12. [ |-E|\ [*nlevels*] ]
  13. [ |-F|\ [**R**\|\ **r**\|\ **h**\|\ **c**][**+c**] ]
  14. [ |-G|\ *zlo*\ /\ *zhi* ]
  15. [ |-H| ]
  16. [ |-I|\ [**c**][**z**] ]
  17. [ |-L|\ *minlimit/maxlimit* ]
  18. [ |-M| ]
  19. [ |-N| ]
  20. [ |-Q|\ [**i**\|\ **o**] ]
  21. [ |SYN_OPT-R| ]
  22. [ |-S|\ **h**\|\ **l**\|\ **m**\|\ **u** ]
  23. [ |-T|\ *start/stop/inc* ]
  24. [ |SYN_OPT-V| ]
  25. [ |-W|\ [**w**] ]
  26. [ |-Z| ]
  27. [ |SYN_OPT-h| ]
  28. [ |SYN_OPT--| ]
  29. |No-spaces|
  30. Description
  31. -----------
  32. **grd2cpt** reads one or more grid files and writes a static color palette
  33. (CPT) file. In classic mode we write the CMT to standard output, while under
  34. modern mode we simply save the CPT as the current session CPT (but see **-H**).
  35. The CPT is based on an existing dynamic
  36. master CPT of your choice, and the mapping from data value to
  37. colors is through the data's cumulative distribution function (CDF), so
  38. that the colors are histogram equalized. Thus if the grid(s) and the
  39. resulting CPT are used in :doc:`grdimage` with a linear projection,
  40. the colors will be uniformly distributed in area on the plot. Let z be
  41. the data values in the grid. Define CDF(Z) = (# of z < Z) / (# of z in
  42. grid). (NaNs are ignored). These z-values are then normalized to the
  43. master CPT and colors are sampled at the desired intervals.
  44. The color palette includes three additional colors beyond the range of
  45. z-values. These are the background color (B) assigned to values lower
  46. than the lowest *z*-value, the foreground color (F) assigned to values
  47. higher than the highest *z*-value, and the NaN color (N) painted
  48. wherever values are undefined. For color tables beyond the
  49. standard GMT offerings, visit `cpt-city <http://soliton.vm.bytemark.co.uk/pub/cpt-city/>`_ and
  50. `Scientific Colour-Maps <http://www.fabiocrameri.ch/colourmaps.php>`_.
  51. If the master CPT includes B, F, and N entries, these will be
  52. copied into the new master file. If not, the parameters
  53. :term:`COLOR_BACKGROUND`, :term:`COLOR_FOREGROUND`,
  54. and :term:`COLOR_NAN` from
  55. the :doc:`gmt.conf` file or the command line will be used. This default
  56. behavior can be overruled using the options **-D**, **-M** or **-N**.
  57. The color model (RGB, HSV or CMYK) of the palette created by :doc:`makecpt`
  58. will be the same as specified in the header of the master CPT. When
  59. there is no :term:`COLOR_MODEL` entry in the master CPT, the
  60. :term:`COLOR_MODEL` specified in the :doc:`gmt.conf` file or on the command
  61. line will be used.
  62. Required Arguments
  63. ------------------
  64. *grid*
  65. Names of one or more grid files used to derive the color palette
  66. table. All grids need to have the same size and dimensions. (See
  67. GRID FILE FORMATS below).
  68. Optional Arguments
  69. ------------------
  70. .. _-A:
  71. **-A**\ *transparency*\ [**+a**]
  72. Sets a constant level of transparency (0-100) for all color slices.
  73. Append **+a** to also affect the fore-, back-, and nan-colors
  74. [Default is no transparency, i.e., 0 (opaque)].
  75. .. _-C:
  76. .. include:: create_cpt.rst_
  77. .. _-D:
  78. **-D**\ [**i**]
  79. Select the back- and foreground colors to match the colors for
  80. lowest and highest *z*-values in the output CPT [Default uses
  81. the colors specified in the master file, or those defined by the
  82. parameters :term:`COLOR_BACKGROUND`, :term:`COLOR_FOREGROUND`, and
  83. :term:`COLOR_NAN`]. Append **i** to match the colors for the lowest and
  84. highest values in the input (instead of the output) CPT.
  85. .. _-E:
  86. **-E**\ [*nlevels*]
  87. Create a linear color table by using the grid z-range as the new
  88. limits in the CPT. Alternatively, append *nlevels* and we will
  89. resample the color table into *nlevels* equidistant slices.
  90. .. _-F:
  91. **-F**\ [**R**\|\ **r**\|\ **h**\|\ **c**][**+c**]
  92. Force output CPT to written with r/g/b codes, gray-scale values
  93. or color name (**R**, default) or r/g/b codes only (**r**), or h-s-v
  94. codes (**h**), or c/m/y/k codes (**c**). Optionally or alternatively,
  95. append **+c** to write discrete palettes in categorical format.
  96. .. _-G:
  97. **-G**\ *zlo*\ /\ *zhi*
  98. Truncate the incoming CPT so that the lowest and highest z-levels
  99. are to *zlo* and *zhi*. If one of these equal NaN then
  100. we leave that end of the CPT alone. The truncation takes place
  101. before any resampling. See also :ref:`manipulating_CPTs`
  102. .. _-H:
  103. **-H**\
  104. Modern mode only: Write the CPT to standard output as well [Default saves
  105. the CPT as the session current CPT]. Required for scripts used to make
  106. animations via :doc:`movie` where we must pass named CPT files.
  107. .. _-I:
  108. **-I**\ [**c**][**z**]
  109. Append **c** [Default] to reverse the sense of color progression in the master CPT. Also
  110. exchanges the foreground and background colors, including those
  111. specified by the parameters :term:`COLOR_BACKGROUND` and
  112. :term:`COLOR_FOREGROUND`.
  113. Append **z** to reverse the sign of z-values in the color table. Note that
  114. this change of *z*-direction happens before **-G** and **-S** values are used
  115. so the latter much be compatible with the changed *z*-range. See also :ref:`manipulating_CPTs`
  116. .. _-L:
  117. **-L**\ *minlimit/maxlimit*
  118. Limit range of CPT to *minlimit/maxlimit*, and don't count data
  119. outside this range when estimating CDF(Z). [Default uses min and max of data.]
  120. .. _-M:
  121. **-M**
  122. Overrule background, foreground, and NaN colors specified in the
  123. master CPT with the values of the parameters
  124. :term:`COLOR_BACKGROUND`, :term:`COLOR_FOREGROUND`,
  125. and :term:`COLOR_NAN`
  126. specified in the :doc:`gmt.conf` file or on the command line. When
  127. combined with **-D**, only :term:`COLOR_NAN` is considered.
  128. .. _-N:
  129. **-N**
  130. Do not write out the background, foreground, and NaN-color fields
  131. [Default will write them].
  132. .. _-Q:
  133. **-Q**\ [**i**\|\ **o**]
  134. Selects a logarithmic interpolation scheme [Default is linear].
  135. **-Qi** expects input z-values to be log10(z), assigns colors, and
  136. writes out z [Default]. **-Qo** takes log10(z) first, assigns
  137. colors, and writes out z.
  138. .. _-R:
  139. .. |Add_-R| unicode:: 0x20 .. just an invisible code
  140. .. include:: explain_-R.rst_
  141. .. _-S:
  142. **-S**\ **h**\|\ **l**\|\ **m**\|\ **u**
  143. Force the color table to be symmetric about zero (from -*R* to +\ *R*).
  144. Append flag to set the range *R*: **l** for *R* =\|zmin\|, **u** for *R* =
  145. \|zmax\|, **m** for *R* = min(\|zmin\|, \|zmax\|), or **h** for *R* =
  146. max(\|zmin\|, \|zmax\|).
  147. .. _-T:
  148. **-T**\ *start/stop/inc* or **-T**\ *n*
  149. Set steps in CPT. Calculate entries in CPT from *start*
  150. to *stop* in steps of (*inc*). Default chooses arbitrary values by
  151. a crazy scheme based on equidistant values for a Gaussian CDF.
  152. Use **-T**\ *n* to select *n* points from such a
  153. cumulative normal distribution [11].
  154. .. _-V:
  155. **-V**
  156. Verbose operation. This will write CDF(Z) estimates to stderr. [Default is silent.]
  157. .. _-W:
  158. **-W**\ [**w**]
  159. Do not interpolate the input color table but pick the output colors
  160. starting at the beginning of the map. This is particularly useful in
  161. combination with a categorical color table. Alternatively, use **-Ww**
  162. to produce a wrapped (cyclic) color table that endlessly repeats its range.
  163. .. _-Z:
  164. **-Z**
  165. Force a continuous CPT [Default is discontinuous].
  166. .. include:: explain_-h.rst_
  167. .. include:: explain_help.rst_
  168. .. include:: explain_grd_inout_short.rst_
  169. .. include:: explain_transparency.rst_
  170. Color Hinges
  171. ------------
  172. Some of the GMT master dynamic CPTs are actually two separate CPTs
  173. meeting at a *hinge*. Usually, colors may change dramatically across
  174. the hinge, which is used to separate two different domains (e.g., land
  175. and ocean across the shoreline, for instance). CPTs with a hinge will
  176. have their two parts stretched to the required range separately, i.e.,
  177. the bottom part up to the hinge will be stretched independently of the
  178. part from the hinge to the top, according to the prescribed new range.
  179. Hinges are either *hard* or *soft*. Soft hinges must be *activated* by
  180. appending **+h**\ [*hinge*] to the CPT name.
  181. If the selected range does not include an activated soft or hard hinge then
  182. we only resample colors from the half of the CPT that pertains to the range.
  183. See :ref:`Of Colors and Color Legends` for more information.
  184. Discrete versus Continuous CPT
  185. ------------------------------
  186. All CPTs can be stretched, but only continuous CPTs can be sampled
  187. at new nodes (i.e., by given an increment in **-T**). We impose this
  188. limitation to avoid aliasing the original CPT.
  189. Examples
  190. --------
  191. .. include:: explain_example.rst_
  192. To get a reasonable and symmetrical color table for the data in the region 0/60/0/60
  193. from the remote 5m relief file, using the geo color table, try::
  194. gmt grd2cpt @earth_relief_05m -R0/60/0/60 -Cgeo -Su
  195. Sometimes you don't want to make a CPT (yet) but would find it
  196. helpful to know that 90% of your data lie between z1 and z2, something
  197. you cannot learn from :doc:`grdinfo`. So you can do this to see some points
  198. on the CDF(Z) curve (use **-V** option to see more):
  199. ::
  200. gmt grd2cpt mydata.nc -V > /dev/null
  201. To make a CPT with entries from 0 to 200 in steps of 20, and ignore
  202. data below zero in computing CDF(Z), and use the built-in master cpt
  203. file relief, run
  204. ::
  205. gmt grd2cpt mydata.nc -Crelief -L0/10000 -T0/200/20 > mydata.cpt
  206. .. include:: cpt_notes.rst_
  207. See Also
  208. --------
  209. :doc:`gmt`, :doc:`gmt.conf`,
  210. :doc:`grdhisteq`, :doc:`grdinfo`, :doc:`makecpt`
  211. References
  212. ----------
  213. Crameri, F., (2018). Scientific colour-maps. Zenodo. http://doi.org/10.5281/zenodo.1243862
  214. Crameri, F. (2018), Geodynamic diagnostics, scientific visualisation and StagLab 3.0,
  215. *Geosci. Model Dev.*, 11, 2541-2562, doi:10.5194/gmd-11-2541-2018.
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...