GRID_2D Function
Returns a gridded, 1D array containing y values, given random x,y coordinates (this function works best with sparse data points).
Usage
Input Parameters
points—A (2, n) array containing the random x,y points to be gridded.
grid_x—The size of the vector to return.
Returned Value
result—A gridded, 1D array containing y values.
Keywords
Order—The order of the weighting function to use for neighborhood averaging. Points are weighted by the function:
w = 1.0 / (dist ^ Order)
where dist
is the distance to the point. (Default: 2)
XMax—The x-coordinate of the right edge of the grid. If omitted, maps the maximum x value found in the points(0, *) array to the right edge of the grid.
XMin—The x-coordinate of the left edge of the grid. If omitted, maps the minimum x value found in the points(0, *) array to the left edge of the grid.
Discussion
GRID_2D uses an inverse distance averaging technique to interpolate missing data values for 2D gridding. The gridded array returned by GRID_2D is suitable for use with the PLOT function.
GRID_2D is similar to FAST_GRID2. GRID_2D, however, works best with sparse data points (say, less than 1000 points to be gridded) and is stable when extrapolating into large void areas. (FAST_GRID2 works best with dense data points; it is considerably faster, but slightly less accurate, than GRID_2D.)
Examples
These commands show 2D gridding with sparse data points.
; Generate the data. points = INTARR(2, 10) points(*, 0) = [1,2] points(*, 1) = [1,3] points(*, 2) = [9,5] points(*, 3) = [8,0] points(*, 4) = [9,6] points(*, 5) = [9,9] points(*, 6) = [7,15] points(*, 7) = [6,-5] points(*, 8) = [0,3] points(*, 9) = [0,-1] ; Reset the viewing window and load the color table. WINDOW, 0, Colors=128 LOADCT, 4 T3D, /Reset ; Set the y-axis range for plotting. !Y.Range = [MIN(points), MAX(points)] ; Grid and plot the resulting data. yval = GRID_2D(points, 256, Order=0.5) PLOT, yval, Color=WoColorConvert(60) yval = GRID_2D(points, 256, Order=1.0) OPLOT, yval, Color=WoColorConvert(80) yval = GRID_2D(points, 256, Order=2.0) OPLOT, yval, Color=WoColorConvert(100) yval = GRID_2D(points, 256, Order=3.0) OPLOT, yval, Color=WoColorConvert(120) ; Reset the y-axis range to the default value. !Y.Range = [0.0, 0.0]
See Also
FAST_GRID2, FAST_GRID3, FAST_GRID4, GRID_3D, GRID_4D, GRID_SPHERE