# [ncl-talk] 回复： Re: Re: rcm2rgrid to interpolates WRF output

Thu Nov 13 09:10:45 MST 2014

```Thanks a lot for your professional method, and the problem has been solved perfectly.
Many thanks to you!
Have a good day!
----- 原始邮件 -----

[1]
Change:

rain_exp_xgrd =rcm2rgrid(lat2d,lon2d,rain_exp,lat,lon,0)

rain_exp_xgrd!0 ="south_north"
rain_exp_xgrd!1 ="west_east"
rain_exp_xgrd at south_north =lat
rain_exp_xgrd at west_east=lon
rain_exp_xgrd at unit="mm"

To:

lat            = fspan(latS, latN, nlat)
lat!0         = "lat"
lat at long_name = "latitude"
lat at units     = "degrees_north"
lat&lat      = lat

lon            = fspan(lonL, lonR, nlon)
lon!0         = "lon"
lon at long_name = "longitude"
lon at units     = "degrees_east"
lon&lon      = lon

where

latS=20 and latN=52
lonL=74 and lonR=132

You can change to fit your needs.

+++++++++
rain_exp_xgrd = rcm2rgrid_Wrap(lat2d,lon2d,rain_exp,lat,lon,0)
===

printVarSummary(rain_exp_xgrd)
===
plot = gsn_csm_contour_map(wks, rain_exp_xgrd, res)

++++++++++++++++++++++++
[3]
A noted by the documentation, latGlobeF is for global grids
Gaussia grids are always global..

D

On Wed, Nov 12, 2014 at 8:27 PM, 易路 <dg1225033 at smail.nju.edu.cn> wrote:

> Hi,Dennis Shea,
> for Mini-language Manual and use of Print are also very usful for me, since
> I'm really a new to NCL.
>     I wrote the script for interplation again, but there are still errors
> as bellow, there are no coordinate, but I failed to set them? would you
> ; rcm2rgrid********************************************
>     rain_exp(it,:,:)=wrf_user_getvar(a,"RAINNC",it)  ; it is a time step
>
>     lat2d=wrf_user_getvar(a,"XLAT",0)
>     lon2d=wrf_user_getvar(a,"XLONG",0)
>     nlat=73
>     mlon=144
>     lat=latGlobeF(nlat,"lat","latitude", "degrees_north")
>     lon=lonGlobeF(mlon,"lon","longtitude","degrees_east")
>
>     rain_exp  =wrf_user_getvar(a,"RAINNC",it)
>     rain_exp_xgrd =rcm2rgrid(lat2d,lon2d,rain_exp,lat,lon,0)
>
>     rain_exp_xgrd!0 ="south_north"
>     rain_exp_xgrd!1 ="west_east"
>     rain_exp_xgrd at south_north =lat
>     rain_exp_xgrd at west_east=lon
>     rain_exp_xgrd at unit="mm"
> printVarSummary(rain_exp_xgrd)
>
>     plot = gsn_csm_contour_map(wks,rain_exp_xgrd,res)
> ;********************************************************************
> [1]the print of rain_exp_xgrd are as follow,Coordinates are missing,how to
> set them?
> Variable: rain_exp_xgrd
> Type: float
> Total Size: 42048 bytes
>             10512 values
> Number of Dimensions: 2
> Dimensions and sizes:   [south_north | 73] x [west_east | 144]
> Coordinates:
> Number Of Attributes: 4
>   unit :        mm
>   lon : <ARRAY of 144 elements>
>   lat : <ARRAY of 73 elements>
>   _FillValue :  9.96921e+36
>
> [2] the final errors showed in the termianl are as follow, how ot correct
> my srcipt?
>
> (0)     check_for_y_lat_coord: Warning: Data either does not contain a
> valid latitude coordinate array or doesn't contain one at all.
> (0)     A valid latitude coordinate array should have a 'units' attribute
> equal to one of the following values:
> (0)         'degrees_north' 'degrees-north' 'degree_north' 'degrees north'
> 'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg north'
> (0)     check_for_lon_coord: Warning: Data either does not contain a valid
> longitude coordinate array or doesn't contain one at all.
> (0)     A valid longitude coordinate array should have a 'units' attribute
> equal to one of the following values:
> (0)         'degrees_east' 'degrees-east' 'degree_east' 'degrees east'
> 'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'
> warning:gsnAddCylic is not a valid resource in Precip_rcm2rgrid_contour at
> this time
>
> [3] I run WRF on part of my country, when I use rcm2rgrid, how should I
> choose the latGau or GlobeF? and how to set their nlat and mlon parameter,
> do they impact the output?
>
>
> Many thanks for you!!!
>
> ----- 原始邮件 -----
> 发件人: Dennis Shea <shea at ucar.edu>
> 收件人: 易路 <dg1225033 at smail.nju.edu.cn>
> 抄送: ncl-talk at ucar.edu
> 已发送邮件: Thu, 13 Nov 2014 00:26:39 +0800 (CST)
> 主题: Re: [ncl-talk] rcm2rgrid to interpolates WRF output
>
> If you are new to NCL, please read the Mini-Language Manual
>    http://www.ncl.ucar.edu/Document/Manuals/
>
> ===
>
> [1]   This is not NCL syntax. Again read the manual, please
>              rain_exp(it, nlat, nlon)==>rain_exp_xgrd
>               rain_con(it, nlat, nlon)==>rain_con_xgrd
>
> [2] Further, on all the WRF files we know of there are no variables named
> 'xlat or 'xlon'.
>      Rather ....
>
>        float XLAT(Time, south_north, west_east) ;
>                 XLAT:FieldType = 104 ;
>                 XLAT:MemoryOrder = "XY " ;
>                 XLAT:description = "LATITUDE, SOUTH IS NEGATIVE" ;
>                 XLAT:units = "degree_north" ;
>                 XLAT:stagger = "" ;
>
>         float XLONG(Time, south_north, west_east) ;
>                 XLONG:FieldType = 104 ;
>                 XLONG:MemoryOrder = "XY " ;
>                 XLONG:description = "LONGITUDE, WEST IS NEGATIVE" ;
>                 XLONG:units = "degree_east" ;
>                 XLONG:stagger = "" ;
>
> [3] Also, XLAT and XLONG are *three* dimensional.
>
>                lat2d=a->XLAT(0,:,:)
>               lon2d=a->XLONG(0,:,:)
>
> [4] Why are you doung this?     lon=fspan(0,nlon,1)
>      Try    print(lon)
>      You are gettind 1,2,3,,,,63,64 for longitudes.
>      Maybe you want
>
>          lon = *lonGlobeF*(mlon, "lon", "longitude", "degrees_east")
>
> Please use 'print or 'printVarSummary' often
>
>
>
>
>
> '
>
>
>
> On Wed, Nov 12, 2014 at 12:55 AM, 易路 <dg1225033 at smail.nju.edu.cn> wrote:
>
> > Hi all,
> >
> >  I try to use rcm2grid to interpolates WRF output data on a curvilinear
> > grid  to a rectilinear grid. But the teminal showed erros as follows:
> >
> > fatal:syntax error: line 80 in file 2gridPrecipitation.ncl before or near
> > =>rain_exp_xgrd
> >         rain_exp(it, nlat, nlon)==>rain_exp_xgrd
> > -----------------------------------------------^
> >
> > fatal:syntax error: line 81 in file 2gridPrecipitation.ncl before or near
> > =>rain_con_xgrd
> >         rain_con(it, nlat, nlon)==>rain_con_xgrd
> > -----------------------------------------------^
> >
> > fatal:Syntax Error in block, block not executed
> > fatal:error at line 177 in file 2gridPrecipitation.ncl
> >
> it?
> >
> >     rain_exp = wrf_user_getvar(a,"RAINNC",it)
> >     rain_con = wrf_user_getvar(a,"RAINC",it)
> >
> >
> > ; rcm2rgrid  **********************************************
> >         nlat=48
> >         nlon=64
> >         lat=latGau(nlat,"lat","latitude", "degrees_north")
> >         lon=fspan(0,nlon,1)
> >         lat2d=a->xlat
> >         lon2d=a->xlon
> >
> >         rain_exp_xgrd =rcm2rgrid(lat2d,lon2d,rain_exp,lat,lon,0)
> >         ;rain_con_xgrd =rcm2rgrid(lat2d,lon2d,rain_con,lat,lon,0)
> >
> >         rain_exp(it, nlat, nlon)==>rain_exp_xgrd(it,64,128)
> >         ;rain_con(it, nlat, nlon)==>rain_con_xgrd(it,64,128)
> >        ; rain_tot = rain_exp + rain_con
> > ;*******************************************************************
> > _______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
>
>

```