Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

Re: Error plotting wind rose

This post was from a previous version of the WRF&MPAS-A Support Forum. New replies have been disabled and if you have follow up questions related to this post, then please start a new thread from the forum home page.

Hi,
I am trying to plot the wind rose using the scripts provided under examples on the NCL website.
This is the script I am using:
"
begin
f = addfile("/scale_wlg_persistent/filesets/project/uoa02450/Build_WRF/WRFV3/WRFV3/run/wrfout_d03_2016-12-29_00:00:00.nc","r")

uvm10 = wrf_user_getvar(f,"uvmet10",-1)
u10 = uvm10(0,:,:,:)
v10 = uvm10(1,:,:,:)

; Pick one grid point
loc = wrf_user_ll_to_ij(f, -18.21, 177.73, True)
mx = loc(0) - 1
ny = loc(1) - 1

lat1 = f->XLAT(0,ny,mx)
lon1 = f->XLONG(0,ny,mx)
res = True
res@tiMainString = "WRF: All Times: grid point ["+sprintf("%5.2f",lat1)+" , "+sprintf("%5.2f",lon1) +"]"
wspd1= ndtooned( sqrt(u10:),ny,mx)^2 + v10:),ny,mx)^2) )
wdir1= ndtooned( atan2(u10:),ny,mx),v10:),ny,mx))/0.01745329 +180. )

numPetals = 16
circFr = 10.
spdBounds = (/ 10., 20., 30., 40. /)
colorBounds = (/ "blue", "green", "yellow", "red" /)

wks = gsn_open_wks("pdf","rose")
plot = WindRoseColor (wks,wspd1,wdir1,numPetals,circFr,spdBounds,colorBounds,res)
end
"

And this the error I am getting:

"
(0) NOTE: No unstaggering required, as the input field is already on mass points.
(0) NOTE: No unstaggering required, as the input field is already on mass points.
fatal:["NclFile.c":2100]:Subscript out of range, error in subscript #1
fatal:["Execute.c":8637]:Execute: Error occurred at or near line 15 in file windrose
"

Appreciate assistance and advice as to how I can fix the problem and plot the wind rose at a grid point.

Regards
Kunal
 
It seems to not like your unstaggering. Try reading in U10 and V10 like this:

u10 = a->U10
v10 = a->V10
 
Hi,
I am still unable to plot the wind rose. The error is as follows:
"
-bash-4.2$ ncl windrose
Copyright (C) 1995-2019 - All Rights Reserved
University Corporation for Atmospheric Research
NCAR Command Language Version 6.6.2
The use of this software is governed by a License Agreement.
See http://www.ncl.ucar.edu/ for more details.
(0) NOTE: No unstaggering required, as the input field is already on mass points.
(0) NOTE: No unstaggering required, as the input field is already on mass points.
fatal:["NclFile.c":2100]:Subscript out of range, error in subscript #1
fatal:["Execute.c":8637]:Execute: Error occurred at or near line 15 in file windrose

"
Updated script:
"
begin

f = addfile("/scale_wlg_persistent/filesets/project/uoa02450/Build_WRF/WRFV3/WRFV3/run/wrfout_d03_2016-12-29_00:00:00.nc","r")

uvm10 = wrf_user_getvar(f,"uvmet10",-1)
u10 = f->U10
v10 = f->V10


; Pick one grid point
loc = wrf_user_ll_to_ij(f, -17.5564, 177.6814, True)
mx = loc(0) - 1
ny = loc(1) - 1

lat1 = f->XLAT(0,ny,mx)
lon1 = f->XLONG(0,ny,mx)
res = True
res@tiMainString = "WRF: All Times: grid point ["+sprintf("%5.2f",lat1)+" , "+sprintf("%5.2f",lon1) +"]"
wspd1= ndtooned( sqrt(u10:),ny,mx)^2 + v10:),ny,mx)^2) )
wdir1= ndtooned( atan2(u10:),ny,mx),v10:),ny,mx))/0.01745329 +180. )

numPetals = 16
circFr = 10.
spdBounds = (/ 10., 20., 30., 40. /)
colorBounds = (/ "blue", "green", "yellow", "red" /)

wks = gsn_open_wks("pdf","rose")
plot = WindRoseColor (wks,wspd1,wdir1,numPetals,circFr,spdBounds,colorBounds,res)

end
"
Appreciate assistance and advice.

Regards
Kunal
 
Hi Kunal,

I'm sorry I missed this the first time, but your lat and lon should be swapped in wrf_user_ll_to_ij. It should look like this:

loc = wrf_user_ll_to_ij(f,177.6814,-17.5564,True)

Also, make sure you load the wind rose library before the beginning of the script like so:

Code:
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/wind_rose.ncl"

begin

f = addfile("/scale_wlg_persistent/filesets/project/uoa02450/Build_WRF/WRFV3/WRFV3/run/wrfout_d03_2016-12-29_00:00:00.nc","r")
 
Hi,

Thank you! It worked well.

If I have multiple wrfout files for a year and I want to plot the wind rose, what changes do I have to do to the code?

Appreciate your advice.

Regards
Kunal
 
I'm not sure I understand. Do you want all the times in the wind rose? If so, the easiest thing to do might be to use the NCO function ncrcat. This will concatenate all your files together into one file.

ncrcat file1.nc file2.nc file3.nc alltimes.nc

https://linux.die.net/man/1/ncrcat
 
I take note.

Well, I am asking if I have multiple wrfout files and I want to use all the separate files to plot an average over a year.

But, your suggestion of combing all the files using NCO and plotting should be helpful.

Regards
Kunal
 
Top