Re: Any NCL function or script that can generate vertical profiles of area averaged mean for WRF variables

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Feb 03 2014 - 12:42:09 MST

Hi Kamal,

I think your code is all correct.

It can be confusing to sort out what the "loc" variable represents.

loc(*,0) refers to the starting point, and loc(*,1) to the end point.

loc(0,*) refers to longitude indexes, and loc(1,*) refers to latitude indexes.

If your "p1" variable is dimensioned time x level x lat x lon, then the following code that you sent me looks correct:

 p1 = wrf_user_getvar(f, "pressure",-1)
 p2 = dim_avg_n_Wrap(p1,0)
 p3 = p2(:,y_start:y_end,x_start:x_end)
 pres = dim_avg_n_Wrap(p3,(/1,2/))

y_start and y_end refer to loc(1,*), which are latitude indexes, so these are correct, and ditto for x_start and x_end.

If you are ever not sure if the "loc" values are correct, you can read XLAT and XLONG off the wrf output file, and plug the loc values back in and print them out:

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/wrf/WRFUserARW.ncl"

begin
  a = addfile("wrfout.nc","r")

  lat2d = wrf_user_getvar(a,"XLAT",0)
  lon2d = wrf_user_getvar(a,"XLONG",0)

  lats = (/ 46.0, 52.0 /)
  lons = (/ -56.0, -52.0 /)
  loc = wrf_user_ll_to_ij(a, lons, lats, True)

  dims = dimsizes(loc)
  rank = dimsizes(dims)
  if(rank.eq.1) then
    lat_indexes = loc(1)
    lon_indexes = loc(0)
  else
    lat_indexes = loc(1,:)
    lon_indexes = loc(0,:)
  end if

  npts = dimsizes(lat_indexes)
  do n=0,npts-1
    print("Original lat = " + lats(n) + ", new lat = " + \
          lat2d(lat_indexes(n),lon_indexes(n)))
    print("Original lon = " + lons(n) + ", new lon = " + \
          lon2d(lat_indexes(n),lon_indexes(n)))
  end do

end

You can also use "wrf_user_ij_to_ll" to double-check the values. See example 2 at:

http://www.ncl.ucar.edu/Document/Functions/WRF_arw/wrf_user_ll_to_ij.shtml

--Mary

On Feb 2, 2014, at 10:08 PM, mmkamal@uwaterloo.ca wrote:

> Hi Mary,
>
> I am able to generate a domain averaged vertical profile of potential temperature from WRF output. Please see the attached image and code. Could you please tell me whether I have applied the correct function or not.
>
> Thanks
> Kamal
>
>
> ========================================
> begin
> ;-----------------
>
> f = addfile("/scratch/wrfout_d01_2002-07-01.nc","r")
>
> ;------------------------------------
> lats = (/ 42.48, 44.73 /)
> lons = (/ -82.30, -79.48 /)
>
> loc = wrf_user_ll_to_ij(f, lons, lats, True)
>
> x_start = loc(0,0) - 1
> x_end = loc(0,1) - 1
> y_start = loc(1,0) - 1
> y_end = loc(1,1) - 1
>
> ;---------------------------------------------
> t1 = f->T + 300
> t2 = dim_avg_n_Wrap(t1,0) ; time average
> t3 = t2(:,y_start:y_end,x_start:x_end)
> theta = dim_avg_n_Wrap(t3,(/1,2/)) ; domain average
>
> ;---------------------------------------------
> p1 = wrf_user_getvar(f, "pressure",-1)
> p2 = dim_avg_n_Wrap(p1,0)
> p3 = p2(:,y_start:y_end,x_start:x_end)
> pres = dim_avg_n_Wrap(p3,(/1,2/))
>
> plot = gsn_csm_xy (wks,theta,pres,res)
>
> gsn_polyline(wks,plot,(/0,0/),(/0,1000/),False)
> frame(wks)
>
> end
>
> ========================================
>
>
> Quoting Mary Haley <haley@ucar.edu>:
>
>> Hi,
>>
>> What you are doing is a basic XY plot with a legend. Did you visit our XY plot examples page?
>>
>> http://www.ncl.ucar.edu/Applications/xy.shtml
>>
>> See examples xy_3.ncl and xy_16.ncl
>>
>> Also, see the CALIPSO page which has a panel plot of vertical profiles:
>>
>> http://www.ncl.ucar.edu/Applications/calipso.shtml
>>
>> This is the kind of question that you can get several answers to if you go to any NCL web page: www.ncl.ucar.edu, and type "vertical profile" in the "advanced" search window on the right side just under the black bar.
>>
>> I just did this, and got back a number of hits:
>>
>> http://www.ncl.ucar.edu/Support/talk_archives/2011/2096.html
>> http://www.ncl.ucar.edu/Support/talk_archives/2010/1823.html
>>
>>
>> Also, sometimes you get a hit if you go to the "tips" link at the top of our Applications page:
>>
>> http://www.ncl.ucar.edu/Applications/
>> http://www.ncl.ucar.edu/Applications/concepts_list.shtml
>>
>> Then, use your browser "search" to look for the word "profile" or "vertical".
>>
>> --Mary
>>
>>
>> On Jan 31, 2014, at 11:29 AM, mmkamal@uwaterloo.ca wrote:
>>
>>> Hi,
>>>
>>> I was wondering is there any NCL function or example script that can generate vertical profiles of area averaged mean for temperature or moisture variable from WRF or any other model output. I am attaching an example image that I want to generate. Any help would be greatly appreciated!
>>>
>>>
>>> Thanks
>>> Kamal
>>>
>>>
>>>
>>>
>>>
>>> <Domain Averaged Moisture Profile.PNG>_______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
>
>
>
>
> <pot_temp_pres.png>_______________________________________________
> 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 Mon Feb 3 12:42:22 2014

This archive was generated by hypermail 2.1.8 : Fri Feb 07 2014 - 16:39:11 MST