error with rcm2rgrid for WRF interpolation

From: Erik Noble <enoble_at_nyahnyahspammersnyahnyah>
Date: Sun, 18 Jan 2009 18:34:22 +0800

I am still trying to use the rcm2 grid function correctly. I am
getting this error, which I don't understand.

"fatal:rcm2rgrid: The rightmost dimensions of fi must be nlat2d x
nlon2d, where nlat2d and nlon2d are the dimensions of the lat2d/lon2d
arrays
fatal:Execute: Error occurred at or near line 65 in file tester.ncl"

I have everything in place for the command. I don't see that anyone
has run into this error in the previous support emails. Could I have
some advice? both my ncl program and terminal history are below.
Sincerely,
Erik

bash-3.1$ ncl tester.ncl
 Copyright (C) 1995-2007 - All Rights Reserved
 University Corporation for Atmospheric Research
 NCAR Command Language Version 5.0.0
 The use of this software is governed by a License Agreement.
 See http://www.ncl.ucar.edu/ for more details.

Variable: rainfall
Type: float
Total Size: 31668 bytes
            7917 values
Number of Dimensions: 3
Dimensions and sizes: [record | 29] x [south_north | 13] x [west_east | 21]
Coordinates:
Number Of Attributes: 6
  FieldType : 104
  MemoryOrder : XY
  description : Total Accumulated Precipitation
  units : mm
  stagger :
  coordinates : XLONG XLAT
(0)
(0) Total Accumulated Precipitation: min=0 max=362.638

Variable: rainfall
Type: float
Total Size: 31668 bytes
            7917 values
Number of Dimensions: 3
Dimensions and sizes: [time | 29] x [lat | 13] x [lon | 21]
Coordinates:
Number Of Attributes: 6
  FieldType : 104
  MemoryOrder : XY
  description : Total Accumulated Precipitation
  units : mm
  stagger :
  coordinates : XLONG XLAT

Variable: rain
Type: float
Total Size: 2436 bytes
            609 values
Number of Dimensions: 2
Dimensions and sizes: [time | 29] x [lon | 21]
Coordinates:
Number Of Attributes: 6
  coordinates : XLONG XLAT
  stagger :
  units : mm
  description : Total Accumulated Precipitation
  MemoryOrder : XY
  FieldType : 104
fatal:syntax error: procedure printMinMax expects 2 arguments, got 1
fatal:error at line 34 in file tester.ncl

Variable: lat2d
Type: float
Total Size: 1092 bytes
            273 values
Number of Dimensions: 2
Dimensions and sizes: [south_north | 13] x [west_east | 21]
Coordinates:
Number Of Attributes: 5
  FieldType : 104
  MemoryOrder : XY
  description : LATITUDE, SOUTH IS NEGATIVE
  units : degrees_north
  stagger :

Variable: lon2d
Type: float
Total Size: 1092 bytes
            273 values
Number of Dimensions: 2
Dimensions and sizes: [south_north | 13] x [west_east | 21]
Coordinates:
Number Of Attributes: 5
  FieldType : 104
  MemoryOrder : XY
  description : LONGITUDE, WEST IS NEGATIVE
  units : degrees_east
  stagger :

Variable: mlon
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) 22

Variable: nlat
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) 14
fatal:rcm2rgrid: The rightmost dimensions of fi must be nlat2d x
nlon2d, where nlat2d and nlon2d are the dimensions of the lat2d/lon2d
arrays
fatal:Execute: Error occurred at or near line 65 in file tester.ncl

fatal:Variable (raingrd) is undefined
fatal:Execute: Error occurred at or near line 66 in file tester.ncl

bash-3.1$ cat tester.ncl
;rrPlot Hovmoller of WRF and TRMM Accumulated Daily Rain
;Create the WRF data from WRF output as .nc file
;Create the TRMM as an hovmoller ascii file from
http://lake.nascom.nasa.gov/Giovanni/tovas/
; Remove headers from ascii file; also figure out number of rows
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/csm/shea_util.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"

; Global
dir = "./"
wrfoutfile="Region_1_daily_24hr_wrf_West_Africa_2006-09.nc"
obsfile = "TRMMR1_9-2_10-1.ascii"
region = "Region_1"
regiontitle = "Atlantic ITCZ"
elaptime = 29 ; normally 30, but missing a day
; Read in 1st file
a = addfile (wrfoutfile,"r")
Rain = a->RAINC
rainfall = a->RAINC
printVarSummary(rainfall) ; look at the variable
printMinMax(rainfall, True ) ; contributed.ncl
rainfall!0 = "time"
rainfall!1 = "lat"
rainfall!2 = "lon"
printVarSummary(rainfall)

rearrange_rain = rainfall(time|:,lon|:,lat|:) ; reorder coordinates
for next step
; Average all lats as a function of lon for Time vs. Longitude plot
(Hovmueller diagram)
 rain=dim_avg(rearrange_rain) ; avg rightmost dimension with center dimension
copy_VarMeta(rearrange_rain, rain)
printVarSummary(rain)
printMinMax(rain)

