Re: Bug in where function?

From: Kyle Griffin <ksgriffin2_at_nyahnyahspammersnyahnyah>
Date: Mon Jan 20 2014 - 06:41:05 MST

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 06:41:38 2014

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