Re: interp WRF to WRF using NCL 6.0.0

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue Aug 21 2012 - 08:19:12 MDT

Since WRF grids are curvilinear you can not use linint2.
Using rcm2rgrid=>rgrid2rcm would 'work' but it would be slow.
You would have to make sure that the 'rgrid' is at a high resolution.
Preferably higher that the original grid.

--
The best way is to upgrade and use the ESMF regrid in 6.1.0-beta
     http://www.ncl.ucar.edu/Applications/ESMF.shtml
Example 16 would be a base template.
On 8/20/12 11:39 AM, Schiffer, Nicole June wrote:
> Hi all,
>
> I want to interpolate WRF variables from one lambert conformal grid to
> another. Would it be best to use linint2 or rcm2rgrid and rgrid2rcm? I am
> using HGT_M, XLAT_M, and XLONG_M.
>
> In trying to use linint2, NCL complains that my longitude array is 2D and
> it wants 1D (though the documentation says 2D should be okay). As far as I
> can tell, longitude (xi) monotonically increases in the x direction and
> latitude (yi) monotonically increases in the y direction.
>
>
> The error says "fatal:Number of dimensions in parameter (0) of
> (linint2_Wrap) is (2), (1) dimensions were expected."
The doc for linint2 is correct. It is bit confusing due to some special
applications that some users needed.
linint2 is for rectilinear to rectilinear not rectilinear to
curvilinear. A rectilinear grid is one where for each input/output
grid the x/y (lon/lat) are one dimensional.
>
> I am using NCL 6.0.0, so unfortunately I cannot try the new ESMF functions.
>
> My code is included below.
>
> Thanks,
> Nicole
>
> ----------------
> NCL CODE:
>
> ; load community-contributed NCL functions
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> ; set constants
> varname = (/"terrain"/)
> resolutionc = "25km"
> resolutionf = "10km"
>
> pathc = "./2004/25km/WPS/NAM25/"
> pathf = "./2004/10km/WPS/NAM/"
>
> ;**************
> ; Main Program
> ;**************
>
> begin
>
> ; assign output file name
> outfilename = "./"+resolutionc+"-"+resolutionf+"terrain"
>
> ; assign input file names
> filec = addfile(pathc+"geo_em.d01.nc","r")
> filef = addfile(pathf+"geo_em.d01.nc","rw")
> ;print(systemfunc("ncdump -h "+pathc+"geo_em.d01.nc"))
> ;print(pathc+"geo_em.d01.nc")
> ;print(isfilepresent(pathc+"geo_em.d01.nc"))
>
> ; initialize regridded array variables
> nclat = dimsizes(filec->XLAT_M(0,:,:))
> nclon = dimsizes(filec->XLONG_M(0,:,:))
> nctopo = dimsizes(filec->HGT_M(0,:,:))
> coarselat = new(nclat,float)  ;coarse grid latitude
> coarselon = new(nclon,float)  ;coarse grid longitude
> coarsetopo = new(nctopo,float)  ;coarse grid topo
>
> nflat = dimsizes(filef->XLAT_M(0,:,:))
> nflon = dimsizes(filef->XLONG_M(0,:,:))
> nftopo = dimsizes(filef->HGT_M(0,:,:))
> finelat  = new(nflat,float)  ;fine grid latitude
> finelon  = new(nflon,float)  ;fine grid longitude
> finetopo = new(nftopo,float)  ;fine grid topo
>
> ; read in coarse and fine lat-lon data
> coarselat = filec->XLAT_M(0,:,:)
> coarselon = filec->XLONG_M(0,:,:)
> finelat = filef->XLAT_M(0,:,:)
> finelon = filef->XLONG_M(0,:,:)
>
> print("Reading terrain data from input file...")
> ; read in coarse terrain
> ; | don't need to read in fine terrain b/c would overwrite it anyhow
> ; | finetopo = filef->HGT_M(0,:,:)
> coarsetopo = filec->HGT_M(0,:,:)
> ; make sure merdata has attributes (inc. missing value)
> copy_VarAtts(getfilevaratts(filec,"HGT_M"),coarsetopo)
> copy_VarAtts(getfilevaratts(filef,"HGT_M"),finetopo)
> printVarSummary(coarsetopo)
>
> ; regrid data and lat-lon using linint2_Wrap (_Wrap preserves metadata)
> ; | *linint2_Wrap(oldx,oldy,olddata,cyclic,newx,newy)
> ; | **rightmost dimensions of arg[2] must be lat, lon**
> ; | *bilinear interpolation in x-dim, then y-dim
> ; | *if new dims are outside old dims, extra values set to missing
> ; | *processed annually
> print("Interpolating data...")
> finetopo = \
>        linint2_Wrap(coarselon,coarselat,coarsetopo,False,finelon,finelat,0)
>
> printVarSummary(finetopo)
>
> ; write regridded data to file
> print("Writing data...")
> filef->HGT_M(0,:,:) = finetopo
> print("Writing latitude...")
> filef->XLAT_M(0,:,:) = finelat
> print("Writing longitude...")
> filef->XLONG_M(0,:,:) = finelon
>
> end
>
> _______________________________________________
> 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 Aug 21 08:19:37 2012

This archive was generated by hypermail 2.1.8 : Thu Aug 23 2012 - 16:16:15 MDT