Re: ask about interpolate function

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Fri, 21 Mar 2008 14:56:46 -0600

I do not understand.

[1] f2gsh .... is designed for global rectilinear grids. All of the *sh
function are.
      The "sh" means spherical harmonics. This is clearly stated in the
documentation.

[2] It seems to me that you want to interpolate "tc" from the WRF grid
     to the latitudes and longitudes you subselected from the NCEP grid.

      Both of these grids are, I think, on curvilinear grids.

[3] The way you have created the "latncep" and "lonncep" coordinates
                  latncep=gridlat(is:ie,js)
                   lonncep=gridlon(is,js:je)
       these are 1D grids

[4] In this case, "triple2grid" may be your best bet.

     wlat = ndtooned(xlat)
     wlon = ndtooned(xlon)
     wval = ndtooned(tc)

     opt = False ; change later.

     tcNew = triple2grid(wlon, wlat, wval, lonnvep, latncep, opt)

     copy_VarAtts(tc, tcNew)
     tcNew!0 = "lat"
     tcNew!1 = "lon"
     tcNew&lat = latncep
     tcNew&lon = lonncep
     printVarSummary(tcNew)
     printMinMax(tcNew, True)

    

Xiaofeng Lou wrote:
> Hi,
> I want to interploate wrf model output data to ncep data point. The
> wrf is not golbal, it is (36,117,135). The ncep data is 30' of
> latitude and longitude. So I should not use f2fsh. But when I use
> f2gsh, it also doesn't work. The message is:
> fatal:_NclBuildArray: each element of a literal array must have the
> same dimension sizes, at least one item doesn't
> fatal:Execute: Error occurred at or near line 77 in file la.ncl
>
> the following is the source code:
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> begin
> directory="/home/fddasys/verification/"
> directory4="/data/input/nam212/"
> a = addfile(directory+"wrfout_d02_2008-03-14_11:00:00.GRM_F.nc","r")
> b = addfile(directory4+"2008031912_fh.0072_tl.press_gr.awip3d.grib2","r")
> type = "ps"
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ; read in data from wrf model output
> time = 0
> xlat= wrf_user_getvar(a,"XLAT",time) ; laT
> xlon= wrf_user_getvar(a,"XLONG",time) ; lon
> tc = wrf_user_getvar(a,"tc",time) ; Tc in C
>
> cct = new((/117,135/),float)
> id=134
> jd=116
> kd=36
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ; read in data from ncep data
> sct=b->TMP_P0_L3_GLC0
> gridlat=b->gridlat_0
> gridlon=b->gridlon_0
> dims=dimsizes(sct)
> alat=dims(1)
> alon=dims(0)
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ;;;;;;;;;;narrow ncep data in (35:40, -110:-105) as wrf output data
> i=0
> j=0
> if (i.lt. alat) then
> do while (gridlat(i,j) .lt. 35)
> is=i
> i=i+1
> end do
> end if
> if (i.lt. alat) then
> do while (gridlat(i,j) .lt. 40)
> ie=i
> i=i+1
> end do
> end if
> j=0
> if (j .lt. alon) then
> do while (gridlon(i,j) .lt. -110)
> j=j+1
> js=j
> end do
> end if
> if (j .lt. alon) then
> do while (gridlon(i,j) .lt. -105)
> j=j+1
> je=j
> end do
> end if
>
> scct=sct(is:ie,js:je)
> print (gridlat(is:ie,js:je))
> print (gridlon(is:ie,js:je))
> scct!1 = "lonncep"
> scct!0 = "latncep"
> latncep=gridlat(is:ie,js)
> lonncep=gridlon(is,js:je)
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ;convert tc to 2d array
> cct=tc(1,:,:)
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ; interpolate grid to ncep point
> ;t2s = natgrid(slon, slat, t2, slon,slat)
> ccts=f2gsh_Wrap(cct(:,:),(/latncep,lonncep/),0)
> end
>
>
>
> I am not sure that whether the cct(lat,lon)'s demension sizes of lat
> and lon should be the same sizes of latncep and lonncep for f2gsh_Wrap.
> Thank you!
> Xiaofeng
>
>
>
>
> Dennis Shea wrote:
>> You have not included enough information.
>>
>> What are the grid types of the WRF and satellite data?
>> If the WRF and satellite grids are not global, then f2fsh which uses
>> spherical harmonics is not applicable [as noted in the documentation].
>>
>>
>>
>>
>> Xiaofeng Lou wrote:
>>> Hello,
>>> I am using NCL in verification of model results with satellite data.
>>> For the wrf model output is in grid net, and the satellite data is
>>> more sparse, I need to interpolate model output to satellite data
>>> point. I use f2fsh function as t2s= f2fsh
>>> (t2(lat|:,lon|:),(/slat,slon/)), where lat and lon are dimension
>>> size of t2, and slat and slon are dimension size of satellite data.
>>> Dimension size of slat and slon is 6, the t2s size should be (6*6),
>>> but the t2s size is (40*41).
>>> Should I use another interpolate function or something is wrong in
>>> 2s= f2fsh (t2(lat|:,lon|:),(/slat,slon/))?
>>> Thank you!
>>> xiaofeng

-- 
======================================================
Dennis J. Shea                  tel: 303-497-1361    |
P.O. Box 3000                   fax: 303-497-1333    |
Climate Analysis Section                             |
Climate & Global Dynamics Div.                       |
National Center for Atmospheric Research             |
Boulder, CO  80307                                   |
USA                        email: shea 'at' ucar.edu |
======================================================
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Mar 21 2008 - 14:56:46 MDT

This archive was generated by hypermail 2.2.0 : Sun Mar 23 2008 - 15:01:36 MDT