Re: WRF: Relative vorticity and Divergence

From: Sahidul <sahidul_at_nyahnyahspammersnyahnyah>
Date: Tue Apr 20 2010 - 06:55:49 MDT

Thank you very much for your help. i tried to plot it. It is giving errors.

==-------- ------- ------- ------------ ---- ----- ----- --- -- = =======
fatal:Number of subscripts on rhs do not match number of dimensions of
variable,(3) Subscripts used, (2) Subscripts expected
fatal:Execute: Error occurred at or near line 109 in file precipitation.ncl
==-------- ------- ------- ------------ ---- ----- ----- --- -- = =======

CODE is here:
==================
; Example script to produce Vorticity plots from WRF ARW model data
; Novemner 2008

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("/casvol5/basantas/cas/WRF3-1/output-wrf/2010041300/wrfout_d02_2010-04-13_00:00:
00.nc","r")

; We generate plots, but what kind do we prefer?
; type = "x11"
; type = "pdf"
 type = "ps"
; type = "ncgm"
  wks = gsn_open_wks(type,"plt_rv")

; Set some basic resources
  res = True
  res@MainTitle = "REAL-TIME WRF"

  pltres = True
  mpres = True

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; What times and how many time steps are in the data set?
  times = wrf_user_list_times(a) ; get times in the file
  ntimes = dimsizes(times) ; number of times in the file

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  do it = 0,ntimes-1,2 ; TIME LOOP

    print("Working on time: " + times(it) )
    res@TimeLabel = times(it) ; Set Valid time to use on plots

  ; Get the data
    u = wrf_user_getvar(a,"ua",it)
    v = wrf_user_getvar(a,"va",it)
    printVarSummary(u)
    p = wrf_user_getvar(a,"pressure",it)
    lat2d = wrf_user_getvar(a,"lat",it)
    lon2d = wrf_user_getvar(a,"lon",it)
    lat = lat2d(:,0)
    asciiwrite("lat.txt",lat)
    lon = lon2d(0,:)
    asciiwrite("lon.txt",lon)

    u_grid = rcm2rgrid(lat2d,lon2d,u,lat,lon,0)
    v_grid = rcm2rgrid(lat2d,lon2d,v,lat,lon,0)
    printVarSummary(u_grid)
    printVarSummary(v_grid)

    rv = uv2vr_cfd(u_grid,v_grid,lat,lon,3)
; rv = uv2vrF_Wrap(u,v)
    rv@long_name = "relative vorticity"
    rv@units = "1/s"
    rv!0 = "time"
    rv!1 = "lat"
    rv!2 = "lon"
    rv@lat = lat
    rv@lon = lon

   ; copy_VarCoords(u,rv)
    printVarSummary(rv)

    rv_grid = rgrid2rcm (rv&lat, rv&lon, rv, lat2d, lon2d, 0)
  ; Interpolate to pressure

    rv_p = wrf_user_intrp3d(rv_grid,p,"h",500.,0,False)
    printVarSummary(rv_p)
    rv_plane = rv_p*10^5
    asciiwrite("rv.txt",rv_plane)

    ; Plotting options
      opts = res
      opts@cnFillOn = True
      opts@gsnSpreadColorEnd = -3 ; End third from the last color in color
map
 mpres@mpOutlineBoundarySets = "National"
      mpres@mpGeophysicalLineColor = "Black"
      mpres@mpNationalLineColor = "Black"
      mpres@mpUSStateLineColor = "Black"
mpres@mpNationalLineThicknessF = 1.8
      mpres@mpGeophysicalLineThicknessF =1.8

      contour_rv = wrf_contour(a,wks,rv_plane,opts)
      delete(opts)

    ; MAKE PLOTS

      plot = wrf_map_overlays(a,wks,(/contour_rv/),pltres,mpres)

  end do ; END OF TIME LOOP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
end

please help us.

On Mon, Apr 19, 2010 at 11:38 PM, Evelyn Grell <Evelyn.Grell@noaa.gov>wrote:

> It looks like there is already a WRF function for computing absolute
> vorticity. See
>
>
> http://www.mmm.ucar.edu/wrf/OnLineTutorial/Graphics/NCL/Examples/DIAGNOSTICS/wrf_pv.htm
>
> Could you just use this and subtract the Coriolis factor at each grid point
> (or modify the function wrf_avo to compute relative vorticity)? I couldn't
> find the function but it needs map factors as input, so it has likely
> accounted for the coordinate issue.
>
> - Evelyn
>
>
> Dennis Shea wrote:
>
>> In order to use the suggested functions, you would have to interpolate
>> the curvilinear WRF coordinates XLAT/XLONG to a regular [rectilinear]
>> grid using:
>>
>> http://www.ncl.ucar.edu/Document/Functions/Built-in/rcm2rgrid.shtml
>> or
>>
>> http://www.ncl.ucar.edu/Document/Functions/Contribute/rcm2rgrid_Wrap.shtml
>>
>>
>> Then use the uv2dv_cfd & uv2vr_cfd functions.
>>
>> Finallay interpolate back to the original WRF coordinates
>>
>> http://www.ncl.ucar.edu/Document/Functions/Built-in/rgrid2rcm.shtml
>>
>> or
>>
>>
>> http://www.ncl.ucar.edu/Document/Functions/Contributed/rgrid2rcm_Wrap.shtml
>>
>> ====
>> Note:
>> If the purpose is for deriving vorticity/divergence is "visual",
>> then the above approach is probably adequate for both quantities.
>> However, if the derived quantities are going to be used as the basis
>> for further derivations, they should be used with extreme caution
>> [in particular, divergence].
>>
>>
>>
>> On 04/18/2010 11:44 AM, Mateus Teixeira wrote:
>>
>>
>>> Dear Sahidul,
>>>
>>> You can calculate relative vorticity and divergence with uv2vr_cfd and
>>> uv2dv_cfd, respectively. Please take a look at
>>>
>>>
>>> uv2dv_cfd -> for divergence
>>> http://www.ncl.ucar.edu/Document/Functions/Built-in/uv2dv_cfd.shtml
>>>
>>> uv2vr_cfd -> for vorticity
>>> http://www.ncl.ucar.edu/Document/Functions/Built-in/uv2vr_cfd.shtml
>>>
>>> Examples for Vorticity
>>> http://www.ncl.ucar.edu/Applications/vort.shtml
>>>
>>>
>>> I hope that it helps you.
>>>
>>> Best regards,
>>>
>>> Mateus
>>>
>>>
>>> 2010/4/18 Sahidul <sahidul@gmail.com <mailto:sahidul@gmail.com>>
>>>
>>> NCL Users,
>>>
>>> We have WRF forecast files, saved in 1 hour interval having total 88
>>> files. We want contour plot for "Relative Vorticity" and
>>> "Divergence" every hour.
>>>
>>> Is there any function or Script for calculating "Relative Vorticity"
>>> and "Divergence" ?
>>>
>>> Thanking you,
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>>
>>>
>>> --
>>> Mateus da Silva Teixeira
>>> Meteorologista
>>> Instituto de Pesquisas Meteorológicas - IPMet
>>> Universidade Estadual Paulista - UNESP
>>> Av. Luis Edmundo Carrijo Coube, 14-01 - Cx. Postal 281 - CEP 17033-360
>>> Bauru - SP - Brasil
>>> Fone: +55 14 3103-6030 / fax: 3203-3649
>>>
>>> Registered Linux User #466740 (http://counter.li.org/)
>>>
>>>
>>>
>>> _______________________________________________
>>> 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 Apr 20 06:55:58 2010

This archive was generated by hypermail 2.1.8 : Fri Apr 23 2010 - 14:40:07 MDT