Ipac公司¶
- class astropy.io.ascii.Ipac(definition='ignore', DBMS=False)[源代码]¶
基类:
Basic
IPAC格式表。
参见:https://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
或:
|-----ra---|----dec---|---sao---|------v---|----sptype--------| 2.09708 29.09056 73765 2.06000 B8IVpMnHg
标题中定义的注释和关键字可通过输出表获得
meta
属性:>>> 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
注意,对于出现在
|
IPAC表格中的符号。默认情况下,在|
将被忽略(因为这是当前的标准),但是如果您需要读取的文件中|
符号属于|
,您可以指定definition='left'
或definition='right'
分别在读取表时(默认为definition='ignore'
). 以下示例演示了不同的约定: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表可以在标题中指定空值,以代替丢失或错误的数据。写入时,此值缺省为
null
。若要指定不同的空值,请使用fill_values
选项将屏蔽值替换为您选择的字符串或数字,如中所述 astropy:io_ascii_write_parameters **>>> 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
在编写包含整数列的表时,数据类型输出为
int
当该列dtype.itemsize
小于或等于2;否则数据类型为long
。对于浮点值列,数据类型为float
什么时候dtype.itemsize
小于或等于4;否则数据类型为double
。- 参数
方法总结
write
\(表)写
table
作为字符串列表。方法文件