FAST_GRID2 Function
Returns a gridded, 1D array containing y values, given random x, y coordinates (this function works best with dense data points).
Usage
result = FAST_GRID2(points, grid_x)
Input Parameters
pointsA (2, n) array containing the random x, y points to be gridded.
grid_xThe x dimension of the grid. The x values are scaled to fit this dimension.
Returned Value
resultA gridded 1D array containing y values.
Keywords
IterThe number of iterations on the smooth function. The execution time increases linearly with the number of iterations. The default is 3, but any non-negative integer (including zero) may be specified.
NghbrThe size of the neighborhood to smooth. If not supplied, the neighborhood size is calculated from the distribution of the points. The amount of memory required increases by the square of neighborhood size.
No_AvgNormally, if multiple data points fall in the same cell in the gridded array, then the value of that cell is the average value of all the data points that fall in that cell. If the No_Avg keyword is present and nonzero, however, the value of the cell in the gridded array is the total of all the points that fall in that cell.
XMaxThe 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.
XMinThe 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
FAST_GRID2 uses a neighborhood smoothing technique to interpolate missing data values for 2D gridding. The gridded array returned by FAST_GRID2 is suitable for use with the PLOT function.
FAST_GRID2 is similar to GRID_2D. FAST_GRID2, however, works best with dense data points (more than 1000 points to be gridded) and is considerably faster, but slightly less accurate, than GRID_2D. (GRID_2D works best with sparse data points and is stable when extrapolating into large void areas.)
 
note
For best results, use a small neighborhood (such as 3) and a large number of iterations (more than 16).
Examples
This program shows 2D gridding with dense data points.
; Set up the data points.
points = INTARR(2, 10)
points(*, 0) = [1, 2]
points(*, 1) = [2, 3]
points(*, 2) = [5, 5]
points(*, 3) = [8, 0]
points(*, 4) = [9, 6]
points(*, 5) = [4, 9]
points(*, 6) = [7, 15]
points(*, 7) = [6, -5]
points(*, 8) = [0, 3]
points(*, 9) = [0, -1]
; Set up the viewing window and load the color table.
WINDOW, 0
LOADCT, 0 & TEK_COLOR
T3D, /Reset
; Set the y-axis range for plotting.
!Y.Range = [MIN(points), MAX(points)]
; Grid and plot the points using different values for
; the neighborhood and number of iterations.
yval = FAST_GRID2(points, 256, Iter=0)
PLOT, yval, Color=WoColorConvert(11), Background=WoColorConvert(255)
yval = FAST_GRID2(points, 256, Iter=150, Nghbr=3)
OPLOT, yval, Color=WoColorConvert(8)
yval = FAST_GRID2(points, 256, Nghbr=77)
OPLOT, yval, Color=WoColorConvert(6)
yval = FAST_GRID2(points, 256)
OPLOT, yval, Color=WoColorConvert(3)
; Reset the y-axis range to the default value.
!Y.Range = [0.0, 0.0]
See Also