[AstroPy] Trying to read Tycho-2 catalog
Leonard Burtscher
burtscher at mpe.mpg.de
Thu Sep 3 11:38:43 EDT 2015
Hi Ole,
I would recommend using the astropy.Table class which makes it very easy to deal with tables. To read your table you can simply do
from astropy.table import Table
tyc = Table.read("tyc2.dat.00",format="ascii")
I am not sure what the size restriction or performance of this is, but parsing 500 MB of text through Python will certainly take a while.
If you're only interested in a subset of the catalog, I would recommend cutting out the required columns using bash tools. E.g. if you only need columns 1 and 2, you could do
cat tyc2.dat.00 | awk -F "|" '{print $1 "|" $2}' > tyc2_12.dat.00
Best,
Leonard
> Am 03.09.2015 um 17:08 schrieb Ole Streicher <astropy at liska.ath.cx>:
>
> 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)?
>
> 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?
>
> 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
More information about the AstroPy
mailing list