From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>

Date: Tue Oct 18 2011 - 22:51:07 MDT

Date: Tue Oct 18 2011 - 22:51:07 MDT

You can see the 'pattern_cor' => "pattern_cor2"

The latter does the actual computations.

%> less $NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl

On 10/18/11 10:06 PM, Ivanna Mo wrote:

*> Hi,
*

*> I use the built-in function pattern_cor to calculate the pattern
*

*> correlation coefficient of my result. I find that the r is strange and
*

*> different from the result I compute myself. Here is the script that I use:
*

*>
*

*> r_x = pattern_cor(X,O,1.0,1) ; r_x = 0.9998
*

*> r_y = pattern_cor(Y,O,1.0,1) ; r_y= 0.99996
*

*>
*

*>
*

*> Avg_X = avg(X)
*

*> Avg_Y = avg(Y)
*

*> Avg_O = avg(O)
*

*>
*

*> Sum_X = 0.0
*

*> Sum_y = 0.0
*

*> Sum_dev_X = 0.0
*

*> Sum_dev_Y = 0.0
*

*> Sum_dev_O = 0.0
*

*>
*

*> do i=0, 67
*

*> do j=0, 67
*

*>
*

*> Sum_x = Sum_x + (X(i,j) - Avg_X)*(O(i,j) - Avg_O)
*

*> Sum_y = Sum_y + (Y(i,j) - Avg_Y)*(O(i,j) - Avg_O)
*

*> Sum_dev_X = Sum_dev_X + (X(i,j) - Avg_X)*(X(i,j) - Avg_X)
*

*> Sum_dev_Y = Sum_dev_Y +(Y(i,j) - Avg_Y)*(Y(i,j) - Avg_Y)
*

*> Sum_dev_O = Sum_dev_O +(O(i,j) - Avg_O)*(O(i,j) - Avg_O)
*

*>
*

*> end do
*

*> end do
*

*>
*

*> R_x = Sum_x/(sqrt(Sum_dev_X)*sqrt(Sum_dev_O)) ; R_x = 0.70
*

*>
*

*> R_y = Sum_y/(sqrt(Sum_dev_Y)*sqrt(Sum_dev_O)) ; R_y = 0.98
*

*>
*

*>
*

*>
*

*>
*

*>
*

*>
*

*> _______________________________________________
*

*> ncl-talk mailing list
*

*> List instructions, subscriber options, unsubscribe:
*

*> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
*

_______________________________________________

ncl-talk mailing list

List instructions, subscriber options, unsubscribe:

http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Tue Oct 18 22:51:12 2011

*
This archive was generated by hypermail 2.1.8
: Wed Oct 19 2011 - 13:36:10 MDT
*