Re: About how to draw the NARR data in a limited area

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Tue Sep 11 2012 - 14:50:59 MDT

Another user had a similar question just a few days ago. Maybe her solution will help in your case. Here it is:

;***************************************************************************
; 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

Good luck
 -dave

On Sep 11, 2012, at 8:27 AM, astroqing wrote:

> Hi,
>
> I have a question that if there are some methods to draw NARR data in a limited area like (35N - 65N, 105W - 55W)?
>
> I have tried as below but it was failed, so could you help solve this problem?
> res@mpLimitMode = "Corners"
> res@mpLeftCornerLatF = 35
> res@mpLeftCornerLonF =-105
> res@mpRightCornerLatF = 65
> res@mpRightCornerLonF = -55
>
>
> Regards!
>
> Tao
>
> 2012-09-11
> _______________________________________________
> 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 Sep 11 14:51:06 2012

This archive was generated by hypermail 2.1.8 : Tue Sep 11 2012 - 15:30:41 MDT