Re: where function

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Sun Jan 06 2013 - 13:12:43 MST

Hi Ahmad,
You really should at least tell us what the error message says.
However, you are using attribute syntax for what look like coordinate arrays.
The simplest approach would be to use coordinate array syntax (untested)

tmp = alkali ; create a tmp variable with same coordinate arrays as alkali
tmp = 0 ; set all the values to 0
tmp({25:50},{-5:5}) = alkali({25:50},{-5:5})
akali = tmp
delete(tmp) ; get rid of the tmp variable

 -dave

alkali = where((alkali&conc.ge.25 .and. alkali&conc.le.50 .and. alkali&ionm.ge.-5 .and. alkali&lonm.le.5), alkali, 0)

On Jan 6, 2013, at 4:30 AM, Ahmad Farsyud wrote:

> Hallo NCL,
>
> I have a simple question related "where" logic in NCL.
>
> I have a data containing this information:
> variable : float alkali( conc, ionm)
> "conc" extends from 1.0 to 100.0
> "ionm" extends from -10 to +10
>
> i want to display only alkali values in specific range conc|25:50 and ionm|-5:5 while the rest values outside the range, I want to replace with zero "0".
>
> I did something like this:
>
> alkali = where((alkali@ conc.ge.25 .and. alkali@conc.le.50 .and. alkali@ ionm.ge.-5 .and. alkali@ionm.le.5), alkali, 0)
>
> but, i got error message!
>
> Thanks for your help.
>
> Ahmad
>
>
>
> On Sun, Jan 6, 2013 at 8:02 PM, Ahmad Farsyud <a.farsyud@gmail.com> wrote:
> Hallo NCL,
>
> I have a simple question related "where" logic in NCL.
>
> I have a data containing this information:
> variable : float alkali( conc, ionm)
> "conc" extends from 1.0 to 100.0
> "ionm" extends from -10 to +10
>
> i want to display only alkali values in specific range conc|25:50 and ionm|-5:5 while the rest values outside the range, I want to replace with zero "0".
>
> I did something like this:
>
> alkali = where((alkali@ conc.ge.0.1 .and. alkali@conc.le.0.4 .and. alkali@ ionm.ge.-1 .and. alkali@ionm.le.-10), alkali, 0)
>
> but, i got error message!
>
> Thanks for your help.
>
> Ahmad
>
> _______________________________________________
> 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 Sun Jan 6 13:12:57 2013

This archive was generated by hypermail 2.1.8 : Mon Jan 07 2013 - 08:57:08 MST