[AstroPy] Trying to read Tycho-2 catalog

Aldcroft, Thomas aldcroft at head.cfa.harvard.edu
Thu Sep 3 12:33:47 EDT 2015


Hi Ole,

I copied tyc2.dat.00 to tyc2.dat and had success with the recommended use
pattern of:

>>> t = ascii.read('tyc2.dat', readme='ReadMe')

This format is certainly tricky and there is room to improve the error
handling.  The issue with your first try was that the ReadMe has a list of
possible data files and tyc2.dat.00 was not there.

On Thu, Sep 3, 2015 at 11:08 AM, Ole Streicher <astropy at liska.ath.cx> wrote:

> from astropy.io import ascii
>
> Hi,
>
> I am trying to read the Tycho-2 data catalog from CDS [1] with
> astropy.io.ascii. First question is: The catalog is split into 20 data
> files tyc2.dat.00 ... tyc2.dat.19[.gz]; how can I read them in?
> ascii.read() wants to use a single file name only, not a list of file
> names.
>
> When I tried to read a single file according to the help:
>
> cat = ascii.read('tyc2.dat.00', readme='ReadMe')
>
> I get a TypeError: __init__() got an unexpected keyword argument
> 'readme'; did I misunderstand here something or is this a (known) bug
> (version 1.0.3)?
>

This weird error is a result of the guessing process where it ends up
trying formats that don't accept the readme arg.  If you know in advance
the format then you can specify the format along with guess=False in order
to get the actual exception:

>>> t = ascii.read('tyc2.dat.00', readme='ReadMe', format='cds',
guess=False)
...
InconsistentTableError: Can't find table tyc2.dat.00 in ReadMe


>
> I then tried
>
> reader = ascii.get_reader(ascii.Cds, readme='ReadMe')
> cat = reader.read('tyc2.dat.00')
>
> which leads to an InconsistentTableError: Can't find table tyc2.dat.00
> in ReadMe. Is there a way to specify the actual name of the catalog so
> that I don't have to rename the file?
>

The CDS format requires that the data files be named exactly as specified
in the ReadMe.  You could always change the ReadMe.


>
> Finally, if I rename the file to 'tyc2.dat' (or concatenate all data
> files into a file of this name):
>
> cat = reader.read('tyc2.dat')
>
> I get a ValueError: Column RAmdeg failed to convert. (The column seems
> to contain empty values: may this be the problem?)
>
> How should I proceed here pragmatically? Or did I something completely
> not understand?
>
> Best regards
>
> Ole
>
> [1] http://cdsarc.u-strasbg.fr/viz-bin/Cat?I/259
> _______________________________________________
> 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/20150903/8f3445c6/attachment.html>


More information about the AstroPy mailing list