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

Thu Oct 30 09:08:00 MDT 2014

```Thank you . Yes! I realised that my script was not doing the running
correlation instead it was doing correlation for every 15 year time
step.Answer to the questions are as follows:-

1. Why 7:10 is the data starting third column ? Any way not related to your
question.

I am calculating average for summer months of monsoon June, July, August
and September and that is the column 7:10

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

years=air(:,1)

2. Years is the first column from air which has information for year going
from 1871 to 2012

I am incorporating the suggestion recommended.

Thank You
Best Regards
Ipshita

On Thu, Oct 30, 2014 at 2:48 AM, gibies george <gibies at tropmet.res.in>
wrote:

>
>
> 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
>>
>>
>>
>> ncol = 12
>> nrows=133
>>
>> ;Reading in the data from 1871 to 2012
>>
>> 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
>
>>
>> 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/931a2d7d/attachment.html
```