IDL

GRID_INPUT

GRID_INPUT

The GRID_INPUT procedure preprocesses and sorts two-dimensional scattered data points, and removes duplicate values. This procedure is also used for converting spherical coordinates to Cartesian coordinates.

Note: GRID_INPUT accepts complex input but only utilizes the real part of any complex number.

Syntax


GRID_INPUT, X, Y, F, X1, Y1, F1 [, DUPLICATES=string ] [, EPSILON=value ] [, EXCLUDE=vector ]

or

GRID_INPUT, Lon, Lat, F, Xyz, F1, /SPHERE [, /DEGREES] [, DUPLICATES=string ] [, EPSILON=value ] [, EXCLUDE=vector ]

or

GRID_INPUT, R, Theta, F, X1, Y1, F1, /POLAR [, /DEGREES] [, DUPLICATES=string ] [, EPSILON=value ] [, EXCLUDE=vector ]

Arguments


X, Y

These are input arguments for scattered data points, where X, and Y are location. All of these arguments are N point vectors.

F

The function value at each location in the form of an N point vector.

Lon, Lat

These are input arguments representing scattered data points on a sphere, specifying location (longitude and latitude). All are N point vectors. Lon, Lat are in degrees or radians (default).

R, Theta

These are scattered data point input arguments representing the R and Theta polar coordinate location in degrees or radians (default). All arguments are N point vectors.

X1, Y1, F1

These output arguments are processed and sorted single precision floating point data which are passed as the input points to the GRIDDATA function.

Xyz

Upon return, a named variable that contains a 3-by-n array of Cartesian coordinates representing points on a sphere.

Keywords


DEGREES

By default, all angular inputs and keywords are assumed to be in radian units. Set the DEGREES keyword to change the angular input units to degrees.

DUPLICATES

Set this keyword to a string indicating how duplicate data points are handled per the following table. The case (upper or lower) is ignored. The default setting for DUPLICATES is “First”.

 

String

Meaning

"First"

Retain only the first encounter of the duplicate locations.

"Last"

Retain only the last encounter of the duplicate locations.

"All"

Retains all locations, which is invalid for any gridding technique that requires a TRIANGULATION. Some methods, such as Inverse Distance or Polynomial Regression with no search criteria can handle duplicates.

"Avg"

Retain the average F value of the duplicate locations.

"Midrange"

Retain the average of the minimum and maximum duplicate locations ((Max(F) + Min (F)) / 2).

"Min"

Retain the minimum of the duplicate locations (Min(F)).

"Max"

Retain the maximum of the duplicate locations (Max(F)).

EPSILON

The tolerance for finding duplicates. Points within EPSILON distance of each other are considered duplicates. For spherical coordinates, EPSILON is in units of angular distance, as set by the DEGREES keyword.

EXCLUDE

An N-point vector specifying the indices of the points to exclude.

POLAR

Set to indicate inputs are in polar coordinates.

SPHERE

Set to indicate inputs are in spherical coordinates. In this case, the output argument Xyz is set to a 3-by-n array containing the spherical coordinates converted to 3-dimensional Cartesian points on a sphere.

Examples


The following example uses the data from the irreg_grid1.txt ASCII file included in the examples/data subdirectory of the IDL distribution. This file contains scattered elevation data of a model of an inlet. This scattered elevation data contains two duplicate locations. The GRID_INPUT procedure is used to omit the duplicate locations.

file = FILE_SEARCH(!DIR, 'irreg_grid1.txt')
; Import the data from the file into a structure.
dataStructure = READ_ASCII(file)
; Get the imported array from the first field of the structure.
dataArray = TRANSPOSE(dataStructure.field1)
; Initialize the variables of this example from
; the imported array.
x = dataArray[*, 0]
y = dataArray[*, 1]
data = dataArray[*, 2]

Next, we display the data by scaling it to range from 1 to 253 so a color table can be applied. The values of 0, 254, and 255 are reserved as outliers. We tell IDL to use decomposed color mode (a maximum of 256 colors) and load a color table, then plot the data and show the data values in color.

scaled = BYTSCL(data, TOP = !D.TABLE_SIZE - 4) + 1B
DEVICE, DECOMPOSED = 0
LOADCT, 38
; Open a display window and plot the data points.
WINDOW, 0, XSIZE=512, YSIZE=800
!P.MULTI=[0,1,2,0,0]
PLOT, x, y, /XSTYLE, /YSTYLE, LINESTYLE = 1, $
   TITLE = 'Original Data, Scaled (1 to 253)', $
   XTITLE = 'x', YTITLE = 'y'
; Now display the data values with respect to the color table.
FOR i = 0L, (N_ELEMENTS(x) - 1) DO PLOTS, x[i], y[i], PSYM = -1, $
   SYMSIZE = 2., COLOR = scaled[i]

Finally, process the data with GRID_INPUT to sort and remove any duplicate locations, then display the results in a second window.

GRID_INPUT, x, y, data, xSorted, ySorted, dataSorted
; Scale the resulting data.
scaled = BYTSCL(dataSorted, TOP = !D.TABLE_SIZE - 4) + 1B
; Plot the resulting data points.
PLOT, xSorted, ySorted, /XSTYLE, /YSTYLE, LINESTYLE = 1, $
   TITLE = 'The Data Preprocessed and Sorted, Scaled (1 to 253)', $
   XTITLE = 'x', YTITLE = 'y'
; Now display the resulting data values with respect to the color
; table.
FOR i = 0L, (N_ELEMENTS(xSorted) - 1) DO PLOTS, $
   xSorted[i], ySorted[i], PSYM = -1, COLOR = scaled[i], $
   SYMSIZE = 2.
WSHOW, 0
!P.MULTI=0

Version History


5.5

Introduced

See Also


GRIDDATA



Notes


This page has no user notes yet. Be the first one!


This information is not subject to the controls of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR). However, it may be restricted from transfer to various embargoed countries under U.S. laws and regulations.
© 2014 Exelis Visual Information Solutions