Re: Strange behavior of logical variable to not operator

From: gibies george <gibies_at_nyahnyahspammersnyahnyah>
Date: Tue Mar 01 2011 - 22:31:16 MST

Thank you Dave for being with great patience through out the long discussion
(Both online and offline).

Thanking you very much for all your supports.

I am also thankful to Mary for the suggestions and support.

On 2 March 2011 06:40, David Brown <dbrown@ucar.edu> wrote:

> Hi Gibies,
>
> There is a problem here and thank you for pointing it out. However, it is
> not what it might seem at first glance. There is one issue, admittedly
> somewhat serious: the conversion of the default logical missing value to a
> string is not working correctly. When you call 'print' with your variable
> 'full' set to the default missing value, "Missing", as follows:
>
> print("full = " + full)
>
> the value of 'full' gets converted to a string -- incorrectly, it turns
> out. However, the variable 'full' still has the correct value and the .not.
> operator is working correctly. You can see this if you print the variable
> and the expression without converting them to a string. If the first part of
> your code is changed from:
>
> print("A1 : Defineing full = new(1,logical)")
> full = new(1,logical)
>
> print("full = "+full)
> print(".not.full = "+.not.full)
>
> to
>
> print("A1 : Defining full = new(1,logical)")
> full = new(1,logical)
>
> print(full)
> print(.not.full)
>
> Instead of your output below you get:
>
> (0) A1 : Defining full = new(1,logical)
>
>
> Variable: full
> Type: logical
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> Number Of Attributes: 1
> _FillValue : Missing
> (0) Missing
> (0) Missing
>
> which is correct based on the rule that any operation applied to a missing
> value yields a missing value.
>
> Setting the missing value to True, as you do in case B, inevitably leads to
> results that seem weird, even though all the results in your B scenario are
> correct by the rule above. Likewise with scenario C where the missing value
> is set to False. In most cases, although allowed, it is not advisable to
> change the missing value of logical variables from the default. Case D is
> the same as A and has the same error. Thanks much for pointing this out. I'm
> not sure how this has managed to slip by for such a long time. But it will
> have a high priority for getting fixed quickly.
> -dave
>
>
> On Mar 1, 2011, at 9:34 AM, gibies george wrote:
>
> Here I have analysed 12 different cases of logical variable find
> its behavior to not operator.
>
> My script is attached
>
> The output is as follows.
>
> Please note the potions with red font colour.
>
> I am using NCAR Command Language Version 5.1.1 on Fedora 11 operating
> system
>
> (0) A1 : Defineing full = new(1,logical)
> *(0)** **full = True*
> *(0)** **.not.full = True*
> (0) case A2 : full = True
> (0) full = True
> (0) .not.full = False
> (0) case A3 : full = False
> (0) full = False
> (0) .not.full = True
> (0) B1 : Defineing full = new(1,logical,True)
> *(0)** **full = True*
> *(0)** **.not.full = True*
> (0) case B2 : full = True
> *(0)** **full = True*
> *(0)** **.not.full = True*
> (0) case B3 : full = False
> (0) full = False
> (0) .not.full = True
> (0) C1 : Defineing full = new(1,logical,False)
> *(0)** **full = False*
> *(0)** **.not.full = False*
> (0) case C2 : full = True
> (0) full = True
> (0) .not.full = False
> (0) case C3 : full = False
> *(0)** **full = False*
> *(0)** **.not.full = False*
> (0) D1 : Defineing full = new(1,logical)
> *(0)** **full = True*
> *(0)** **.not.full = True*
> (0) case D2 : full = True
> (0) full = True
> (0) .not.full = False
> (0) case D3 : full = False
> (0) full = False
> (0) .not.full = True
>
>
> --
> *Gibies George, CSIR-RF,
> Climate and Global Modelling Division,
> Indian Institute of Tropical Meteorology,
> Dr. Homi Bhabha Road,
> NCL (P. O.), Pashan,
> Pune 411008, India.*
>
> *http://sites.google.com/site/gibiesge/*
>
> Please Think about the environment. Save paper; Save Trees; and don't print
> this e-mail unless it is necessary.
> <trial1.ncl>_______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>

-- 
*Gibies George,   CSIR-RF,
Climate and Global Modelling Division,
Indian Institute of Tropical Meteorology,
Dr. Homi Bhabha Road,
NCL (P. O.), Pashan,
Pune 411008, India.*
*http://sites.google.com/site/gibiesge/*
Please Think about the environment. Save paper; Save Trees; and don't print
this e-mail unless it is necessary.

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Mar 1 22:31:24 2011

This archive was generated by hypermail 2.1.8 : Wed Mar 02 2011 - 09:18:12 MST