[ncl-talk] use rgrid2rcm to deal with TRMM 3B42

易路 dg1225033 at smail.nju.edu.cn
Wed Nov 19 05:23:21 MST 2014


Dear all,

   I downloaded the TRMM 3B42 with a format of NetCDF, and want to change to rcm for keeping consistance with WRF output data.
   
The problem is (1) the spatial area of wrf output is regioanl, for example in China, but the spatial area of TRMM is nearly global(-50,50;-180,180)
               (2) the TRMM data is grided, the wrf data is rcm (lambert)
when I want to display the regioanl (China) area of the TRMM and in a format of RCM, how to realize?

I tried writing the scriput, but it is wrong , would you please check it for me? Thanks a lot!

SCRIPT AS FOLLOWS:
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

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"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"

begin

; read data *****************************************************************

  aDataDir       ="/home/yl/wrfcase/ncl-picture/"
  aFileName      ="wrfout_d01_2003-07-02_00:00:00.nc"
  aFile          =aDataDir+aFileName
  a = addfile(aFile,"r")                                             ; a is the wrf output with the format of rcm

  bDataDir       ="/home/yl/wrfcase/TRMM/rgrid2rcm/"
  bFileName      ="trmmdata"
  bFile          =bDataDir+bFileName
  b = addfile(bFile,"r")                                             ; b is the trmm data with the format of grid

  lat2d=wrf_user_getvar(a,"XLAT",0)
  lon2d=wrf_user_getvar(a,"XLONG",0)

  xlat=b->latitude
  xlon=b->longitude
  rain=b->pcp                          
  times=b->time
  xtimes=dimsizes(times)
  year="2003"
  ;printVarSummary(xlat)
  ;printVarSummary(xlon)
  ;printVarSummary(times)
  ;printVarSummary(rain)
; set basic resources*****************************************************

   type    = "x11"
   wksname ="GrADS_rain_2rcm"
   wks     = gsn_open_wks(type,wksname)
  
  res                   = True
  res at gsnAddCyclic     = False

; set map
   res at mpGeophysicalLineColor = "Navy"
   res at mpNationalLineColor    = "Black"
  ;res at mpUSStateLineColor     = "Black"
  ;res at mpLimbLineColor        = "Black"
  ;res at mpPerimLineColor       = "Black"
  res at mpDataBaseVersion="MediumRes"    ;加入中国省界边界线
  res at mpDataSetName="Earth..4"         ;加入中国省界边界线
  res at mpOutlineSpecifiers = "China:states"   ;加入中国省界边界线

  res at pmTickMarkDisplayMode   ="Always"

  res at mpLimitMode             ="Corners"
  res at mpLeftCornerLatF        =lat2d(0,0)             ; lat2d(nlat-1,0)
  res at mpLeftCornerLonF        =lon2d(0,0)             ; lon2d(nlat-1,0)
  res at mpRightCornerLatF        =lat2d(nlat-1,mlon-1)  ; lat2d(0,nlon-1)
  res at mpRightCornerLonF        =lon2d(nlat-1,mlon-1)  ; lon2d(0,nlon-1)

  res at mpProjection            ="LambertConformal"
  res at mpLambertParallel1F     =30.
  res at mpLambertParallel2F     =60.
  res at mpLambertMeridianF      =113.5
  res at mpCenterLonF            =113.5
  res at mpFillOn                =False
  
;set grid line
  res at mpGridAndLimbOn          =True     ; defalt is True
  res at mpGridAndLimbDrawOrder   ="PostDraw" ; Draw, PostDraw
  res at pmTickMarkDisplayMode    ="Always"

  res at mpGridLineDashPattern       =0   ; 17 kinds in all 
  res at mpGridSpacingF              =5.
  res at mpGridLineThicknessF        =2
  res at mpGridLineColor             ="Grey"

; plot*************************************************************************
; do it =0,xtimes-1,1          ; TIME LOOP  0,xtimes-1,1 
    
      ;print("Working on time: " + times(it) )

      rain_it  =rain(:,:,:)
      rain_it_xgrd = rgrid2rcm(xlat,xlon,rain_it,lat2d,lon2d,0)
      rain_it_xgrd!0  ="south_north"
      rain_it_xgrd!1  ="west_east"
      rain_it_xgrd at lat2d  =lat2d
      rain_it_xgrd at lon2d  =lon2d
          
      printVarSummary(rain_it_xgrd)

      plot = gsn_csm_contour_map(wks,rain_it_xgrd,res)


 ;end do 
;*****************************************************************************

end 

;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


More information about the ncl-talk mailing list