grdblend - Blend several partially over-lapping grids into one large grid
grdblend [ blendfile | grid1 grid2 ... ] -Goutgrid [ -Iincrement ] [ -Rregion ] [ -Cf|l|o|u ] [ -Nnodata ] [ -Q ] [ -Zscale ] [ -V[level] ] [ -W[z] ] [ -f<flags> ] [ -r ]
Note: No space is allowed between the option flag and the associated arguments.
grdblend reads a listing of grid files and blend parameters and creates a binary grid file by blending the other grids using cosine-taper weights. grdblend will report if some of the nodes are not filled in with data. Such unconstrained nodes are set to a value specified by the user [Default is NaN]. Nodes with more than one value will be set to the weighted average value. Any input grid that does not share the final output grid’s node registration and grid spacing will automatically be resampled via calls to grdsample. Note: Due to the row-by-row i/o nature of operations in grdblend we only support the netCDF and native binary grid formats for both input and output.
By default GMT writes out grid as single precision floats in a COARDS-complaint netCDF file format. However, GMT is able to produce grid files in many other commonly used grid file formats and also facilitates so called “packing” of grids, writing out floating point data as 1- or 2-byte integers. To specify the precision, scale and offset, the user should add the suffix =id[/scale/offset[/nan]], where id is a two-letter identifier of the grid type and precision, and scale and offset are optional scale factor and offset to be applied to all grid values, and nan is the value used to indicate missing data. See grdconvert and Section Grid file format specifications of the GMT Technical Reference and Cookbook for more information.
When writing a netCDF file, the grid is stored by default with the variable name “z”. To specify another variable name varname, append ?varname to the file name. Note that you may need to escape the special meaning of ? in your shell program by putting a backslash in front of it, or by placing the filename and suffix between quotes or double quotes.
When the output grid type is netCDF, the coordinates will be labeled “longitude”, “latitude”, or “time” based on the attributes of the input data or grid (if any) or on the -f or -R options. For example, both -f0x -f1t and -R90w/90e/0t/3t will result in a longitude/time grid. When the x, y, or z coordinate is time, it will be stored in the grid as relative time since epoch as specified by TIME_UNIT and TIME_EPOCH in the gmt.conf file or on the command line. In addition, the unit attribute of the time variable will indicate both this unit and epoch.
While the weights computed are tapered from 1 to 0, we are computing weighted averages, so if there is only a single grid given then the weighted output will be identical to the input. If you are looking for a way to taper your data grid, see grdmath’s TAPER operator.
To create a grid file from the four grid files piece_?.nc, giving them each the different weights, make the blendfile like this
piece_1.nc -R<subregion_1> 1 piece_2.nc -R<subregion_2> 1.5 piece_3.nc -R<subregion_3> 0.9 piece_4.nc -R<subregion_4> 1
Then run
gmt grdblend blend.job -Gblend.nc -R<full_region> -I<dx/dy> -V
To blend all the grids called MB_*.nc given them all equal weight, try
gmt grdblend MB_*.nc -Gblend.nc -R<full_region> -I<dx/dy> -V
While grdblend can process any number of files, it works by keeping those files open that are being blended, and close files as soon as they are finished. Depending on your session, many files may remain open at the same time. Some operating systems set fairly modest default limits on how many concurrent files can be open, e.g., 256. If you run into this problem then you can change this limit; see your operating system documentation for how to change system limits.