;WRF XLAT/XLONG are (Time,south_north,west_east)
;Generally, they do not change with time.
;Hence, read then as 2D arrays

                          ; These are [*][*] (two dimensional)
 lat2d = a->XLAT(0,:,:)
 lon2d = a->XLONG(0,:,:)
 lat2d_at_units = "degrees_north" ; not required for interpolation
 lon2d_at_units = "degrees_east"
 printVarSummary(lat2d)
 printVarSummary(lon2d)
;Your 'target' (rectilinear) grid is lat[*],lon[*].
;This could be from some other model
;or you could manually create via
 latS = 5 ; regular grid output
 latN = 11
 lonL = -30
 lonR = -20

 mlon = 22 ; however many points you want, here 22
because 0.5 degree
 lon = fspan (lonL, lonR, mlon)
 lon!0= "lon"
 lon_at_units = "degrees_east"
 print(mlon)
 nlat = 14 ; however many points you want
 lat = fspan (latS,latN, nlat)
 lat!0= "lat"
 lat_at_units = "degrees_north"
 print(nlat)
raingrd = rcm2rgrid(lat2d,lon2d,rain,lat,lon,0)
printVarSummary(raingrd)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

On Sun, Jan 18, 2009 at 5:16 AM, Erik Noble <enoble_at_giss.nasa.gov> wrote:
> Dear Dennis. Thank you. Your help was more than expected help. Yes
> .....I got the latitude/longitude labels backwards...:-| Thank you.
>
> On Sun, Jan 18, 2009 at 3:54 AM, Dennis Shea <shea_at_ucar.edu> wrote:
>> a = addfile("WRF.nc","r")
>> fi = a->T ; (Time,bottom_top,south_north,west_east)
>> printVarSummary(fi) ; look at the variable
>> printMinMax(fi, True ) ; contributed.ncl
>>
>> WRF XLAT/XLONG are (Time,south_north,west_east)
>> Generally, they do not change with time.
>> Hence, read then as 2D arrays
>>
>> ; These are [*][*] (two dimensional)
>> lat2d = a->XLAT(0,:,:)
>> lon2d = a->XLONG(0,:,:)
>> lat2d_at_units = "degrees_north" ; not required for interpolation
>> lon2d_at_units = "degrees_east"
>>
>> Your 'target' (rectilinear) grid is lat[*],lon[*].
>> This could be from some other model
>> or you could manually create via
>>
>> latS =-20 ; regular grid output
>> latN = 35
>> lonL =-35
>> lonR = 35
>>
>> mlon = 50 ; however many points you want
>> lon = fspan (lonL, lonR, mlon)
>> lon!0= "lon"
>> lon_at_units = "degrees_east"
>>
>> nlat = 40 ; however many points you want
>> lat = fspan (latS,latN, nlat)
>> lat!0= "lat"
>> lat_at_units = "degrees_north"
>>
>> -----
>> v5.1.0 has a faster code but the interface is exactly the same
>>
>> Erik Noble wrote:
>>>
>>> Thank you Dennis, for pointing me to the rcm2rgrid instructions.
>>> Although there are examples, I'm not clear from the examples on what
>>> to put for the "lat" and "lon" arguments. It says that they are 1D
>>> arrays that specify the lat and lon coordinates of the regular grid
>>> and that they should be monotonically increasing. My model output is
>>> regional ( latitudes 35W to 35E, longitudes 20S to 35N).
>>
>> ?latitudes with W and E ... no
>> ?longitudes with N and S ... no
>>
>> This is confusing
>>
>> Would I put
>>>
>>> these values in for the "lat" and "lon" arguments respectively(
>>> {-35:35}",{-20:35})?
>>>
>>> function rcm2rgrid (
>>> lat2d [*][*] : numeric,
>>> lon2d [*][*] : numeric,
>>> fi : numeric,
>>> lat [*] : numeric,
>>> lon [*] : numeric,
>>> Option : numeric
>>> )
>>>
>>> return_val : numeric
>>> Thank you for your help.
>>> -Erik
>>> On Sat, Jan 17, 2009 at 1:13 PM, Dennis Shea <shea_at_ucar.edu> wrote:
>>>>
>>>> http://www.ncl.ucar.edu/Document/Functions/Built-in/rcm2rgrid.shtml
>>>>
>>>> WRF data have multidimensional lat/lon arrays:
>>>> XLAT[*][*], XLONG[*][*]
>>>>
>>>> linint2 had coordinates prototypes as one dimensional:
>>>> lat[*], lon[*]
>>>>
>>>> The rcm2rgrid in version 5.1.0 is more efficient.
>>>>
>>>>
>>>>
>>>> Erik Noble wrote:
>>>>>
>>>>> Hi. I am trying to learn how to use NCL to interpolate WRF rain data
>>>>> to observed precipitation from Satellite (TRMM).
>>>>> Some say use the linint2 function to bilinearly interpolate.
>>>>> Some don't:
>>>>> http://www.ncl.ucar.edu/Support/talk_archives/2008/0484.html
>>>>>
>>>>> Do we have any examples of using linint2 with wrf data?
>>>>> -Erik
>>>>> _______________________________________________
>>>>> 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 Sun Jan 18 2009 - 03:34:22 MST

This archive was generated by hypermail 2.2.0 : Wed Jan 21 2009 - 13:09:21 MST