Re: Selective summation problem

From: Rick Brownrigg <brownrig_at_nyahnyahspammersnyahnyah>
Date: Fri Oct 02 2009 - 14:20:31 MDT

Hi Bridget,

I believe a statement such as:

        Tsum(e) = Tsum(e) + temps(t,i,j)

is not "working" because Tsum(e) on the right-hand side of the
expression contains missing values, which in turn resulted from the
third parameter of the creation of Tsum:

         Tsum = new(16,float,0.)

Note that the optional third param to new() is not an initializer as
much as it is a specifier for what constitutes missing_values.

One way to get what you're after might be to initialize your summation
arrays as:

        Tsum=new(16,float)
        Tsum=0.

Hope this helps....

Rick

On Oct 2, 2009, at 12:24 PM, Bridget Thrasher wrote:

> I've got a nested loop that is selecting which points to add to a
> summation. However, it is not actually doing to addition, and I
> can't figure out what I'm doing wrong. Any help would be appreciated!
>
> Here is my loop, followed by the beginning of the output:
> do t=0,1800-1
> print("Averaging month "+t)
> Tcnt = new(16,integer,0)
> Tsum = new(16,float,0.)
> Pcnt = new(16,integer,0)
> Psum = new(16,float,0.)
> do e=0,15
> Tcnt(e) = num(eco(:,:).eq.(e+1))
> Pcnt(e) = num(eco(:,:).eq.(e+1))
> end do
> print("Tcnt="+Tcnt)
> print("Pcnt="+Pcnt)
> do i=0,222-1
> do j=0,462-1
> if ((.not.ismissing(eco(i,j))).and.(eco(i,j).gt.0)) then
> e = eco(i,j) - 1
> print("e="+e+" t="+temps(t,i,j)+" pr="+precip(t,i,j))
> Tsum(e) = Tsum(e) + temps(t,i,j)
> Psum(e) = Psum(e) + precip(t,i,j)
> print("Tsum(e)="+Tsum(e))
> print("Psum(e)="+Psum(e))
> end if
> end do
> end do
> ;print("Tsum="+Tsum)
> ;print("Psum="+Psum)
> ts(t,:) = Tsum/Tcnt
> pr(t,:) = Psum/Pcnt
> end do
>
>
> Copyright (C) 1995-2009 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 5.1.1
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> (0) Averaging month 0
> (0) Tcnt=1023
> (1) Tcnt=760
> (2) Tcnt=1564
> (3) Tcnt=4155
> (4) Tcnt=2927
> (5) Tcnt=1811
> (6) Tcnt=1194
> (7) Tcnt=1898
> (8) Tcnt=324
> (9) Tcnt=753
> (10) Tcnt=166
> (11) Tcnt=408
> (12) Tcnt=1250
> (13) Tcnt=1428
> (14) Tcnt=828
> (15) Tcnt=1148
> (0) Pcnt=1023
> (1) Pcnt=760
> (2) Pcnt=1564
> (3) Pcnt=4155
> (4) Pcnt=2927
> (5) Pcnt=1811
> (6) Pcnt=1194
> (7) Pcnt=1898
> (8) Pcnt=324
> (9) Pcnt=753
> (10) Pcnt=166
> (11) Pcnt=408
> (12) Pcnt=1250
> (13) Pcnt=1428
> (14) Pcnt=828
> (15) Pcnt=1148
> (0) e=15 t=12.09 pr=0.0921936
> (0) Tsum(e)=0
> (0) Psum(e)=0
> (0) e=15 t=11.89 pr=0.0980645
> (0) Tsum(e)=0
> (0) Psum(e)=0
> (0) e=15 t=12 pr=0.102774
> (0) Tsum(e)=0
> (0) Psum(e)=0
> (0) e=15 t=10.42 pr=0.0926452
> (0) Tsum(e)=0
> (0) Psum(e)=0
> .
> .
> .
>
>
> Thanks!
> Bridget
>
> --
> Bridget Thrasher, PhD
> Postdoctoral Researcher
> Climate Central
> www.climatecentral.org
>
>
> _______________________________________________
> 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 Fri, 2 Oct 2009 14:20:31 -0600

This archive was generated by hypermail 2.1.8 : Thu Oct 22 2009 - 12:22:52 MDT