VOTableFile¶
- class astropy.io.votable.tree.VOTableFile(ID=None, id=None, config=None, pos=None, version='1.4')[source]¶
Bases:
Element,_IDProperty,_DescriptionPropertyVOTABLE element: represents an entire file.
The keyword arguments correspond to setting members of the same name, documented below.
version is settable at construction time only, since conformance tests for building the rest of the structure depend on it.
Attributes Summary
A list of coordinate system descriptions for the file.
A list of groups, in the order they appear in the file.
A list of informational parameters (key-value pairs) for the entire file.
A list of parameters (constant-valued columns) that apply to the entire file.
A list of resources, in the order they appear in the file.
A list of time system descriptions for the file.
The version of the VOTable specification that the file uses.
Methods Summary
from_table(table[, table_id])Create a
VOTableFileinstance from a givenastropy.table.Tableinstance.get_coosys_by_id(ref[, before])Looks up a COOSYS element by the given ID.
get_field_by_id(ref[, before])get_field_by_id_or_name(ref[, before])get_fields_by_utype(ref[, before])Looks up a FIELD element by the given utype and returns an iterator emitting all matches.
Often, you know there is only one table in the file, and that's all you need.
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.
get_info_by_id(ref[, before])Looks up a INFO element by the given ID.
get_infos_by_name(ref[, before])Returns all INFO children with the given name.
get_table_by_id(ref[, before])Looks up a TABLE element by the given ID.
get_table_by_index(idx)Get a table by its ordinal position in the file.
get_tables_by_utype(ref[, before])Looks up a TABLE element by the given utype, and returns an iterator emitting all matches.
get_timesys_by_id(ref[, before])Looks up a TIMESYS element by the given ID.
get_values_by_id(ref[, before])Looks up a VALUES element by the given ID.
Recursively iterate over all COOSYS elements in the VOTABLE file.
Recursively iterate over all FIELD and PARAM elements in the VOTABLE file.
Recursively iterate over all GROUP elements in the VOTABLE file.
Recursively iterate over all INFO elements in the VOTABLE file.
Iterates over all tables in the VOTable file in a "flat" way, ignoring the nesting of resources etc.
Recursively iterate over all TIMESYS elements in the VOTABLE file.
Recursively iterate over all VALUES elements in the VOTABLE file.
parse(iterator, config)For internal use.
set_all_tables_format(format)Set the output storage format of all tables in the file.
to_xml(fd[, compressed, tabledata_format, ...])Write to an XML file.
Attributes Documentation
- coordinate_systems¶
A list of coordinate system descriptions for the file. Must contain only
CooSysobjects.
- groups¶
A list of groups, in the order they appear in the file. Only supported as a child of the VOTABLE element in VOTable 1.2 or later.
- infos¶
A list of informational parameters (key-value pairs) for the entire file. Must only contain
Infoobjects.
- params¶
A list of parameters (constant-valued columns) that apply to the entire file. Must contain only
Paramobjects.
- resources¶
A list of resources, in the order they appear in the file. Must only contain
Resourceobjects.
- version¶
The version of the VOTable specification that the file uses.
Methods Documentation
- classmethod from_table(table, table_id=None)[source]¶
Create a
VOTableFileinstance from a givenastropy.table.Tableinstance.- Parameters:
- table_id
str, optional Set the given ID attribute on the returned Table instance.
- table_id
- get_field_by_id(ref, before=None)¶
Looks up a FIELD element by the given ID. Used by the field’s “ref” attribute.
- get_fields_by_utype(ref, before=None)¶
Looks up a FIELD element by the given utype and returns an iterator emitting all matches.
- get_first_table()[source]¶
Often, you know there is only one table in the file, and that’s all you need. This method returns that first table.
- 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.
- get_info_by_id(ref, before=None)¶
Looks up a INFO element by the given ID.
- get_infos_by_name(ref, before=None)¶
Returns all INFO children with the given name.
- get_table_by_id(ref, before=None)¶
Looks up a TABLE element by the given ID. Used by the table “ref” attribute.
- get_tables_by_utype(ref, before=None)¶
Looks up a TABLE element by the given utype, and returns an iterator emitting all matches.
- get_values_by_id(ref, before=None)¶
Looks up a VALUES element by the given ID. Used by the values “ref” attribute.
- iter_fields_and_params()[source]¶
Recursively iterate over all FIELD and PARAM elements in the VOTABLE file.
- iter_tables()[source]¶
Iterates over all tables in the VOTable file in a “flat” way, ignoring the nesting of resources etc.
- parse(iterator, config)[source]¶
For internal use. Parse the XML content of the children of the element.
- Parameters:
- iterator
xmliterable An iterator over XML elements as returned by
get_xml_iterator.- config
dict The configuration dictionary that affects how certain elements are read.
- iterator
- Returns:
- self
Element Returns self as a convenience.
- self
- to_xml(fd, compressed=False, tabledata_format=None, _debug_python_based_parser=False, _astropy_version=None)[source]¶
Write to an XML file.
- Parameters:
- fd
stror file-like object Where to write the file. If a file-like object, must be writable.
- compressedbool, optional
When
True, write to a gzip-compressed file. (Default:False)- tabledata_format
str, optional Override the format of the table(s) data to write. Must be one of
tabledata(text representation),binaryorbinary2. By default, use the format that was specified in eachTableobject as it was created or read in. See Data Serialization Formats.
- fd