Hi all,
Please go through the following code & please tell me whether it is
printing correct nearest grid points & plot.
File used. NCEP data "air.2000.nc"
IDL>print,size(air)
4 144 73 17 1464
2
261622656
IDL>print,size(air[lon])
1 144 2 144
IDL> print,size(air[lat])
1 73 2 73
;To find nearest grid point
PRO ex_grid1
fid=ncdf_open('air.2000.nc')
airid=ncdf_varid(fid,'air')
lonid=ncdf_varid(fid,'lon')
latid=ncdf_varid(fid,'lat')
ncdf_varget,fid,airid,air
ncdf_varget,fid,lonid,lon
ncdf_varget,fid,latid,lat
mlat=make_array(n_elements(lon),type=size(lon,/type))
mlat[0]=lat
nlon=lon
nlat=mlat
; A 2 degree grid with grid dimensions.
;delta = 1
dims = [144, 73]
PRINT,size(lon)
PRINT,size(mlat)
; The lon/lat grid locations
lon_grid = 72
lat_grid = 49
; Create a dependent variable in the form of a smoothly varying
; function.
f = SIN(2*lon*!DTOR) + COS(mlat*!DTOR) ;
; Initialize display.
WINDOW, 0, XSIZE = 512, YSIZE = 768, TITLE = 'Spherical Gridding'
!P.MULTI = [0, 1, 3, 0, 0]
; The following example requires triangulation.
TRIANGULATE, lon, mlat, tr
z = GRIDDATA(lon,mlat, f, /DEGREES, START = 0, DELTA = delta, $
DIMENSION = dim, /NATURAL_NEIGHBOR, TRIANGLES = tr)
PLOT,z,psym=1
;CONTOUR, z, /OVERPLOT, NLEVELS = 5, /FOLLOW
; Set system variable back to default value.
!P.MULTI = 0
CLOSE,fid
END
|