represent_mixins_as_columns

astropy.table.represent_mixins_as_columns(tbl, exclude_classes=())[源代码]

表示输入表 tbl 仅使用 ColumnMaskedColumn 物体。

此函数表示任何mixin列,如 Time 在里面 tbl 一个或多个平原 ~astropy.table.Column 对象并返回一个新表。单个mixin列可以根据需要拆分为多个列组件,以完全表示该列。这包括递归拆分的可能性,如下例所示。新列名的格式如下 <column_name>.<component> ,例如 sc.ra 对于一个 SkyCoord 列名为 sc .

除了拆分列,此函数还更新表 meta 包含名为 __serialized_columns__ 它提供了从拆分列构造原始mixin列所需的附加信息。

在将表写入ECSV、FITS、HDF5格式时,astropy I/O使用此函数。

请注意,如果表不包含任何mixin列,则返回原始表时不更新 meta .

参数
tblTable 或子类表或子类

将mixin表示为列的表

exclude_classes类的元组

排除作为元组中任何类的实例的任何mixin列

返回
tblTable

具有更新列的新表,或原始输入 tbl

实例

>>> from astropy.table import Table, represent_mixins_as_columns
>>> from astropy.time import Time
>>> from astropy.coordinates import SkyCoord
>>> x = [100.0, 200.0]
>>> obstime = Time([1999.0, 2000.0], format='jyear')
>>> sc = SkyCoord([1, 2], [3, 4], unit='deg', obstime=obstime)
>>> tbl = Table([sc, x], names=['sc', 'x'])
>>> represent_mixins_as_columns(tbl)
<Table length=2>
 sc.ra   sc.dec sc.obstime.jd1 sc.obstime.jd2    x
  deg     deg
float64 float64    float64        float64     float64
------- ------- -------------- -------------- -------
    1.0     3.0      2451180.0          -0.25   100.0
    2.0     4.0      2451545.0            0.0   200.0