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

Plotting Daily, Weekly, Monthly and Yearly averages on one Map for each

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 new to WRF and NCL and I am using NCL to do post-processing of wrfout files and I would like to know how I can plot averages of atmospheric parameters on one map for a set time period of 1 day, 1 week, 1 month and 1 year etc.

I want to map for instance average wind speed for one day on one map, average wind speed for one week on one map, average wind speed for one month on one map and so on.

Also, if I want to plot wind power density in a similar manner how can I do it?

I have looked at the example scripts for NCL but I could not locate any that could assist me on the above.

Appreciate if you can suggest or guide me regarding these.

Regards
Kunal
 
Hi Kunal,

First I will start out by pointing you to some pages that have excellent examples of NCL scripts and WRF-specific NCL scripts that will be very helpful to you:

http://www.ncl.ucar.edu/Applications/
http://www2.mmm.ucar.edu/wrf/OnLineTutorial/Graphics/NCL/NCL_examples.htm

More specifically, I will point you to this script to get you started:
http://www2.mmm.ucar.edu/wrf/OnLineTutorial/Graphics/NCL/Examples/BASIC_SFC/wrf_Surface_multi_files.ncl

The following lines in the script read in multiple files and variables. Reading in multiple files and all the times will set you up to be able to make your averages. The "-1" in the wrf_user_getvar function indicates you want to read in all the times available.

**************************************
a = addfiles(FILES+".nc","r")

times = wrf_user_getvar(a,"times",-1) ; get all times in the file
ntimes = dimsizes(times) ; number of times in the file

slp = wrf_user_getvar(a,"slp",-1) ; slp
***************************************

Now for your averages. The following line in the script calculates temperature in Fahrenheit. This is also a great spot to do your averaging.

**************************************
tf2 = 1.8*tc2+32. ; Turn temperature into Fahrenheit
***************************************

NCL has a number of functions to help you do this. Say you want a monthly average of SLP. Read in all the files for the month and then insert a line like this:

slp_mon_avg = dim_avg_n(slp,0)

This calculates an averages over the 0th dimension, which here is time.

The next part of the script loops through times. You will want to remove the do loop and just plot your new average variable.
 
Hi abjaye,

I take note and thank you for the information.
I am able to plot from the examples of NCL scripts.

As for your suggestion on averages regarding slp, would it be possible to provide me with a script that is working.

I tried the script as it is and I am getting a warning message "dimension sizes do not confirm to others in list; skipping file".

I have 8 wrfout files: 1 for d01, 2 for d02 and 5 for d03.

Appreciate your assistance.

Regards
Kunal
 
It seems like you might be trying to read in files from multiple domains at the same time. Are you reading in the files for d01, d02, and d03 all together? If so, try reading only d03.

If this doesn't work, please send your whole script so that I can look at it more closely.
 
Hi abjaye,

I used the following script and in 1-M folder I just had d03 files:
"
begin
DATADir = "Desktop/data/Build_WRF/WRFV3/run/1-M/"
FILES = systemfunc (" ls -1 " + DATADir + "wrfout*")
numFILES = dimsizes(FILES)
print("numFILES = " + numFILES)
print(FILES)
print (" ")

type = "x11"

wks = gsn_open_wks(type,"plt_Surface_multi_files")

res = True
res@MainTitle = "REAL-TIME WRF"
res@Footer = False

pltres = True
mpres = True

a = addfiles(FILES+".nc","r")

times = wrf_user_getvar(a,"times",-1)
ntimes = dimsizes(times)

slp = wrf_user_getvar(a,"slp",-1)
wrf_smooth_2d( slp, 3 )
tc = wrf_user_getvar(a,"tc",-1)
u = wrf_user_getvar(a,"ua",-1)
v = wrf_user_getvar(a,"va",-1)
td2 = wrf_user_getvar(a,"td2",-1)
tc2 = wrf_user_getvar(a,"T2",-1)
tc2 = tc2-273.16
u10 = wrf_user_getvar(a,"U10",-1)
v10 = wrf_user_getvar(a,"V10",-1)

tf2 = 1.8*tc2+32.
tf2@description = "Surface Temperature"
tf2@units = "F"
u10 = u10*1.94386
v10 = v10*1.94386
u10@units = "kts"
v10@units = "kts"

do it = 0,ntimes-1,2

print("Working on time: " + times(it) )
res@TimeLabel = times(it)


opts = res
opts@cnFillOn = True
opts@ContourParameters = (/ -20., 90., 5./)
opts@gsnSpreadColorEnd = -3
contour_tc = wrf_contour(a[it],wks,tf2(it,:,:),opts)
delete(opts)

opts = res
opts@cnLineColor = "Blue"
opts@cnHighLabelsOn = True
opts@cnLowLabelsOn = True
opts@ContourParameters = (/ 900., 1100., 4. /)
opts@cnLineLabelBackgroundColor = -1
opts@gsnContourLineThicknessesScale = 2.0
contour_psl = wrf_contour(a[it],wks,slp(it,:,:),opts)
delete(opts)

opts = res
opts@FieldTitle = "Wind" ; overwrite Field Title
opts@NumVectors = 47 ; density of wind barbs
vector = wrf_vector(a[it],wks,u10(it,:,:),v10(it,:,:),opts)
delete(opts)

plot = wrf_map_overlays(a[it],wks,(/contour_tc,contour_psl,vector/),pltres,mpres)

end do
end
"
And I get the following as command output but no plots:
"
(0) numFILES = 5

Variable: FILES
Type: string
Total Size: 40 bytes
5 values
Number of Dimensions: 1
Dimensions and sizes: [5]
Coordinates:
(0) Desktop/data/Build_WRF/WRFV3/run/1-M/wrfout_d03_2016-02-01_00:00:00
(1) Desktop/data/Build_WRF/WRFV3/run/1-M/wrfout_d03_2016-02-07_22:40:00
(2) Desktop/data/Build_WRF/WRFV3/run/1-M/wrfout_d03_2016-02-14_21:20:00
(3) Desktop/data/Build_WRF/WRFV3/run/1-M/wrfout_d03_2016-02-21_20:00:00
(4) Desktop/data/Build_WRF/WRFV3/run/1-M/wrfout_d03_2016-02-28_18:40:00
(0)
"

Appreciate assistance and advice.

Regards
Kunal
 
Hi,

Your script works fine on my end with some wrfout files that I have. Do you have your X11 window working properly? Try writing to a pdf instead and see if you get a file.

Change this line:

type = "x11"

To this:

type = "pdf"
 
Thank you it worked.

Do you have a sample script for plotting monthly means on one map?

Appreciate your assistance and advice.

Regards
Kunal
 
Top