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

Mary Haley haley at ucar.edu
Fri Oct 13 14:16:59 MDT 2017


Muhammad,

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> 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
>
>
> 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/csm/contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
> load "/data/muhdomer/NSCC/scratch/WRF_myfunc.ncl"
> begin
>
>  DATADir = "./"
>
>   FILES   = systemfunc (" ls -1 " + DATADir + "wrfout_d05* ")
>
>   a       = addfiles(FILES+".nc","r")
>
>
>   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)
>     gsn_define_colormap(wks,"spread_15lev")
>
>   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)
>
>    shape_files = (/"/data/muhdomer/NSCC/scratch/Shapefiles/MYS_adm0.
> shp","/data/muhdomer/NSCC/scratch/Shapefiles/IDN_adm0.
> shp","/data/muhdomer/NSCC/scratch/Shapefiles/MP14_REGION_NO_SEA_PL.shp"/)
>
>      plot = add_coastline_sgmyid(shape_files,wks,plot,"black")
>
>      draw(plot)
>      frame(wks)
> end
>
> Regards
>
>
> Muhammad Omer
>
> Muhammad Omer Mughal
> 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 <m.lynch at curtin.edu.au>
> Web | 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
> 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/20171013/50d1e507/attachment.html>


More information about the ncl-talk mailing list