SSAResults

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

Bases: pyvo.dal.adhoc.DatalinkResultsMixin, pyvo.dal.DALResults

The list of matching images resulting from a spectrum (SSA) query. Each record contains a set of metadata that describes an available spectrum matching the query constraints. The number of records in the results is by passing it to the Python built-in len() function.

This class supports iterable semantics; thus, individual records (in the form of SSARecord instances) are typically accessed by iterating over an SSAResults instance.

>>> results = pyvo.spectrumsearch(url, pos=[12.24, -13.1], diameter=0.2)
>>> for spec in results:
...     print("{0}: {1}".format(spec.title, spec.getdataurl()))

Alternatively, records can be accessed randomly via getrecord() or through a Python Database API (v2) Cursor (via cursor()). Column-based data access is possible via the getcolumn() method.

SSAResults is essentially a wrapper around an Astropy votable Table instance where the columns contain the various metadata describing the spectra. One can access that VOTable directly via the votable attribute. Thus, when one retrieves a whole column via getcolumn(), the result is a Numpy array. Alternatively, one can manipulate the results as an Astropy Table via the following conversion:

>>> table = results.votable.to_table()

SSAResults supports the array item operator [...] in a read-only context. When the argument is numerical, the result is an SSARecord instance, representing the record at the position given by the numerical index. If the argument is a string, it is interpreted as the name of a column, and the data from the column matching that name is returned as a Numpy array.

Methods Summary

getrecord(self, index) return a representation of a sia result record that follows dictionary semantics.

Methods Documentation

getrecord(self, index)[source]

return a representation of a sia result record that follows dictionary semantics. The keys of the dictionary are those returned by this instance’s fieldnames attribute. The returned record has additional image-specific properties

Parameters:
index : int

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

Returns:
SIARecord

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