Re: how to calculate seasonal means

From: Rob Nicholas <rnicholas_at_nyahnyahspammersnyahnyah>
Date: Fri Aug 27 2010 - 09:32:01 MDT

Vishali,

First off, month_to_season() isn't going to help you if your data is
4x daily -- you need to have monthly means for this to work. I'm not
aware of any NCL functions that are explicitly designed for sub-daily
data, so you may as well deal with this by brute force. As a simple
example, if you wanted JAS zonal wind for 1980-1999 and your time
variable was in the format yyyymmdd.f, you might do *something* like
the following (untested!!):

yr = fspan(1980,1999,20)
dims_u = dimsizes( u(lev|:,lat|:,lon|:,time|:) )
u_jas = new( (/dims_u(0),dims_u(1),dims_u(2),dimsizes(yr)/), float )
do i=0,dimsizes(yr)-1
    beg_date=10000*yr+0701.00
    end_date=10000*yr+0930.99
    u_jas(:,:,:,i) = dim_avg_Wrap(
u(lev|:,lat|:,lon|:,{time|beg_date:end_date}) )
end do

Second, it's not entirely clear where (in the code) you want to do the
seasonal averaging. Perhaps you could strip out all of the code (esp.
the plotting) that's not relevant for the question at hand and
indicate where you're running into trouble.

Cheers,
Rob

On Fri, Aug 27, 2010 at 5:37 AM, Vishali P. <vishali.prat@gmail.com> wrote:
>
> Hi
>
> Thanks, I was able to do the fist step...adding multiple files.
> The data were 4x Daily.
> Now I'm trying to use this function month_to_season, but I'm finding difficulties for 4 dimensions (time,lev,lat,lon)
> I am sending my script and if need any extra information, I'll provide later.
>
> Please help
>
> Vp
>
> ;*************************************************
> ; wind.ncl (1998-2004)
> ;************************************************
> 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/csm/shea_util.ncl"
> ;************************************************
> begin
> ;************************************************
> ; read in netCDF file
> ;************************************************
>   diru ="/home/Vishali/Documents/dadosVentos/"
>   filu = systemfunc("cd "+diru+" ; ls uwnd*nc")
>   print(filu)
>   fu   = addfiles(diru+filu, "r")
>
>
>   dirv ="/home/Vishali/Documents/dadosVentos/"
>   filv = systemfunc("cd "+dirv+" ; ls vwnd*nc")
>   print(filv)
>   fv   = addfiles(dirv+filv, "r")
>
> ;************************************************
> ; read in zonal [u] and meridional [v] winds
> ;************************************************
>
>   u    = short2flt(fu[:]->uwnd(1,0,:,:))
>   v    = short2flt(fv[:]->vwnd(1,0,:,:))           ; Get u, v, time (1),level (1000hpa),latitude(-90:90) and longitude(0:360) data.
>
>   printVarSummary(u)
>   printVarSummary(v)
>
>   speed = sqrt(u^2+v^2) ; wind speed magnitude
>
> ;************************************************
> ; create plot
> ;************************************************
>   wks = gsn_open_wks("ps","vector_w")              ; open a ps file
>
>   gsn_define_colormap(wks,"BlAqGrYeOrRevi200")     ; choose color map
>
>
>   vcres                         = True             ; plot mods desired
>
>   vcres@gsnFrame                = False            ; so we can draw time stamp
>   vcres@gsnSpreadColors = True                ; use full colormap
>   vcres@gsnSpreadColorEnd = -2                ; don't use added gray
>   i = NhlNewColor(wks,0.8,0.8,0.8)            ; add gray to colors
>
>   vcres@vcRefAnnoOrthogonalPosF = -1.0             ; move ref vector up
>   vcres@vcRefMagnitudeF         = 10.0             ; define vector ref mag
>   vcres@vcRefLengthF            = 0.045            ; define length of vec ref
>   vcres@vcGlyphStyle            = "CurlyVector"    ; turn on curly vectors
>   vcres@vcMinDistanceF          = 0.017
>   vcres@vcMonoLineArrowColor = False               ; create color vectors
>
>   vcres@pmTickMarkDisplayMode = "Always"        ; turn on tickmarks
>
>   ;vcres@lbOrientation = "vertical"            ; vertical label bar
>   ;vcres@pmLabelBarDisplayMode = "Always"        ; Turn on a label bar.
>   ;vcres@pmLabelBarWidthF = 1
>
>
> ;************************************************
> ; Choose a subregion
> ;************************************************
>   vcres@mpFillOn                    = False        ; turn off gray fill
>   vcres@mpOutlineBoundarySets       = "National"   ; turn on country boundaries
>   vcres@mpGeophysicalLineColor      = "Navy"       ; color of cont. outlines
>   vcres@mpGeophysicalLineThicknessF = 1.5          ; thickness of outlines
>
>   vcres@mpMaxLatF                   = 0         ;maximum latitude
>   vcres@mpMinLatF                   = -45       ;minimum latitude
>   vcres@mpMaxLonF                   = 55        ;maximum longitude
>   vcres@mpMinLonF                   = 5         ;minimum longitude
>
>   vector = gsn_csm_vector_map_ce(wks,u,v,vcres)
>
> ;************************************************
> ; add time stamp to plot
> ;************************************************
> ;  infoTimeStamp(wks,0.025,"*wnd*.nc")      ; arguments are workstation
>                                            ; size of text desired, and
>                                            ; right string.
>   frame (wks)
> end
>

--
Robert Nicholas
Department of Atmospheric Sciences
University of Washington, Box 351640
Seattle, WA 98195-1640
rnicholas@atmos.washington.edu
tel 206-438-3509, fax 206-543-0308
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Aug 27 09:32:21 2010

This archive was generated by hypermail 2.1.8 : Thu Sep 09 2010 - 05:56:39 MDT