[AstroPy] Selecting data from ascii.table with multiple conditions

Aldcroft, Thomas aldcroft at head.cfa.harvard.edu
Fri Oct 25 09:08:39 EDT 2013


On Fri, Oct 25, 2013 at 5:27 AM, Joe Philip Ninan <indiajoe at gmail.com>wrote:

> Hi Yannick, Tom and Jeonghyun,
> Thanks for the examples. They all worked.
> I loaded the data with ascii.read() tool.
> What confused me was Mytable['ID']>60  returned an object which contains a
> boolean data array and another mask array.
> Which is why i thought, i had to add .data before taking logical &, to
> make sure data array is used.
>
> Am I correct in assuming that this object which returned will basically
> work like a standard numpy masked array? It will all make sense that way.
>

Yes, that's correct.  The fact that you get a masked boolean array in this
case is a feature because it means if any elements in your MyTable['ID'])
are masked then the corresponding comparison truth values will be masked.
 I.e. if the input is not known then the comparison is likewise not known.

- Tom


> Thanks,
> -cheers
> joe
>
>
>
> On 25 October 2013 11:25, Yannick Roehlly <yannick.roehlly at oamp.fr> wrote:
>
>> Le Fri, 25 Oct 2013 02:24:38 +0530,
>> Joe Philip Ninan <indiajoe at gmail.com> a écrit :
>>
>> > Mytable[np.where((Mytable['ID']>60).data &
>> > (Mytable['MAG']>18).data)]['MAG'].data.data
>> >
>> > Quite a lot of ".data" to be appended !!
>> > Am i missing some feature astropy already has for doing these kind of
>> > data selection from table?
>>
>> Hi Joe,
>>
>> How do you read your table ?
>>
>> Mytable[(Mytable['ID']>60) & (Mytable['MAG']>18)] should do what you
>> want.
>>
>> Cheers,
>>
>> Yannick
>>
>> --
>> You will never amount to much.
>>                 -- Munich Schoolmaster, to Albert Einstein, age 10
>> _______________________________________________
>> AstroPy mailing list
>> AstroPy at scipy.org
>> http://mail.scipy.org/mailman/listinfo/astropy
>>
>
>
>
> --
> /---------------------------------------------------------------
> "GNU/Linux: because a PC is a terrible thing to waste" -  GNU Generation
>
> ************************************************
> Joe Philip Ninan    http://sites.google.com/site/jpninan/
> Research Scholar        /________________\
> DAA,                            | Vadakeparambil |
> TIFR,                           | Pullad P.O.         |
> Mumbai-05, India.      | Kerala, India      |
> Ph: +917738438212   | PIN:689548       |
> ------------------------------\_______________/--------------
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20131025/ecadd13d/attachment.html>


More information about the AstroPy mailing list