[AstroPy] Practical Python for Astronomers web tutorial

Dr. Juan E Cabanela Ph.D. cabanela at mnstate.edu
Thu May 26 10:25:28 EDT 2011


Tom,
   Thanks for the clarification as to the cause of the error.  Makes sense.  The reason I was attempting my own fill was precisely because the default filling of missing values seemed odd.  Specifically, while replacing 'null' with 'nan' makes sense to me, there were several cases where:

WARNING: null value for column ***** changed from null to -9223372036854775807

which seemed an odd choice to me.  It appears to be the smallest signed 64-bit integer, I would have preferred more control over it.  But your alternative solution works for me.

Juan

On May 26, 2011, at 8:58 AM, Tom Aldcroft wrote:
> Hi Juan,
> 
> In your example ATpy is looking at the table and inferring that it is
> an IPAC table.  So by default it uses the internal ATpy IPAC table
> reader. This does not have the fill_values keyword, but it
> automatically deals with the missing values in an acceptable way.  So
> either do:
> 
> data = atpy.Table('wise_matches.tbl')
>  # OR
> data = atpy.Table('wise_matches.tbl', type='ascii', fill_values=filler)
> 
> The latter specifically tells atpy to use the asciitable IPAC reader
> instead of the atpy IPAC reader.  This is one case that is a little
> confusing because there is overlapping functionality.  I would
> recommend using the ATpy internal reader in most cases since it
> automatically deals with common missing value cases.
> 
> - tom
> 
> On Thu, May 26, 2011 at 9:40 AM, Dr. Juan E Cabanela Ph.D.
> <cabanela at mnstate.edu> wrote:
>> On May 26, 2011, at 2:20 AM, Frederic Grollier wrote:
>>> On Wed, May 25, 2011 at 02:29:09PM -0500, Dr. Juan E Cabanela Ph.D. wrote:
>>>> 
>>>> t5 = atpy.Table(raw,type='ascii', fill_values=fill_values)
>>>> 
>>>> fails for me.  In fact, there appears to be no way to get atpy.Table to fill
>>>> values automatically as it triggers an error
>>>> 
>>>> TypeError: read() got an unexpected keyword argument 'fill_values'
>>>> 
>>>> I hope this can be fixed and if someone can tell me how to use fill_values
>>>> within ATpy that would be appreciated.
>>> 
>>> This code snippet works for me here, using ATpy.0.9.5.1 and
>>> asciitable.0.5.2. In the case of type='asciitable', the read() method
>>> delegates most of its work to asciitable, and so 'fill_values' should
>>> be a feature of this module. As far as I can tell, the 'fill_values'
>>> parameter was introduced in version 0.4.0 of asciitable, can you check
>>> your version info for this ?
>> 
>> I am running ATpy 0.9.5.1 and asciitable 0.5.2 as well, running on Python 2.7.1 -- EPD 7.0-2 (64-bit) on MacOS 10.6.7.
>> 
>> In my script test.py I do the following:
>> ===========================================================================
>> import numpy
>> import pylab
>> import atpy
>> 
>> filler = [('null',numpy.nan),('null',-999,'cntr_u','nb','na','ext_flg','w1nm','w1m','w2nm','w2m','w3nm','w3m','w4nm','w4m','tmass_key')]
>> data = atpy.Table('wise_matches.tbl',fill_values=filler)
>> ===========================================================================
>> 
>> and that last line triggers the following error (with traceback):
>> 
>> Traceback (most recent call last):
>>  File "test.py", line 14, in <module>
>>   data = atpy.Table('wise_matches.tbl',fill_values=filler)
>>  File "/Users/juan/Library/Python/2.7/lib/python/site-packages/ATpy-0.9.5.1-py2.7.egg/atpy/basetable.py", line 167, in __init__
>>   self.read(*args, **kwargs)
>>  File "/Users/juan/Library/Python/2.7/lib/python/site-packages/ATpy-0.9.5.1-py2.7.egg/atpy/basetable.py", line 213, in read
>>   atpy._readers[table_type](self, *args, **kwargs)
>> TypeError: read() got an unexpected keyword argument 'fill_values'
>> 
>> And so I have the same modules, but a different result.



-- 
Dr. Juan Cabanela                    218-477-2453 (V)  218-477-2290 (F)
Minnesota State University Moorhead     WWW: http://www.cabanela.com/     
Dept. of Physics and Astronomy      Twitter: Juan_Kinda_Guy 
1104 Seventh Ave South, Hagen 307B       IM: AstroJuanCab (AIM)   
Moorhead, MN 56563                           cabanela at mnstate.edu (MSN)
                                             juancab at gmail.com (GTalk)
   Public PGP Key available at: http://www.cabanela.com/juan_public.asc
  








More information about the AstroPy mailing list