THANKS EVERYONE
THIS WORKS FOR ZOOMING INTO MY SPECIFIC AREA.
;***************************************************************************
; narr_4.ncl
;
;***************************************************************************
; [1] Read Grib file
; [2] ZOOMING IN TO SPECIFIC LOCATION
;**************************************************************
; Only one variable is done here. Howvever, this could readily
; be expanded to multiple variables.
;**************************************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
begin
FILES = systemfunc ("ls narrmon-a_221*.grb")
numFILES = dimsizes(FILES)
print(numFILES)
do ifil = 0,numFILES-1
print(ifil)
print(FILES(ifil))
f = addfile (FILES(ifil), "r")
str = FILES(ifil)
strs = str_split(str, "_")
print("'" + strs + "'")
prefix = strs(2)
;system("/bin/rm -f "+filo)
print(str)
print(prefix)
;*******************************************
; open file and read in data
;*******************************************
glon2d = f->gridlon_221
glat2d = f->gridlat_221
printMinMax(glat2d, True)
printMinMax(glon2d, True)
latS = 35 ; Nebraska [*rough*]
latN = 45
lonL = -105
lonR = -93
ji = region_ind (glat2d,glon2d, latS, latN, lonL, lonR)
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->PRATE_221_SFC_113(jStrt:jLast,iStrt:iLast)
dimx = dimsizes( x )
nlat = dimx(0)
mlon = dimx(1)
print(dimx)
print(nlat)
print(mlon)
;********************************************
; create plots
;********************************************
wks = gsn_open_wks ("pdf", prefix)
print(prefix)
gsn_define_colormap (wks,"gui_default") ; choose color map
res = True ; plot mods desired for original grid
res@cnFillOn = True ; color fill
res@cnLinesOn = False ; no contour lines
res@cnLineLabelsOn = False ; no contour labels
res@gsnSpreadColors = True ; use total colormap
res@gsnSpreadColorStart = 4
res@gsnSpreadColorEnd = -1
res@cnInfoLabelOn = False ; no contour info label
res@mpGridAndLimbOn = True
res@mpGridLineDashPattern = 2 ; lat/lon lines as dashed
res@pmTickMarkDisplayMode = "Always" ; turn on tickmarks
res@tmXTOn = True
res@mpOutlineBoundarySets = "USStates" ; turn on state boundaries
res@gsnAddCyclic = False ; regional data
res@mpLimitMode = "Corners" ; choose range of map
res@mpLeftCornerLatF = LAT2D(0,0)
res@mpLeftCornerLonF = LON2D(0,0)
res@mpRightCornerLatF = LAT2D(nlat-1,mlon-1)
res@mpRightCornerLonF = LON2D(nlat-1,mlon-1)
res@tfDoNDCOverlay = True
res@mpProjection = "LambertConformal"
res@mpLambertParallel1F = 40
res@mpLambertParallel2F = 41
res@mpLambertMeridianF = -100 ; middle longitutude Nebraska
res@lbLabelBarOn = True
res@gsnCenterString = strs(2)+" Precip"
res@gsnLeftString = "Original grid"
plot= gsn_csm_contour_map(wks,x,res) ; Draw original grid
delete(f)
delete(x)
delete(wks)
delete(strs)
delete(str)
end do
end
Jane Okalebo
PhD student
HPRCC, School of Natural Resources
University of Nebraska-Lincoln
249 Hardin Hall
3310 Holdrege,
Lincoln, Nebraska 68583-0749 U.S.A.
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Sep 6 10:15:46 2012
This archive was generated by hypermail 2.1.8 : Tue Sep 11 2012 - 15:30:42 MDT