.TH GRD2CPT 1gmt "Feb 27 2014" "GMT 4.5.13 (SVN)" "Generic Mapping Tools" .SH NAME grd2cpt \- Make a color palette table from grid files .SH SYNOPSIS \fBgrd2cpt\fP \fIgrdfiles\fP [ \fB\-C\fP\fIcptmaster\fP ] [ \fB\-D\fP ] [ \fB\-E\fP\fInlevels\fP ] [ \fB\-I\fP ] [ \fB\-L\fP\fIminlimit/maxlimit\fP ] [ \fB\-M\fP ] [ \fB\-N\fP ] [ \fB\-Q\fP[\fBi|o\fP] ] [ \fB\-R\fP\fIwest\fP/\fIeast\fP/\fIsouth\fP/\fInorth\fP[\fBr\fP] ] [ \fB\-S\fP\fIzstart/zstop/zinc\fP ] [ \fB\-T\fP\fB-\fP|\fB+\fP|\fB_\fP|\fB=\fP ] [ \fB\-V\fP ] [ \fB\-Z\fP ] .SH DESCRIPTION \fBgrd2cpt\fP reads one or more grid files and writes a color palette (cpt) file to standard output. The cpt file is based on an existing master cpt file of your choice, and the mapping from data value to colors is through the data's cumulative distribution function (CDF), so that the colors are\"' histogram equalized. Thus if the grid(s) and the resulting cpt file are used in \fBgrdimage\fP with a linear projection, the colors will be uniformly distributed in area on the plot. Let z be the data values in the grid. Define CDF(Z) = (# of z < Z) / (# of z in grid). (NaNs are ignored). These z-values are then normalized to the master cpt file and colors are sampled at the desired intervals. .br The color palette includes three additional colors beyond the range of z-values. These are the background color (B) assigned to values lower than the lowest \fIz\fP-value, the foreground color (F) assigned to values higher than the highest \fIz\fP-value, and the NaN color (N) painted whereever values are undefined. .br If the master cpt file includes B, F, and N entries, these will be copied into the new master file. If not, the parameters \fBCOLOR_BACKGROUND\fP, \fBCOLOR_FOREGROUND\fP, and \fBCOLOR_NAN\fP from the \.gmtdefaults4 file or the command line will be used. This default behavior can be overruled using the options \fB\-D\fP, \fB\-M\fP or \fB\-N\fP. .br The color model (RGB, HSV or CMYK) of the palette created by \fBmakecpt\fP will be the same as specified in the header of the master cpt file. When there is no \fBCOLOR_MODEL\fP entry in the master cpt file, the \fBCOLOR_MODEL\fP specified in the \.gmtdefaults4 file or on the command line will be used. .TP \fIgrdfiles\fP Names of one or more 2-D binary grid files used to derive the color palette table. All grids need to have the same size and dimensions. (See GRID FILE FORMATS below). .SH OPTIONS .TP \fB\-C\fP Selects the master color table to use in the interpolation. Choose among the built-in tables (type \fBgrd2cpt\fP to see the list) or give the name of an existing cpt file [Default gives a rainbow cpt file]. .TP \fB\-D\fP Select the colors for lowest and highest \fIz\fP-values in the output cpt file as the back- and foreground colors that will be written to the cpt file [Default uses the colors specified in the master file, or those defined by the parameters \fBCOLOR_BACKGROUND\fP, \fBCOLOR_FOREGROUND\fP, and \fBCOLOR_NAN\fP]. .TP \fB\-E\fP Create a linear color table by dividing the grid z-range into \fInlevels\fP equidistant slices. .TP \fB\-I\fP Reverses the sense of color progression in the master cpt file. Also exchanges the foreground and background colors, including those specified by the parameters \fBCOLOR_BACKGROUND\fP and \fBCOLOR_FOREGROUND\fP. .TP \fB\-L\fP Limit range of cpt file to \fIminlimit/maxlimit\fP, and don't count data\"' outside range when estimating CDF(Z). [Default uses min and max of data.] .TP \fB\-M\fP Overrule background, foreground, and NaN colors specified in the master cpt file with the values of the parameters \fBCOLOR_BACKGROUND\fP, \fBCOLOR_FOREGROUND\fP, and \fBCOLOR_NAN\fP specified in the \.gmtdefaults4 file or on the command line. When combined with \fB\-D\fP, only \fBCOLOR_NAN\fP is considered. .TP \fB\-N\fP Do not write out the background, foreground, and NaN-color fields [Default will write them]. .TP \fB\-Q\fP Selects a logarithmic interpolation scheme [Default is linear]. \fB\-Qi\fP expects input z-values to be log10(z), assigns colors, and writes out z [Default]. \fB\-Qo\fP takes log10(z) first, assigns colors, and writes out z. .TP \fB\-R\fP \fIxmin\fP, \fIxmax\fP, \fIymin\fP, and \fIymax\fP specify the Region of interest. For geographic regions, these limits correspond to \fIwest, east, south,\fP and \fInorth\fP and you may specify them in decimal degrees or in [+-]dd:mm[:ss.xxx][W|E|S|N] format. Append \fBr\fP if lower left and upper right map coordinates are given instead of w/e/s/n. The two shorthands \fB\-Rg\fP and \fB\-Rd\fP stand for global domain (0/360 and -180/+180 in longitude respectively, with -90/+90 in latitude). Alternatively, specify the name of an existing grid file and the \fB\-R\fP settings (and grid spacing, if applicable) are copied from the grid. For calendar time coordinates you may either give (a) relative time (relative to the selected \fBTIME_EPOCH\fP and in the selected \fBTIME_UNIT\fP; append \fBt\fP to \fB\-JX\fP|\fBx\fP), or (b) absolute time of the form [\fIdate\fP]\fBT\fP[\fIclock\fP] (append \fBT\fP to \fB\-JX\fP|\fBx\fP). At least one of \fIdate\fP and \fIclock\fP must be present; the \fBT\fP is always required. The \fIdate\fP string must be of the form [-]yyyy[-mm[-dd]] (Gregorian calendar) or yyyy[-Www[-d]] (ISO week calendar), while the \fIclock\fP string must be of the form hh:mm:ss[.xxx]. The use of delimiters and their type and positions must be exactly as indicated (however, input, output and plot formats are customizable; see \fBgmtdefaults\fP). .TP \fB\-S\fP Set steps in cpt file. Calculate entries in cpt file from \fIzstart\fP to \fIzstop\fP in steps of (\fIzinc\fP). [Default chooses arbitrary values by a crazy scheme.] .TP \fB\-T\fP Force the color table to be symmetric about zero (from -R to +R). Append flag to set the range R: \fB-\fP for R =|zmin|, \fB+\fP for R = |zmax|, \fB_\fP for R = min(|zmin|, |zmax|), or \fB=\fP for R = max(|zmin|, |zmax|). .TP \fB\-V\fP Verbose operation. This will write CDF(Z) estimates to stderr. [Default is silent.] .TP \fB\-Z\fP Will create a continuous color palette. [Default is discontinuous, i.e., constant color intervals] .SH GRID FILE FORMATS \fBGMT\fP is able to recognize many of the commonly used grid file formats, as well as the precision, scale and offset of the values contained in the grid file. When \fBGMT\fP needs a little help with that, you can add the suffix \fB=\fP\fIid\fP[\fB/\fP\fIscale\fP\fB/\fP\fIoffset\fP[\fB/\fP\fInan\fP]], where \fIid\fP is a two-letter identifier of the grid type and precision, and \fIscale\fP and \fIoffset\fP are optional scale factor and offset to be applied to all grid values, and \fInan\fP is the value used to indicate missing data. See \fBgrdreformat\fP(1) and Section 4.17 of the GMT Technical Reference and Cookbook for more information. .P When reading a netCDF file that contains multiple grids, \fBGMT\fP will read, by default, the first 2-dimensional grid that can find in that file. To coax \fBGMT\fP into reading another multi-dimensional variable in the grid file, append \fB?\fP\fIvarname\fP to the file name, where \fIvarname\fP is the name of the variable. Note that you may need to escape the special meaning of \fB?\fP in your shell program by putting a backslash in front of it, or by placing the filename and suffix between quotes or double quotes. See \fBgrdreformat\fP(1) and Section 4.18 of the GMT Technical Reference and Cookbook for more information, particularly on how to read splices of 3-, 4-, or 5-dimensional grids. .SH EXAMPLES Sometimes you don't want to make a cpt file (yet) but would find it helpful\"' to know that 90% of your data lie between z1 and z2, something you cannot learn from \fBgrdinfo\fP. So you can do this to see some points on the CDF(Z) curve (use \fB\-V\fP option to see more): .br .sp \fBgrd2cpt\fP mydata.grd \fB\-V\fP > /dev/null .br .sp To make a cpt file with entries from 0 to 200 in steps of 20, and ignore data below zero in computing CDF(Z), and use the built-in master cpt file relief, run .br .sp \fBgrd2cpt\fP mydata.grd \fB\-C\fP\fIrelief\fP \fB-L\fP0/10000 \fB-S\fP0/200/20 > mydata.cpt .SH "SEE ALSO" .IR gmtdefaults (1), .IR GMT (1), .IR grdhisteq (1), .IR grdinfo (1), .IR makecpt (1)