astropy:docs

Ipac

class astropy.io.ascii.Ipac(definition='ignore', DBMS=False)[source] [edit on github]

Bases: astropy.io.ascii.FixedWidth

Read or write an IPAC format table. See http://irsa.ipac.caltech.edu/applications/DDGEN/Doc/ipac_tbl.html:

\name=value
\ Comment
|  column1 |   column2 | column3 | column4  |    column5    |
|  double  |   double  |   int   |   double |     char      |
|  unit    |   unit    |   unit  |    unit  |     unit      |
|  null    |   null    |   null  |    null  |     null      |
 2.0978     29.09056    73765     2.06000    B8IVpMnHg

Or:

|-----ra---|----dec---|---sao---|------v---|----sptype--------|
  2.09708   29.09056     73765   2.06000    B8IVpMnHg

The comments and keywords defined in the header are available via the output table meta attribute:

>>> import os
>>> from astropy.io import ascii
>>> filename = os.path.join(ascii.__path__[0], 'tests/t/ipac.dat')
>>> data = ascii.read(filename)
>>> print(data.meta['comments'])
['This is an example of a valid comment']
>>> for name, keyword in data.meta['keywords'].items():
...     print(name, keyword['value'])
...
intval 1
floatval 2300.0
date Wed Sp 20 09:48:36 1995
key_continue IPAC keywords can continue across lines

Note that there are different conventions for characters occuring below the position of the | symbol in IPAC tables. By default, any character below a | will be ignored (since this is the current standard), but if you need to read files that assume characters below the | symbols belong to the column before or after the |, you can specify definition='left' or definition='right' respectively when reading the table (the default is definition='ignore'). The following examples demonstrate the different conventions:

  • definition='ignore':

    |   ra  |  dec  |
    | float | float |
      1.2345  6.7890
    
  • definition='left':

    |   ra  |  dec  |
    | float | float |
       1.2345  6.7890
    
  • definition='right':

    |   ra  |  dec  |
    | float | float |
    1.2345  6.7890
    
Parameters:

definition : str, optional

Specify the convention for characters in the data table that occur directly below the pipe (|) symbol in the header column definition:

  • ‘ignore’ - Any character beneath a pipe symbol is ignored (default)
  • ‘right’ - Character is associated with the column to the right
  • ‘left’ - Character is associated with the column to the left

DBMS : bool, optional

If true, this varifies that written tables adhere (semantically) to the IPAC/DBMS definiton of IPAC tables. If ‘False’ it only checks for the (less strict) IPAC definition.

Methods Summary

write(table) Write table as list of strings.

Methods Documentation

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

Write table as list of strings.

Parameters:table – input table data (astropy.table.Table object)
Returns:list of strings corresponding to ASCII table

Page Contents