Re: 回复: interpolate WRF output to isentropic levels

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Jul 09 2014 - 10:18:57 MDT

The script I sent you did all times steps. Please use printVarSummary(...)
to look at your variables.

    time = -1
    theta= wrf_user_getvar(a,"theta",time) ; [Time | 25] x [bottom_top] x
                                                                 ;
[south_north] x [west_east]
    x = wrf_user_getvar(a,"wa" ,time) ; ..... same ...
            :
    lvl = (/ 307 /)
            :
    xlvl = int2p_n_Wrap (theta, x, lvl, 0, 1)
    printVarSummary(xlvl)
====
Variable: xlvl
Type: float
Total Size: 729000 bytes
            182250 values
Number of Dimensions: 4
Dimensions and sizes: [Time | 25] x [lvl | 1] x [south_north ] x
[west_east]
Coordinates:
            lvl: [307..307] <=============
======
Number Of Attributes: 7
  _FillValue : 9.96921e+36
  coordinates : XLONG XLAT
  FieldType : 104
  MemoryOrder : XYZ
  description : z-wind component
  units : m s{-1}
====

The script you are using looks over each *individual* time step so there is
no time dimension
like in my example. *Always use printVarSummary(...)* to look at your data.

 do it = 22, 25
              theta= wrf_user_getvar(a,"theta",it) ; [bottom_top
]x[south_north] x [west_east]
              x = wrf_user_getvar(a,"wa",it) ;
0 1 2
             ;printVarSummary(theta)
             ;printVarSummary(x)

Then 'int2p_n_Wrap' was used. Please read the documentation.


https://www.ncl.ucar.edu/Document/Functions/Contributed/int2p_n_Wrap.shtml

The last argument specifies the dimension number over which the
interpolation is to occur.

