interp WRF to WRF using NCL 6.0.0

From: Schiffer, Nicole June <nschiff2_at_nyahnyahspammersnyahnyah>
Date: Mon Aug 20 2012 - 11:39:14 MDT

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."

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
Received on Mon Aug 20 11:39:23 2012

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