Dear IDL Users
I had succeeded to interpolate a scattered data using 2-D girddata, but It can't projected on the right position on the map according to the following code.
Could you please help me to correct this error.
_____________
pro t1
lat=[32.05, 30.43,29.02,25.48, 24.13,32.49, 32.47,32.06,29.40]
lon=[20.16,20.10, 21.34, 21.08, 23.18, 21.51, 22.35, 23.55, 24.32]
w=[9.80,4.95,5.20, 5.60, 5.20, 11.65, 11.75, 8.75, 7.40]
scaled = BYTSCL(w, TOP = !D.TABLE_SIZE - 4) + 1B
; display the data values with respect to the color table.
FOR i = 0L, (N_ELEMENTS(Lat) - 1) DO PLOTS, Lat[i], Lon[i],$
PSYM = -1, SYMSIZE = 2., COLOR = scaled[i]
; Preprocess and sort the data.
GRID_INPUT, lon, lat, w, xSorted, ySorted, dataSorted
; Initialize the grid parameters.
gridSize = [51, 51]
; Use the equation of a straight line and the grid parameters to
; determine the x of the resulting grid.
slope = (MAX(xSorted) - MIN(xSorted))/(gridSize[0] - 1)
intercept = MIN(xSorted)
xGrid = (slope*FINDGEN(gridSize[0])) + intercept
; Use the equation of a straight line and the grid parameters to
; determine the y of the resulting grid.
slope = (MAX(ySorted) - MIN(ySorted))/(gridSize[1] - 1)
intercept = MIN(ySorted)
yGrid = (slope*FINDGEN(gridSize[1])) + intercept
; Grid the data with the Radial Basis Function method.
grid = GRIDDATA(xSorted, ySorted, dataSorted, $
DIMENSION = gridSize, METHOD = 'RadialBasisFunction')
print, grid
nlevels =30
step = (Max(grid) - Min(grid)) / nlevels
levels = IndGen(nlevels) * step + Min(grid)
LoadCT, 33, NColors=nlevels, Bottom=1
SetDecomposedState, 0, CurrentState=currentState
Contour, grid, xgrid,ygrid, /Cell_Fill, $
Levels=levels, Background=cgColor('white'), $
Position=[0.125, 0.125, 0.95, 0.80], $
Color=cgColor('black'), XStyle=1, YStyle=1, $
C_Colors=IndGen(nlevels)+1
Contour, grid, ygrid, xgrid, /Overplot, $
Color=cgColor('black'), Levels=levels, $
C_Labels=everyOther
map_set, /cylindrical, 0,0, limit=[ceil(min(lat)-0.5)-1.,ceil(min(lon)-0.5)-1., ceil( max(lat)+0.5)+1., ceil(max(lon)+0.5)+1.],/continent, $
/NoErase, Position=[0.1, 0.1, 0.8, 0.9], MLINESTYLE =0, MLINETHICK =2,$
GLINETHICK=2
print, min(xgrid), min(ygrid), max(xgrid), max(ygrid)
print, min(lat), min(lon), max(lat), max(lon)
SetDecomposedState, currentState
cgColorbar, Range=[Min(grid),Max(grid)], $
Divisions=30, XTicklen=1, XMinor=0, $
AnnotateColor='black', NColors=30, Bottom=1, $
Position=[0.125, 0.915, 0.955, 0.95], $
Charsize=0.75
end
__________ Khaled
|