Under the CPT-File Hood
Here is a brief explanation of the anatomy of a CPT File:
Each 'Value Row' in a CPT File contains a 'From' and a 'To' Value, that can contain either data with units of measurement (aka Denormalized, and typically in metres), or Normalized data, that spans a range of [0, 1] or [-1, 0] or [-1, 1].
CPT Files can also address 'Categorical Data', for which normal numerical operations are not defined. For instance, imagine a map of land classifications: Shrubland, Savanna, Grassland, etc. If we assigned a numerical value to these categories, e.g. Shrubland = 1, Savanna = 2, etc. it would be meaningless to then try to compute average values, such as 1.5. For Categorical CPT files, Values are more correctly called 'Keys'. The Key values should be in ascending order, though do not need to be consecutive. An example of this type of CPT File is 'GMT_wysiwyg.cpt' in the Samples folder.
Associated with each 'From' and 'To' Value is a color, which can be in either RGB, HSV, or CMYK format. The format is specified in the 'Color Model' - more about that later.
If you are only interested in GrayScale coloring, you can also use a single integer color-value, in the range 0-255, or you can use the same value three times: 255/255/255 for white in the RGB color-model.
Many programs will also allow the use of Named Colors for a color-value, though you should adhere to the standard spellings (see the full list in the Named Colors tool-tabpage.):
-10000 DarkViolet -6500 RoyalBlue
For compatibility-sake, the 'CPT Designer' will convert any Named Colors to values in the current Color-Model.
The color for a 'band' of values represented by 'From' and 'To' can be either constant, where the 'From' and 'To' colors are identical, or a continuous linear function of the value, where the 'From' and 'To' colors are different.
Besides Value Lines, the CPT file can have other data included:
Lines preceeded with 'F': the following value stores the 'Foreground' color that is assigned to values higher than the highest z-value
Lines preceeded with 'B': the following value stores the 'Background' color that is assigned to values lower than the lowest z-value
Lines preceeded with 'N': the following value stores the 'NaN' color that will be painted wherever values are undefined as numbers.
Other optional lines are preceeded with the '#' character:
Lines preceeded with '# COLOR_MODEL = ': the following value stores the Color Model. This indicates that the color palette files contain RGB values (r,g,b in 0-255 range), HSV values (h in 0-360, s,v in 0-1 range), or CMYK values (c,m,y,k in 0-1 range). Note that 'HSV' and 'HSB' are the same thing, but 'HSV' and 'HSL' are not. If the Color Model entry is not present, an RGB color model is assumed, though in the GMT program this can be changed with the setting in the 'gmtdefaults' file. Use the 'Config' tab-page commands to change it.
Lines preceded with '# HINGE = ': this stores the Value where a range changes from negative to positive when normalized. It is usually '0', but can be any value within the Range. It is used to treat the two halves of the CPT file differently when normalizing to fit the User's range. If the Hinge-value is omitted, it is assumed to be '0'.
Lines preceded with '# RANGE = ': this is often present when the Values have been Normalized, and is required if the values need to be compared to a Denormalized data-set. The Range is entered as 0/1 or -1/0 if there is no hinge, or -1/1 if there is a hinge.
Lines containing '# CYCLIC': this indicates the CPT file is classed as a cyclic or wrapped color table, meaning that the 'z' value will always be kept within the limits of the Range, and 'Foreground' and 'Background' colors will never be encountered. The 'CPT Designer' treats a '# CYCLIC' line as just another comment, and takes no further action.
Any other CPT File lines that are preceded with '#', and are not empty lines or spacing-lines, and are not covered by previous conditions are classed as Comments. When shown in the 'Comments' box of the 'CPT File Window', comments have their leading '#' character removed. This is automatically replaced when the file is rebuilt, as can be seen in the 'CPT Viewer'.
Labels: There is the facility for some Value Rows to include Labels: this is especially pertinent for files of 'Categorical Data'. Some typical Value Rows might be:
1 064/000/192 2 064/000/192 ;Shrubland
2 000/064/255 3 000/064/255 ;Savanna
3 000/128/255 4 000/128/255 ;Grassland
where the Label is stored after a ';' character. The 'CPT Designer' does not currently handle Labels, and any Labels will be ignored, though this policy may be modified if there is sufficient interest.