DALResults

class pyvo.dal.DALResults(votable, url=None, session=None)[source]

Bases: object

Results from a DAL query. It provides random access to records in the response. Alternatively, it can provide results via a Cursor (compliant with the Python Database API) or an iterable.

initialize the cursor. This constructor is not typically called by directly applications; rather an instance is obtained from calling a DALQuery’s execute().

Parameters:
votable : str

the service response parsed into an astropy.io.votable.tree.VOTableFile instance.

url : str

the URL that produced the response

session : object

optional session to use for network requests

Raises:
DALFormatError

if the response VOTable does not contain a response table

See also

DALFormatError

Attributes Summary

fielddescs return the full metadata the columns as a list of Field instances, a simple object with attributes corresponding the the VOTable FIELD attributes, namely: name, id, type, ucd, utype, arraysize, description
fieldnames return the names of the columns.
queryurl the URL query that produced these results.
resultstable The votable XML element astropy.io.votable.tree.Table
status The query status as a 2-element tuple e.g.
table
votable The complete votable XML Document astropy.io.votable.tree.VOTableFile

Methods Summary

broadcast_samp(self[, client_name]) Broadcast the table to client_name via SAMP
cursor(self) return a cursor that is compliant with the Python Database API’s Cursor interface.
fieldname_with_ucd(self, ucd) return the field name that has a given UCD value or None if the UCD is not found.
fieldname_with_utype(self, utype) return the field name that has a given UType value or None if the UType is not found.
from_result_url(result_url[, session]) Create a result object from a url.
getcolumn(self, name) return a numpy array containing the values for the column with the given name
getdesc(self, name) return the field description for the record attribute (column) with the given name
getrecord(self, index) return a representation of a result record that follows dictionary semantics.
getvalue(self, name, index) return the value of a record attribute–a value from a column and row.
to_table(self) Returns a astropy Table object.

Attributes Documentation

fielddescs

return the full metadata the columns as a list of Field instances, a simple object with attributes corresponding the the VOTable FIELD attributes, namely: name, id, type, ucd, utype, arraysize, description

fieldnames

return the names of the columns. These are the names that are used to access values from the dictionaries returned by getrecord(). They correspond to the column name.

queryurl

the URL query that produced these results. None is returned if unknown

resultstable

The votable XML element astropy.io.votable.tree.Table

status

The query status as a 2-element tuple e.g. (‘OK’, ‘Everythings fine’)

table
votable

The complete votable XML Document astropy.io.votable.tree.VOTableFile

Methods Documentation

broadcast_samp(self, client_name=None)[source]

Broadcast the table to client_name via SAMP

cursor(self)[source]

return a cursor that is compliant with the Python Database API’s Cursor interface. See PEP 249 for details.

fieldname_with_ucd(self, ucd)[source]

return the field name that has a given UCD value or None if the UCD is not found.

fieldname_with_utype(self, utype)[source]

return the field name that has a given UType value or None if the UType is not found.

classmethod from_result_url(result_url, session=None)[source]

Create a result object from a url.

Uses the optional session to make the request.

getcolumn(self, name)[source]

return a numpy array containing the values for the column with the given name

getdesc(self, name)[source]

return the field description for the record attribute (column) with the given name

Parameters:
name : str

the name of the attribute (column)

Returns:
object

with attributes (name, id, datatype, unit, ucd, utype, arraysize) which describe the column

getrecord(self, index)[source]

return a representation of a result record that follows dictionary semantics. The keys of the dictionary are those returned by this instance’s fieldnames attribute.The returned record may have additional accessor methods for getting at stardard DAL response metadata (e.g. ra, dec).

Parameters:
index : int

the integer index of the desired record where 0 returns the first record

Returns:
Record

a dictionary-like wrapper containing the result record metadata.

Raises:
IndexError

if index is negative or equal or larger than the number of rows in the result table.

See also

Record
getvalue(self, name, index)[source]

return the value of a record attribute–a value from a column and row.

Parameters:
name : str

the name of the attribute (column)

index : int

the zero-based index of the record

Raises:
IndexError

if index is negative or equal or larger than the number of rows in the result table.

KeyError

if name is not a recognized column name

to_table(self)[source]

Returns a astropy Table object.

Returns:
astropy.table.Table