Skip to content

Commit

Permalink
Merge pull request #608 from msdemlei/open-more-regtap-api
Browse files Browse the repository at this point in the history
Adding RegistryResults and RegistryResource to the registry API
  • Loading branch information
bsipocz authored Oct 11, 2024
2 parents 130d08d + 4706df9 commit e701754
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
19 changes: 9 additions & 10 deletions docs/registry/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ you would say:
... registry.Freetext("AGB"))

After that, ``resources`` is an instance of
:py:class:`~pyvo.registry.regtap.RegistryResults`, which you can iterate over. In
:py:class:`~pyvo.registry.RegistryResults`, which you can iterate over. In
interactive data discovery, however, it is usually preferable to use the
``to_table`` method for an overview of the resources available:

Expand Down Expand Up @@ -165,13 +165,12 @@ And to look for tap resources *in* a specific cone, you would do
object ...
------------------------------- ...
ivo://cds.vizier/j/a+a/688/a104 ...
ivo://cds.vizier/j/aj/166/68 ...
ivo://cds.vizier/j/apj/938/73 ...

Astropy Quantities are also supported for the radius angle of a SkyCoord-defined circular region:

.. doctest-remote-data::

>>> from astropy.coordinates import SkyCoord
>>> from astropy import units as u
>>> registry.search(registry.Freetext("Wolf-Rayet"),
... registry.Spatial((SkyCoord("23d +3d"), 180*u.Unit('arcmin')), intersect="enclosed"))
Expand All @@ -181,7 +180,7 @@ Astropy Quantities are also supported for the radius angle of a SkyCoord-defined
object ...
------------------------------- ...
ivo://cds.vizier/j/a+a/688/a104 ...
ivo://cds.vizier/j/aj/166/68 ...
ivo://cds.vizier/j/apj/938/73 ...

Where ``intersect`` can take the following values:
* 'covers' is the default and returns resources that cover the geometry provided,
Expand All @@ -205,7 +204,7 @@ are not), but it is rather clunky, and in the real VO short name
collisions should be very rare.

Use the ``get_service`` method of
:py:class:`~pyvo.registry.regtap.RegistryResource` to obtain a DAL service
:py:class:`~pyvo.registry.RegistryResource` to obtain a DAL service
object for a particular sort of interface.
To query the fourth match using simple cone search, you would
thus say:
Expand All @@ -229,8 +228,8 @@ the first conesearch it finds.
However some providers provide multiple services of the same type
-- for example in VizieR you'll find one conesearch per table.
In this case, you can inspect the available `~pyvo.registry.regtap.Interface` to services with
`~pyvo.registry.regtap.RegistryResource.list_interfaces`. Then, you can refine your
instructions to `~pyvo.registry.regtap.RegistryResource.get_service` with a keyword
`~pyvo.registry.RegistryResource.list_interfaces`. Then, you can refine your
instructions to `~pyvo.registry.RegistryResource.get_service` with a keyword
constraint on the description ``get_service(service_type='conesearch', keyword='sncat')``.

.. doctest-remote-data::
Expand Down Expand Up @@ -363,7 +362,7 @@ to find what x-ray images that have of CasA. For the arguments you will
enter ``'image'`` for the service type and ``'x-ray'`` for the waveband.
The position is provided by the Astropy library.

The query returns a :py:class:`~pyvo.registry.regtap.RegistryResults` object
The query returns a :py:class:`~pyvo.registry.RegistryResults` object
which is a container holding a table of matching services. In this example
it returns 33 matching services.

Expand Down Expand Up @@ -432,12 +431,12 @@ Search results
==============

What is coming back from registry.search is
:py:class:`pyvo.registry.regtap.RegistryResults` which is rather
:py:class:`pyvo.registry.RegistryResults` which is rather
similar to :ref:`pyvo-resultsets`; just remember that for interactive
use there is the ``to_tables`` method discussed above.

The individual items are instances of
:py:class:`~pyvo.registry.regtap.RegistryResource`, which expose many
:py:class:`~pyvo.registry.RegistryResource`, which expose many
pieces of metadata (e.g., title, description, creators, etc) in
attributes named like their RegTAP counterparts (see the class
documentation). Some attributes deserve a second look.
Expand Down
8 changes: 6 additions & 2 deletions pyvo/registry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
The regtap module supports access to the IVOA Registries
"""

from .regtap import search, ivoid2service, get_RegTAP_query, choose_RegTAP_service
from .regtap import (search, ivoid2service,
get_RegTAP_query,
choose_RegTAP_service,
RegistryResults, RegistryResource)

from .rtcons import (Constraint, SubqueriedConstraint,
Freetext, Author, Servicetype, Waveband, Datamodel, Ivoid,
Expand All @@ -15,4 +18,5 @@
"Freetext", "Author",
"Servicetype", "Waveband", "Datamodel", "Ivoid", "UCD",
"Spatial", "Spectral", "Temporal",
"choose_RegTAP_service", "RegTAPFeatureMissing"]
"choose_RegTAP_service", "RegTAPFeatureMissing",
"RegistryResults", "RegistryResource",]
2 changes: 1 addition & 1 deletion pyvo/registry/regtap.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def search(*constraints: rtcons.Constraint,
Returns
-------
~pyvo.registry.regtap.RegistryResults`
~pyvo.registry.RegistryResults`
a container holding a table of matching resource (e.g. services)
"""
Expand Down

0 comments on commit e701754

Please sign in to comment.