[ncl-talk] average plots difficulties
Mary Haley
haley at ucar.edu
Thu Aug 14 11:00:59 MDT 2014
Saurabh,
In order to help you, we need to know more about the type of data you have,
and what kind of hourly data you have. There are many ways to calculate
averages across time, but it is very specific to your data.
For example, if you have hourly data, then this means that the "time"
dimension of your array should be a multiple of 24.
Let's further assume you wanted to calculate a 3-hour average, so,
averaging hours 0-2, 3-5, 6-8, ... 21-23.
What you can do is use "reshape" to restructure the 24 hours into a 3 x
8*ndays array, making it easier to do the 3-hour average.
Using your script, and assuming that slp is 3D and the time array is a
multiple of 24, here's what the code might look like:
a = addfiles(FILES+".nc","r") ; Open all files
slp = wrf_user_getvar(a,"PSFC",-1) ; Get sea level pressure for all times
;---Assuming "slp" is 3-dimensional
slp_dims = dimsizes(slp)
ntim = slp_dims(0)
nlat = slp_dims(1)
nlon = slp_dims(2)
ndays = ntim/24 ; This better be a multiple of 24!
slp4D = reshape(slp,(/3,8*ndays,nlat,nlon/))
copy_VarAtts(slp,slp4D)
slp_3hr_avg = dim_avg_n_Wrap(slp4D,0) ; 8*ndays x nlat x nlon
I typed this in a hurry. If you have further questions, please first visit
our posting guidelines, which give you information about where to find help:
http://www.ncl.ucar.edu/Support/posting_guidelines.shtml
--Mary
On Thu, Aug 14, 2014 at 7:19 AM, Saurabh Singh <saurabhsingh123op at gmail.com>
wrote:
> NCL version : NCL -6.1.0
> Os :UBUNTU
>
> dear sir
>
> please suggest how to plot average of any variables over a cetain time
> intervals(say daily,monthly,weekly) for hourly generated wrf output files
> generated every hour.
>
> here is a sample script that plots "slp" but it plots for each time step
> and in sepearte pdf file for each time step.,i want the plot daily avereage
> "slp" for say 3 months in a pdf file will multiple pages for every day.
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>
> begin
>
> ; Make a list of all files we are interested in
> DATADir =
> "/home/cee1/Music/Build_WRF_and_WPS.V351/WRF_and_WPS_src/WRFV3/test/em_real/2k5/"
> FILES = systemfunc (" ls -1 " + DATADir + "wrfout_d01_2005-01-01* ")
> numFILES = dimsizes(FILES)
>
> ; We generate plots, but what kind do we prefer?
> type = "pdf"
>
> res = True ; Set up some basic plot resources
> res at MainTitle = "WRF OUT FILES"
> res at Footer = False
> pltres = True
> mpres = True
> opts = res
> opts at cnFillOn = True
> do ifil = 0,numFILES-1
> wks = gsn_open_wks(type,"plt_wrfout"+ifil)
>
> a = addfile(FILES(ifil)+".nc","r") ; Open the next file
> slp = wrf_user_getvar(a,"PSFC",0) ; Get sea level pressure from file
> contour = wrf_contour(a,wks,slp,opts)
> plot = wrf_map_overlays(a,wks,(/contour/),pltres,mpres)
>
> end do
> end
>
>
>
> --
> With regards
> Saurabh Kumar singh
>
> *P** : * *Please consider the environment before printing this e-mail*
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> 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/20140814/7f243497/attachment.html
More information about the ncl-talk
mailing list