<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi Lekshmi,
<div class=""><br class="">
</div>
<div class="">The month_to_annual function can be found in the:</div>
<div class="">
<pre style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl</pre>
<div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">I recommend looking at how the function behaves, and then creating your own function that mimics the month_to_annual but specifically for the season that you are focused on.</span></div>
<div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""><br class="">
</span></div>
<div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">For example, a 3D variable, T(</span><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">time,lat,lon) uses the rankx.eq.3:</span></font></div>
<div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">contributed.ncl</span></div>
<div class=""><br class="">
</div>
<div class=""><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""> if (rankx.eq.3) then<br class="">
ny = dimx(1) ; nlat<br class="">
mx = dimx(2) ; mlon<br class="">
nyr = -1<br class="">
xAnnual= new ( (/nyrs,ny,mx/), typeof(x), getFillValue(x)) ; contributed.ncl<br class="">
do nt=0,ntim-1,NMOS<br class="">
xTemp = x(nt:nt+NMOS1,:,:) ; cleaner code only<br class="">
nyr = nyr+1<br class="">
<br class="">
if (opt.eq.0) then<br class="">
xAnnual(nyr,:,:) = dim_sum_n ( xTemp, 0 )<br class="">
else<br class="">
xAnnual(nyr,:,:) = dim_avg_n ( xTemp, 0 )<br class="">
end if<br class="">
<br class="">
nMsg = 0 ; number of missing for current year (nyr)<br class="">
if (isatt(x,"_FillValue")) then<br class="">
nMsg = num (ismissing(xTemp) ) ; for all grid points<br class="">
end if<br class="">
<br class="">
if (nMsg.gt.0) then<br class="">
nGood = dim_num_n(.not.ismissing(xTemp), 0 ) ; (lat,lon)<br class="">
xAnnual(nyr,:,:) = mask( xAnnual(nyr,:,:), nGood.ge.nmos, True) ; ?False<br class="">
print("month_to_annual: some grid points have missing data: nt="+nt \<br class="">
+" nyr="+nyr+" num(nGood)="+num(nGood.gt.0))<br class="">
end if<br class="">
end do<br class="">
<br class="">
copy_VarAtts (x, xAnnual)<br class="">
xAnnual@NCL = "month_to_annual"<br class="">
xAnnual!0 = "year"<br class="">
copy_VarCoords_skipDim0 (x, xAnnual)<br class="">
return(xAnnual)<br class="">
end if<br class="">
</span></font><br class="">
</div>
<div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""><br class="">
</span></div>
<div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">Cheers,</span></div>
<div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">-Jonathan</span></div>
<div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""><br class="">
</span></div>
<div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""><br class="">
</span></div>
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Apr 21, 2022, at 16:52, Lekshmi M S via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" class="">ncl-talk@mailman.ucar.edu</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<div class="gmail_default" style="font-family: tahoma, sans-serif;">
<p class="">I would like to modify the following script to spatially plot the JJAS precipitation trend plot for 70years. Instead of using "month_to_annual", I think I have to use "month_to _season" here. But JJAS is not defined as a season here. Please help
me to do this for JJAS months.</p>
<pre class="">;*************************************************
; regress_4.ncl
;
; Concepts illustrated:
; - Drawing color-filled contours over a cylindrical equidistant map
; - Calculating the regression coefficient (slope) at each grid point
; - Copying attributes from one variable to another
;
;*************************************************
;
; These files are loaded by default in NCL V6.2.0 and newer
; 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"
begin
;************************************************
; Specify geographical region and time span (year-month start and end
;************************************************
latS = -90
latN = 90
lonL = 0
lonR = 360
ymStrt = 195101
ymLast = 201012
pltTitle = "Globe: "+(ymStrt/100)+"-"+(ymLast/100)
;************************************************
; Read from netCDF file: variable is type short...unpack
;************************************************
diri = "./"
fili = "<a href="http://air.sig995.mon.mean.nc/" target="_blank" class="">air.sig995.mon.mean.nc</a>"
f = addfile(diri+fili,"r")
YYYYMM = cd_calendar( f->time, -1)
iStrt = ind(YYYYMM.eq.ymStrt)
iLast = ind(YYYYMM.eq.ymLast)
x = short2flt( f->air(iStrt:iLast,{latS:latN},{lonL:lonR}) )
x = x-273.15
x@units= "degC"
printVarSummary(x) ; [time| 720]x[lat| 91]x[lon| 180]
yyyymm = cd_calendar(x&time, -1)
yyyy = yyyymm/100
dimx = dimsizes(x)
ntim = dimx(0) ; all years and months
nlat = dimx(1)
mlon = dimx(2)
year = ispan(yyyy(0), yyyy(ntim-1), 1)
nyrs = dimsizes(year)
;************************************************
; Areal averages: cos(lat) is good enough
;************************************************
xann = month_to_annual(x , 1) ; [year| 60]x[lat| 91]x[lon| 180]
xann&year = year
printVarSummary(xann)
;************************************************
; Calculate the regression coefficients (slopes)
;************************************************
rc = regCoef(year,xann(lat|:,lon|:,year|:))
rc@long_name = "Trend"
rc@units = xann@units+"/year"
copy_VarCoords(xann(0,:,:), rc) ; copy lat,lon coords
printVarSummary(rc)
;************************************************
; for illustration: change units to degC/period-used
;************************************************
rc = rc*nyrs ; (C/year)*(nyrs)
rc@units = "degC/"+nyrs+"_year"
;************************************************
; plotting parameters
;************************************************
wks = gsn_open_wks("png","regress") ; send graphics to PNG file
res = True
res@gsnMaximize = True ; make large
res@cnFillOn = True ; turn on color
res@cnLinesOn = False ; turn off contour lines
res@cnLineLabelsOn = False ; turn off contour line labels
;;res@cnFillMode = "RasterFill"
res@cnLevelSelectionMode = "ManualLevels<a href="mailto:;setmanualcontourlevelsres@cnMinLevelValF=-2.0;setmincontourlevelres@cnMaxLevelValF=2.0;setmaxcontourlevelres@cnLevelSpacingF=0.2;setcontourintervalres@mpFillOn=False;turnoffdefaultbackgroundgray;res@mpCenterLonF=180res@gsnCenterString=year(0)+" target="_blank" class="">" ; set manual contour levels
res@cnMinLevelValF = -2.0 ; set min contour level
res@cnMaxLevelValF = 2.0 ; set max contour level
res@cnLevelSpacingF = 0.2 ; set contour interval
res@mpFillOn = False ; turn off default background gray
;res@mpCenterLonF = 180
res@gsnCenterString = year(0)+"</a>-"+year(nyrs-1)
res@tiMainString = "20th Century Reanalysis: sig995" ; fili
plot = gsn_csm_contour_map_ce(wks,rc,res)
end<br class="">
</pre>
</div>
</div>
_______________________________________________<br class="">
ncl-talk mailing list<br class="">
<a href="mailto:ncl-talk@mailman.ucar.edu" class="">ncl-talk@mailman.ucar.edu</a><br class="">
List instructions, subscriber options, unsubscribe:<br class="">
https://mailman.ucar.edu/mailman/listinfo/ncl-talk</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>