# [ncl-talk] Help Required in plotting average 2m temperature for 24 hours for 30 days in NCL

Mon Oct 16 07:53:46 MDT 2017

```Hi Mary

How can we overlay the average of wind speed vectors in the following code

begin

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;   input from WRF

; The WRF ARW input file.

; This needs to have a ".nc" appended, so just do it.

ListSetType(b,"cat")
;LH1 = wrf_user_getvar(a,"rh2",-1)
;LH2 = wrf_user_getvar(b,"rh2",-1)
;printVarSummary(LH1)
;printVarSummary(LH2)

LH = LH1 - LH2
;LH=LH-273.16
; What times and how many time steps are in the data set?
;  times  = wrf_user_list_times(a)  ; get times in the file
times = a[:]->Times
ntimes = dimsizes(times)         ; number of times in the file
ntimes_plot = ntimes(0)

lh3d = new((/29,129,210/), float)
lh2d = new((/129,210/), float)
c = 0

do i=time_serie, ntimes_plot-2,24
lh2d(:,:) = LH(i,:,:)
lh3d(c,:,:) = lh2d(:,:)
c = c + 1

end do
lh_avg = dim_avg_n(lh3d,0)
; We generate plots, but what kind do we prefer?
type = "png"

wks = gsn_open_wks(type,"LH_d05_diff_3_1_"+hour)
; Set some basic resources
res = True

;res at ContourParameters = (/ 273., 310., 5./)
res at cnFillOn = True
res at cnLevelSelectionMode = "ExplicitLevels"
; res at cnLevels=(/-0.4,-0.2,0,0.4,0.8,1.0,1.4,1.8,2.0,2.4/)
res at cnLevels=(/-0.2,0,0.4,0.6,0.8,1.0,1.2,1.4,1.6,1.8,2.0,2.2,2.4/)
;res at cnLevelSelectionMode = "ExplicitLevels"
;res at cnLevels = (/-50,-45,-40,-35,-30,-25,-20,-15,-10,-5,0/)
;res at cnFillColors = (/12,11,10,9,8,7,6,5,4,3,2,2/)
;res at MainTitle                   = "REAL-TIME WRF"
;res at cnLevels = (/0,5,10,15,20,25,30,35,40,45,50/)
;res at cnLevels = (/0,10,20,30,40,50,60,70,80,90,100/)
;res at cnFillColors = (/2,2,3,4,5,6,7,8,9,10,11,12,13/)
;res at mpOutlineOn = False
res at InitTime = False
res at Footer = False
res at gsnMaximize = True
res at gsnPaperOrientation = "landscape"
pltres = True
pltres at NoTitles = True
pltres at gsnMaximize = True
pltres at FramePlot = False
pltres at PanelPlot = True
mpres = True
;mpres at mpFillOn = False
;mpres at mpGeophysicalLineColor = "black"
;mpres at mpGeophysicalLineThicknessF       = 0.0   ; for type = "png"
; mpres at mpDataBaseVersion="Ncarg4_1"
; mpres at mpDataSetName="Earth..4"
; mpres at mpDataResolution="Finest"
; mpres at mpOutlineOn=False

lh_avg at description = "UHI"
;lh_avg at description = "Sensible Heat Flux"

lh_avg at units = "C"
; Plotting options for LH
opts = res
opts at cnFillOn = True
;opts at ContourParameters = (/ -50., 0., 5. /)
;opts at gsnSpreadColorEnd = -3  ; End third from the last color in color map
contour_lh = wrf_contour(a[0],wks,lh_avg,opts)
delete(opts)
; MAKE PLOTS

plot = wrf_map_overlays(a[0],wks,contour_lh,pltres,mpres)

draw(plot)
frame(wks)

MSc BSc Mechanical Engineering
PhD  Research Scholar
Remote Sensing and Satellite Research Group
Department of Imaging and Applied Physics
Curtin University

Curtin University
Tel | +61 8 9266 7962
Fax | +61 8 9266 2377
Mobile | 0470 237 525

Email | m.mughal1 at postgrad.curtin.edu.au<mailto:m.lynch at curtin.edu.au>
Web | http://curtin.edu.au<http://curtin.edu.au/>

Curtin University is a trademark of Curtin University of Technology.
CRICOS Provider Code 00301J (WA), 02637B (NSW)

________________________________
From: Mary Haley <haley at ucar.edu>
Sent: Saturday, 14 October 2017 4:16:59 AM
Cc: ncl-talk at ucar.edu
Subject: Re: [ncl-talk] Help Required in plotting average 2m temperature for 24 hours for 30 days in NCL

I think this script is slightly more complicated than it needs to be.

It looks like your tc2 array is dimensioned ((/30,129,210/), and you want to skip indexes 0-11 of the leftmost dimension so that you are only averaging across indexes 12-29
​? If so, then:

tc2_avg = dim_avg_n(tc2(12:,:,:),0)​

This will give you back a 129 x 210 array, where each element is an average of the last 18 timesteps.

--Mary

On Wed, Oct 11, 2017 at 2:53 AM, Muhammad Omer Mughal <m.mughal1 at postgrad.curtin.edu.au<mailto:m.mughal1 at postgrad.curtin.edu.au>> wrote:

Hi Mary

Kindly see the script below which I use with the bash script to determine the average of 2M TEMPERATURE contained in the whole of WRF out directory. I intend to skip the first 12 hours (spin up time) and I also tend to plot the final average in one plot. Kindly let me know if you can help me out

begin

FILES   = systemfunc (" ls -1 " + DATADir + "wrfout_d05* ")

tc2 = wrf_user_getvar(a,"T2",-1)
tc2 = tc2-273.16
times = a[:]->Times
ntimes = dimsizes(times)         ; number of times in the file
ntimes_plot = ntimes(0)        ; abandon the first 12 hours

lh3d = new((/30,129,210/), float)
lh2d = new((/129,210/), float)
c = 0
do i=time_serie, ntimes_plot-2,24
lh2d(:,:) = tc2(i,:,:)
lh3d(c,:,:) = lh2d(:,:)
c = c + 1
end do
lh_avg = dim_avg_n(lh3d,0)
type = "x11"
wks= gsn_open_wks(type,"temp_"+hour)

res = True
res at cnLevelSelectionMode = "ExplicitLevels"
res at cnLevels=(/24,25,26,27,28,29,30,31,32,33,34,35,36/)
res at InitTime = False
res at Footer = False
res at gsnMaximize = True
res at gsnPaperOrientation = "landscape"
pltres = True
pltres at NoTitles = True
pltres at gsnMaximize = True
pltres at FramePlot = False
pltres at PanelPlot = True
mpres = True
mpres at mpFillOn = False
mpres at mpGeophysicalLineColor = "black"
mpres at mpGeophysicalLineThicknessF       = 0.0   ; for type = "png"
mpres at mpDataBaseVersion="Ncarg4_1"
mpres at mpDataSetName="Earth..4"
mpres at mpDataResolution="Finest"
mpres at mpOutlineOn=False

lh_avg at description = "temperature averaged"

lh_avg at units = "degree C"
opts = res
opts at cnFillOn = True
contour_lh = wrf_contour(a[0],wks,lh_avg,opts)
delete(opts)
plot = wrf_map_overlays(a[0],wks,contour_lh,pltres,mpres)

draw(plot)
frame(wks)
end

Regards

MSc BSc Mechanical Engineering
PhD  Research Scholar
Remote Sensing and Satellite Research Group
Department of Imaging and Applied Physics
Curtin University

Curtin University
Tel | +61 8 9266 7962
Fax | +61 8 9266 2377
Mobile | 0470 237 525

Email | m.mughal1 at postgrad.curtin.edu.au<mailto:m.lynch at curtin.edu.au>
Web | http://curtin.edu.au<http://curtin.edu.au/>

Curtin University is a trademark of Curtin University of Technology.
CRICOS Provider Code 00301J (WA), 02637B (NSW)

_______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu<mailto:ncl-talk at ucar.edu>
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171016/790f4fac/attachment.html>
```