Cds

class astropy.io.ascii.cds.Cds(readme=None) [edit on github][source]

Bases: astropy.io.ascii.core.BaseReader

Read a CDS format table. See http://vizier.u-strasbg.fr/doc/catstd.htx. Example:

Table: Table name here
= ==============================================================================
Catalog reference paper
    Bibliography info here
================================================================================
ADC_Keywords: Keyword ; Another keyword ; etc

Description:
    Catalog description here.
================================================================================
Byte-by-byte Description of file: datafile3.txt
--------------------------------------------------------------------------------
   Bytes Format Units  Label  Explanations
--------------------------------------------------------------------------------
   1-  3 I3     ---    Index  Running identification number
   5-  6 I2     h      RAh    Hour of Right Ascension (J2000)
   8-  9 I2     min    RAm    Minute of Right Ascension (J2000)
  11- 15 F5.2   s      RAs    Second of Right Ascension (J2000)
--------------------------------------------------------------------------------
Note (1): A CDS file can contain sections with various metadata.
          Notes can be multiple lines.
Note (2): Another note.
--------------------------------------------------------------------------------
  1 03 28 39.09
  2 04 18 24.11

About parsing the CDS format

The CDS format consists of a table description and the table data. These can be in separate files as a ReadMe file plus data file(s), or combined in a single file. Different subsections within the description are separated by lines of dashes or equal signs (“——” or “======”). The table which specifies the column information must be preceded by a line starting with “Byte-by-byte Description of file:”.

In the case where the table description is combined with the data values, the data must be in the last section and must be preceded by a section delimiter line (dashes or equal signs only).

Basic usage

Use the ascii.read() function as normal, with an optional readme parameter indicating the CDS ReadMe file. If not supplied it is assumed that the header information is at the top of the given table. Examples:

>>> from astropy.io import ascii
>>> table = ascii.read("t/cds.dat")
>>> table = ascii.read("t/vizier/table1.dat", readme="t/vizier/ReadMe")
>>> table = ascii.read("t/cds/multi/lhs2065.dat", readme="t/cds/multi/ReadMe")
>>> table = ascii.read("t/cds/glob/lmxbrefs.dat", readme="t/cds/glob/ReadMe")

Using a reader object

When Cds reader object is created with a readme parameter passed to it at initialization, then when the read method is executed with a table filename, the header information for the specified table is taken from the readme file. An InconsistentTableError is raised if the readme file does not have header information for the given table.

>>> readme = "t/vizier/ReadMe"
>>> r = ascii.get_reader(ascii.Cds, readme=readme)
>>> table = r.read("t/vizier/table1.dat")
>>> # table5.dat has the same ReadMe file
>>> table = r.read("t/vizier/table5.dat")

If no readme parameter is specified, then the header information is assumed to be at the top of the given table.

>>> r = ascii.get_reader(ascii.Cds)
>>> table = r.read("t/cds.dat")
>>> #The following gives InconsistentTableError, since no
>>> #readme file was given and table1.dat does not have a header.
>>> table = r.read("t/vizier/table1.dat")
Traceback (most recent call last):
  ...
InconsistentTableError: No CDS section delimiter found

Caveats:

  • Format, Units, and Explanations are available in the Reader.cols attribute.
  • All of the other metadata defined by this format is ignored.

Code contribution to enhance the parsing to include metadata in a Reader.meta attribute would be welcome.

Methods Summary

write([table]) Not available for the Cds class (raises NotImplementedError)

Methods Documentation

write(table=None) [edit on github][source]

Not available for the Cds class (raises NotImplementedError)

Page Contents