comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Finding nearest grid point-reg
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Finding nearest grid point-reg [message #78793] Mon, 19 December 2011 21:35
shambhu is currently offline  shambhu
Messages: 41
Registered: December 2011
Member
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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDl triangulate-reg
Next Topic: Plot points!

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 13:36:18 PDT 2025

Total time taken to generate the page: 0.36463 seconds