Ipac#
- class astropy.io.ascii.Ipac(definition='ignore', DBMS=False)[source]#
Bases:
Basic
IPAC format table.
See: https://irsa.ipac.caltech.edu/applications/DDGEN/Doc/ipac_tbl.html
Example:
\\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/data/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 occurring 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 specifydefinition='left'
ordefinition='right'
respectively when reading the table (the default isdefinition='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
IPAC tables can specify a null value in the header that is shown in place of missing or bad data. On writing, this value defaults to
null
. To specify a different null value, use thefill_values
option to replace masked values with a string or number of your choice as described in Parameters for write():>>> from astropy.io.ascii import masked >>> fill = [(masked, 'N/A', 'ra'), (masked, -999, 'sptype')] >>> ascii.write(data, format='ipac', fill_values=fill) \ This is an example of a valid comment ... | ra| dec| sai| v2| sptype| | double| double| long| double| char| | unit| unit| unit| unit| ergs| | N/A| null| null| null| -999| N/A 29.09056 null 2.06 -999 2345678901.0 3456789012.0 456789012 4567890123.0 567890123456789012
When writing a table with a column of integers, the data type is output as
int
when the columndtype.itemsize
is less than or equal to 2; otherwise the data type islong
. For a column of floating-point values, the data type isfloat
whendtype.itemsize
is less than or equal to 4; otherwise the data type isdouble
.- 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
- DBMSbool, optional
If true, this verifies that written tables adhere (semantically) to the IPAC/DBMS definition of IPAC tables. If ‘False’ it only checks for the (less strict) IPAC definition.
- definition
Methods Summary
write
(table)Write
table
as list of strings.Methods Documentation