Field#

class astropy.io.votable.tree.Field(votable, ID=None, name=None, datatype=None, arraysize=None, ucd=None, unit=None, width=None, precision=None, utype=None, ref=None, type=None, id=None, xtype=None, config=None, pos=None, **extra)[source]#

Bases: SimpleElement, _IDProperty, _NameProperty, _XtypeProperty, _UtypeProperty, _UcdProperty

FIELD element: describes the datatype of a particular column of data.

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

If ID is provided, it is used for the column name in the resulting recarray of the table. If no ID is provided, name is used instead. If neither is provided, an exception will be raised.

Attributes Summary

arraysize

Specifies the size of the multidimensional array if this FIELD contains more than a single value.

datatype

The datatype of the column [required].

links

A list of Link instances used to reference more details about the meaning of the FIELD.

precision

Along with width, defines the numerical accuracy associated with the data.

ref

On FIELD elements, ref is used only for informational purposes, for example to refer to a COOSYS or TIMESYS element.

type

The type attribute on FIELD elements is reserved for future extensions.

unit

A string specifying the units for the FIELD.

values

A Values instance (or None) defining the domain of the column.

width

Along with precision, defines the numerical accuracy associated with the data.

Methods Summary

from_table_column(votable, column)

Restores a Field instance from a given astropy.table.Column instance.

parse(iterator, config)

For internal use.

to_table_column(column)

Sets the attributes of a given astropy.table.Column instance to match the information in this Field.

to_xml(w, **kwargs)

For internal use.

uniqify_names(fields)

Make sure that all names and titles in a list of fields are unique, by appending numbers if necessary.

Attributes Documentation

arraysize#

Specifies the size of the multidimensional array if this FIELD contains more than a single value.

See multidimensional arrays.

datatype#

The datatype of the column [required].

Valid values (as defined by the spec) are:

‘boolean’, ‘bit’, ‘unsignedByte’, ‘short’, ‘int’, ‘long’, ‘char’, ‘unicodeChar’, ‘float’, ‘double’, ‘floatComplex’, or ‘doubleComplex’

Many VOTABLE files in the wild use ‘string’ instead of ‘char’, so that is also a valid option, though ‘string’ will always be converted to ‘char’ when writing the file back out.

A list of Link instances used to reference more details about the meaning of the FIELD. This is purely informational and is not used by the astropy.io.votable package.

precision#

Along with width, defines the numerical accuracy associated with the data. These values are used to limit the precision when writing floating point values back to the XML file. Otherwise, it is purely informational – the Numpy recarray containing the data itself does not use this information.

ref#

On FIELD elements, ref is used only for informational purposes, for example to refer to a COOSYS or TIMESYS element.

type#

The type attribute on FIELD elements is reserved for future extensions.

unit#

A string specifying the units for the FIELD.

values#

A Values instance (or None) defining the domain of the column.

width#

Along with precision, defines the numerical accuracy associated with the data. These values are used to limit the precision when writing floating point values back to the XML file. Otherwise, it is purely informational – the Numpy recarray containing the data itself does not use this information.

Methods Documentation

classmethod from_table_column(votable, column)[source]#

Restores a Field instance from a given astropy.table.Column instance.

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_column(column)[source]#

Sets the attributes of a given astropy.table.Column instance to match the information in this Field.

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.

classmethod uniqify_names(fields)[source]#

Make sure that all names and titles in a list of fields are unique, by appending numbers if necessary.