TableElement#

class astropy.io.votable.tree.TableElement(votable, ID=None, name=None, ref=None, ucd=None, utype=None, nrows=None, id=None, config=None, pos=None, **extra)[source]#

Bases: Element, _IDProperty, _NameProperty, _UcdProperty, _DescriptionProperty

TABLE element: optionally contains data.

It contains the following publicly-accessible and mutable attribute:

array: A Numpy masked array of the data itself, where each row is a row of votable data, and columns are named and typed based on the <FIELD> elements of the table. The mask is parallel to the data array, except for variable-length fields. For those fields, the numpy array’s column type is “object” ("O"), and another masked array is stored there.

If the TableElement contains no data, (for example, its enclosing Resource has type == ‘meta’) array will have zero-length.

The keyword arguments correspond to setting members of the same name, documented below.

Attributes Summary

fields

A list of Field objects describing the types of each of the data columns.

format

The serialization format of the table [required].

groups

A list of Group objects describing how the columns and parameters are grouped.

infos

A list of Info objects for the table.

links

A list of Link objects (pointers to other documents or servers through a URI) for the table.

nrows

[immutable] The number of rows in the table, as specified in the XML file.

params

A list of parameters (constant-valued columns) for the table.

ref

Methods Summary

create_arrays([nrows, config])

Create a new array to hold the data based on the current set of fields, and store them in the array and member variable.

from_table(votable, table)

Create a TableElement instance from a given astropy.table.Table instance.

get_field_by_id(ref[, before])

Looks up a FIELD or PARAM element by the given ID.

get_field_by_id_or_name(ref[, before])

Looks up a FIELD or PARAM element by the given ID or name.

get_fields_by_utype(ref[, before])

Looks up a FIELD or PARAM element by the given utype and returns an iterator emitting all matches.

get_group_by_id(ref[, before])

Looks up a GROUP element by the given ID.

get_groups_by_utype(ref[, before])

Looks up a GROUP element by the given utype and returns an iterator emitting all matches.

is_empty()

Returns True if this table doesn't contain any real data because it was skipped over by the parser (through use of the table_number kwarg).

iter_fields_and_params()

Recursively iterate over all FIELD and PARAM elements in the TABLE.

iter_groups()

Recursively iterate over all GROUP elements in the TABLE.

iter_info()

parse(iterator, config)

For internal use.

to_table([use_names_over_ids])

Convert this VO Table to an astropy.table.Table instance.

to_xml(w, **kwargs)

For internal use.

Attributes Documentation

fields#

A list of Field objects describing the types of each of the data columns.

format#

The serialization format of the table [required].

Must be one of:

‘tabledata’ (TABLEDATA), ‘binary’ (BINARY), ‘binary2’ (BINARY2) ‘fits’ (FITS).

Note that the ‘fits’ format, since it requires an external file, can not be written out. Any file read in with ‘fits’ format will be read out, by default, in ‘tabledata’ format.

See Data Serialization Formats.

groups#

A list of Group objects describing how the columns and parameters are grouped. Currently this information is only kept around for round-tripping and informational purposes.

infos#

A list of Info objects for the table. Allows for post-operational diagnostics.

A list of Link objects (pointers to other documents or servers through a URI) for the table.

nrows#

[immutable] The number of rows in the table, as specified in the XML file.

params#

A list of parameters (constant-valued columns) for the table. Must contain only Param objects.

ref#

Methods Documentation

create_arrays(nrows=0, config=None)[source]#

Create a new array to hold the data based on the current set of fields, and store them in the array and member variable. Any data in the existing array will be lost.

nrows, if provided, is the number of rows to allocate.

classmethod from_table(votable, table)[source]#

Create a TableElement instance from a given astropy.table.Table instance.

get_field_by_id(ref, before=None)#

Looks up a FIELD or PARAM element by the given ID.

get_field_by_id_or_name(ref, before=None)#

Looks up a FIELD or PARAM element by the given ID or name.

get_fields_by_utype(ref, before=None)#

Looks up a FIELD or PARAM element by the given utype and returns an iterator emitting all matches.

get_group_by_id(ref, before=None)#

Looks up a GROUP element by the given ID. Used by the group’s “ref” attribute

get_groups_by_utype(ref, before=None)#

Looks up a GROUP element by the given utype and returns an iterator emitting all matches.

is_empty()[source]#

Returns True if this table doesn’t contain any real data because it was skipped over by the parser (through use of the table_number kwarg).

iter_fields_and_params()[source]#

Recursively iterate over all FIELD and PARAM elements in the TABLE.

iter_groups()[source]#

Recursively iterate over all GROUP elements in the TABLE.

iter_info()[source]#
parse(iterator, config)[source]#

For internal use. Parse the XML content of the children of the element.

Parameters:
iteratorxml iterable

An iterator over XML elements as returned by get_xml_iterator.

configdict

The configuration dictionary that affects how certain elements are read.

Returns:
selfElement

Returns self as a convenience.

to_table(use_names_over_ids=False)[source]#

Convert this VO Table to an astropy.table.Table instance.

Parameters:
use_names_over_idsbool, optional

When True use the name attributes of columns as the names of columns in the astropy.table.Table instance. Since names are not guaranteed to be unique, this may cause some columns to be renamed by appending numbers to the end. Otherwise (default), use the ID attributes as the column names.

.. warning::

Variable-length array fields may not be restored identically when round-tripping through the astropy.table.Table instance.

to_xml(w, **kwargs)[source]#

For internal use. Output the element to XML.

Parameters:
wastropy.utils.xml.writer.XMLWriter object

An XML writer to write to.

**kwargsdict

Any configuration parameters to control the output.