Re: Bug in where function?

From: Robert Schuster <rxschuster_at_nyahnyahspammersnyahnyah>
Date: Mon Jan 20 2014 - 07:06:10 MST

Thank you! Working with missing values is a good idea!
It is good to know, that the expressions for both cases are evaluated for all values in the arrays and not only for those where the condition is true.

Robert

Am 20.01.2014 um 14:41 schrieb Kyle Griffin <ksgriffin2@wisc.edu>:

> Unfortunately, Robert, that is exactly how the where function is defined to work. I suggest turning the zeros into missing values (at least temporarily) for the calculation and then subbing the values from the original function back in with another where statement, but others may have better suggestions to work around this issue.
>
>
> Kyle
>
> ----------------------------------------
> Kyle S. Griffin
> Department of Atmospheric and Oceanic Sciences
> University of Wisconsin - Madison
> Room 1421
> 1225 W Dayton St, Madison, WI 53706
> Email: ksgriffin2@wisc.edu
>
>
> On Mon, Jan 20, 2014 at 3:05 AM, Robert Schuster <rxschuster@gmail.com> wrote:
> Hello,
>
> I have two arrays that I want to divide by each other, one of them contains zeros:
>
> a = (/0,1/)
> b = (/1,1/)
>
> I tried to use the where function to avoid a divide by zero error:
>
> c = where(a .gt. 0, b/a, 0)
>
> But interestingly the divide operation is performed on the whole arrays and not only where the condition a .gt. 0 is true:
>
> fatal:divide: Division by 0, Can't continue
> fatal:Div: operator failed, can't continue
>
> Is that the way the where function is supposed to work?
>
> Robert
> _______________________________________________
> 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 Mon Jan 20 07:06:26 2014

This archive was generated by hypermail 2.1.8 : Tue Jan 21 2014 - 15:57:30 MST