http://www.ncl.ucar.edu/Document/Functions/Contributed/region_ind.shtml
Please see Example 1.
The example file is a grib file but you can use a netCDF file.
====
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
;
;
f = addfile("NARRmonhr-b_221_20021201_2100_000.grb" , "r")
glon2d = f->gridlon_221
glat2d = f->gridlat_221
printMinMax(glat2d, True)
printMinMax(glon2d, True)
latS = 30 ; California [*rough*]
latN = 43
lonL = -125
lonR = -113
ji = region_ind (glat2d,glon2d, latS, latN, lonW, lonE)
jStrt = ji(0) ; lat start
jLast = ji(1) ; lat last
iStrt = ji(2) ; lon start
iLast = ji(3) ; lon last
LAT2D = glat2d(jStrt:jLast,iStrt:iLast)
LON2D = glon2d(jStrt:jLast,iStrt:iLast)
printMinMax(LAT2D, True)
printMinMax(LON2D, True)
; read data just for the region of interest
x = f->LHTFL_221_SFC_113(:,jStrt:jLast,iStrt:iLast)
; write netCDF
system("/bin/rm -f simple.nc") ; remove any pre-existing file
ncdf = addfile("simple.nc" ,"c") ; open output netCDF file
; make time and UNLIMITED dimension
;filedimdef(ncdf,"time",-1,True)
; output regional variables directly
ncdf->lat2d = LAT2D
ncdf->lon2d = LON2D
ncdf->LHTFL = x
On 5/17/11 2:06 PM, wei chih chen wrote:
> Dear NCL users,
> I have a NARR nc file, and I just want to narrow down to the specific
> area I want. I have boundary of lat and lon for the new area. How can I
> extract the area I want and save it to a new nc file without missing
> other variables? Any command can do this? Thank you.
>
> --
> Best regards
> Wei-Chih
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue May 17 16:56:01 2011
This archive was generated by hypermail 2.1.8 : Wed May 25 2011 - 09:35:33 MDT