In my case where I had (Time,bottom_top,south_north,west_east) ..(0,1,2,3)
I specified dimension number 1 (bottom-top0

In your case you have (bottom_top, south_north, west_east) ..(0,1,2), the
vertical dimension is number 0

Change

   xlvl = int2p_n_Wrap (theta, x, lvl, 0, 1)

To

  xlvl = int2p_n_Wrap (theta, x, lvl, 0, 0)

Again, please use printVarSummary(..) to look at a variable's size, shape
and type.
In particular when debugging.









On Wed, Jul 9, 2014 at 2:01 AM, Li Qi <liqi123sh@qq.com> wrote:

> Dear Dennis,
>
> I am trying to interpolate the vertical velocity output from WRF to a
> specified isentropic level (e.g., 307 K surface),
>
> but I got a warning message:
>
> "fatal:Dimension (bottom_top) of (xlvl) does not have an associated
> coordinate variable"
>
> Here is my code:
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>
> begin
> ;
> ; The WRF ARW input file.
> ; This needs to have a ".nc" appended, so just do it.
> a = addfile("./wrfout_d03_2011-06-13_18_00_00.nc","r")
>
> ; We generate plots, but what kind do we prefer?
> ; type = "x11"
> ; type = "pdf"
> type = "eps"
> ; type = "ncgm"
> wks = gsn_open_wks(type,"isent")
> ;gsn_define_colormap(wks,"isent") ; Overwrite the standard color
> map
>
> ; Set some basic resources
> res = True
> res@MainTitle = "REAL-TIME WRF"
>
> res@mpDataBaseVersion = "HighRes"
> res@mpDataSetName = "Earth..4"
> res@mpGridAndLimbOn = False ; Turn off lat/lo=
n
> lines
> res@mpOutlineOn = True ; Turn on map outlines
> ;res@mpGeophysicalLineColor = "Black" ; Change the outline line
> color
> res@mpGeophysicalLineThicknessF= 2. ; double the thickness of
> geophysical boundaries
> res@mpOutlineSpecifiers = (/"China","Taiwan","Disputed area betwee=
n
> India and China","India:Arunachal Pradesh"/)
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> ; Which times and how many time steps are in the data set?
> times = wrf_user_getvar(a,"times",-1) ; get all times in the file
> ntimes = dimsizes(times) ; number of times in the file
>
>
> ;Zoom
> lats = (/ 27.7, 29.7 /)
> lons = (/ 115.5, 119.5 /)
> loc = wrf_user_ll_to_ij(a, lons, lats, True)
>
> ; loc(0,;) is west-east (x) ; loc(1,:) is south-north (y)
> ; subtract one since we want to use it as an index in NCL
> x_start = loc(0,0) - 1
> x_end = loc(0,1) - 1
> y_start = loc(1,0) - 1
> y_end = loc(1,1) - 1
>
> res@mpMinLatF = lats(0)
> res@mpMaxLatF = lats(1)
> res@mpMinLonF = lons(0)
> res@mpMaxLonF = lons(1)
>
>
> ;do it = 25,ntimes-1 ; TIME LOOP
> do it = 22, 25
>
> print("Working on time: " + times(it) )
> res@TimeLabel = times(it) ; Set Valid time to use on plots
>
> ; First get the variables we will need
>
> theta= wrf_user_getvar(a,"theta",it)
>
>
> x = wrf_user_getvar(a,"wa",it)
>
>
> lvl = (/ 307. /)
> lvl@description = "isentropic level"
> lvl@units = theta@units
> lvl!0 = "lvl"
> lvl&lvl = lvl
>
>
> xlvl = int2p_n_Wrap (theta, x, lvl, 0, 1)
> xlvl@lat2d = a->XLAT(0,:,:) ; direct assignment
> xlvl@lon2d = a->XLONG(0,:,:)
> printVarSummary(xlvl)
> printMinMax(xlvl, 0)
>
> res@cnFillOn = True ;automatically creates a color bar.
> res@ContourParameters = (/ 0.1, 1.3, 0.3/) ; (/ start, end, step=
 /)
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> plot =
> gsn_csm_contour_map(wks,xlvl({lvl(0)},y_start:y_end,x_start:x_end),res)
>
>
> end do ; END OF TIME LOOP
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> end‍
> ‍
>
>
>
> ------------------ 原始邮件 -----------------=
-
> *发件人:* "Dennis Shea";<shea@ucar.edu>;
> *发送时间:* 2014年7月7日=
(星期一) 晚上10:00
> *收件人:* "Li Qi"<liqi123sh@qq.com>;
> *抄送:* "ncl-talk"<ncl-talk@ucar.edu>; "wrfhelp"<wrfhelp@uc=
ar.edu>;
> *主题:* Re: [ncl-talk] interpolate WRF output to isentropic=
 levels
>
> It is the exact same approach as outlined at
> http://www.ncl.ucar.edu/Applications/isent.shtml,%e2%80%8d
>
> Even easier because wrf_user_getvar returns theta.
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>
> a = addfile("...","r")
> time = -1
> theta= wrf_user_getvar(a,"theta",time)
> printVarSummary(theta)
>
> x = wrf_user_getvar(a,"tc" ,time)
> printVarSummary(x)
> printMinMax(x, 0)
> ; isentropic
> level(s)
> lvl = 320. ; (/300., 320.,
> 340./)
> lvl@description = "isentropic level"
> lvl@units = theta@units
>
> xlvl = int2p_n_Wrap (theta, x, lvl, 0, 1)
> printVarSummary(xlvl)
> print("xlvl: min="+min(xlvl)+" max="+max(xlvl))
> -----
> Please send WRF related questions to wrfhelp@ucar.edu
> You can cc ncl-talk@ucar.edu
>
>
>
>
> On Sun, Jul 6, 2014 at 8:35 PM, Li Qi <liqi123sh@qq.com> wrote:
>
>> Dear all,
>>
>> I'd like to interpolate a variable in WRF output to a specified
>> isentropic level.
>>
>> GrADS has a function (i.e., isen(field,tgrid,pgrid,tlev)‍) to co=
mplete
>> the task, like
>> * 1) Display vertical velocity field on 320K surface:
>> *
>> * "d "isen(w,t,PP,320)‍
>>
>> Is there any corresponding function in NCL?
>>
>> I've checked the examples and got this one:
>> http://www.ncl.ucar.edu/Applications/isent.shtml,%e2%80%8d
>>
>> but I have no idea about the hybrid coef in WRF.
>>
>> Best,
>>
>> Li Qi
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>

Received on Wed Jul 09 04:19:07 2014

This archive was generated by hypermail 2.1.8 : Wed Jul 23 2014 - 15:33:46 MDT