[ncl-talk] Running correlation giving same value for all the different years

Ipshita Majhi ipmajhi at alaska.edu
Wed Oct 29 15:13:40 MDT 2014


Dear all,

I want to calculate running correlation for All India Rainfall and I am not
able to use run_cor because the time dimension does not make sense for me.
I wrote a loop but I get the same value for all the period. There is no
error in the code output. I am not sure where i am going wrong. It will be
great if someone can help



;This is to get a 15 and 20 year running correlation for JJAS

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/run_cor.ncl"


ncol = 12
nrows=133

;Reading in the data from 1871 to 2012

air=readAsciiTable("~/Documents/PhD_June_2015/Data_AIR/air_1871_2012.txt",
ncol, "integer",2)

;Extracting Indian summer monsoon months

JJAS=air(:,7:10)

JJAS_avg=dim_avg_n(JJAS,1)
;print(dimsizes(JJAS_avg))

years=air(:,1)


;This is running correlation for 15 years

  yrStrt  = 1871
  yrLast  = 2012

  nmos    = 12
  nyrs    = yrLast-yrStrt+1
  n_15 = nyrs/15

  running_correlation_15=new(n_15,"float")

    do nyr=0,(15*n_15)-1,15
     nyrStrt = nyr         ; clarity
     nyrLast = nyrStrt+14
     running_correlation_15(nyr/15) = escorc(years,JJAS_avg )

  end do
print(running_correlation_15)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141029/637fcc96/attachment.html 


More information about the ncl-talk mailing list