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

gibies george gibies at tropmet.res.in
Thu Oct 30 01:48:36 MDT 2014


I have a few comments on your script.


On 30 October 2014 02:43, Ipshita Majhi <ipmajhi at alaska.edu> wrote:

> 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)
>
1. Why 7:10 is the data starting third column ? Any way not related to your
question.

>
> JJAS_avg=dim_avg_n(JJAS,1)
> ;print(dimsizes(JJAS_avg))
>
> years=air(:,1)
>
2. Do you mean second column of data?

>
>
> ;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 )
>
3. What is variable "years" ? is it some meaningful index ?

>
>   end do
>
4. Any way this loop is not doing the 15 year window running correlation,

Suggestions
1. You need n_15=nyrs-15 to store 15 rear running correlation output.
2. You have to specify window while passing the data to the escorc function
like escorc(index(y1:y15),JJAS_avg(y1:y15))

3. Within the loop you can increment y1=y1+1 and y15=y15+1 for running
correlation, or you can fix the time step increment as you wish. In the
above loop you are using a 15 year time step by using do
nyr=0,(15*n_15)-1,15.

> print(running_correlation_15)
>
>
>
> _______________________________________________
> 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/20141030/ddeab413/attachment.html 


More information about the ncl-talk mailing list