Skip to content

Commit

Permalink
Deprecating image and spectrum as registry servicetype-s
Browse files Browse the repository at this point in the history
I'm also promising all-VO-searches in some other way in the docs.
  • Loading branch information
msdemlei committed Feb 23, 2024
1 parent 7c3059e commit 7cabd98
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
8 changes: 6 additions & 2 deletions docs/registry/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,13 @@ instance. The opening example could be written like this:

>>> from astropy.coordinates import SkyCoord
>>> my_obj = SkyCoord.from_name("Bellatrix")
>>> for res in registry.search(waveband="infrared", servicetype="spectrum"):
>>> for res in registry.search(waveband="infrared", servicetype="ssap"):
... print(res.service.search(pos=my_obj, size=0.001))
...

In reality, you will have to add some error handling to this kind of
all-VO queries: in a wide and distributed network, some service is
always down. See `Appendix: Robust All-VO Queries`_
always down. See `Appendix: Robust All-VO Queries`_.

The central point is: With a ``servicetype`` constraint,
each result has a well-defined ``service`` attribute that contains some
Expand Down Expand Up @@ -634,3 +634,7 @@ run all-VO queries without reading at least this sentence):
148.204840298431 29.1690999975089
243.044008 -51.778222
321.63278049999997 -54.579285999999996

Note that even this is not enough to reliably cover use cases like „give
me all images of M1 in the X-Ray in the VO“. In some future version,
pyVO will come with higher-level functionality for such tasks.
22 changes: 18 additions & 4 deletions pyvo/registry/rtcons.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
"""

import datetime
import warnings

from astropy import units as u
from astropy import constants
from astropy.coordinates import SkyCoord
from astropy.utils.exceptions import AstropyDeprecationWarning
import numpy

from ..dal import query as dalq
Expand Down Expand Up @@ -316,16 +318,15 @@ class Servicetype(Constraint):
The constraint normally is a custom keyword, one of:
* ``image`` (image services; at this point equivalent to sia, but
scheduled to include sia2, too)
* ``sia`` (SIAP version 1 services)
* ``sia2`` (SIAP version 2 services)
* ``spectrum``, ``ssa``, ``ssap`` (all synonymous for spectral
services, prefer ``spectrum``)
* ``ssa``, ``ssap`` (synonymous for SSAP services)
* ``scs``, ``conesearch`` (synonymous for cone search services, prefer
``scs``)
* ``line`` (for SLAP services)
* ``tap``, ``table`` (synonymous for TAP services, prefer ``tap``)
* ``image`` (a deprecated alias for sia)
* ``spectrum`` (a deprecated alias for ssap)
You can also pass in the standards' ivoid (which
generally looks like
Expand Down Expand Up @@ -361,6 +362,19 @@ def __init__(self, *stds):
self.extra_fragments = []

for std in stds:
if std == 'image':
warnings.warn(AstropyDeprecationWarning(
"The 'image' servicetype is deprecated. To"
" match SIAP 1 services, use 'sia'. Specific"
" functionality for global image seach will come in"
" a later pyVO version."))
if std == 'spectrum':
warnings.warn(AstropyDeprecationWarning(
"The 'spectral' servicetype is deprecated. To"
" match SSAP services, use 'ssap'. Specific"
" functionality for global spectral seach will come in"
" a later pyVO version."))

if std in SERVICE_TYPE_MAP:
self.stdids.add(SERVICE_TYPE_MAP[std])
elif "://" in std:
Expand Down
16 changes: 14 additions & 2 deletions pyvo/registry/tests/test_rtcons.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from astropy.time import Time
from astropy import units as u
from astropy.coordinates import SkyCoord
from astropy.utils.exceptions import AstropyDeprecationWarning

import numpy
import pytest

Expand Down Expand Up @@ -122,13 +124,13 @@ def test_fulluri(self):
== "standard_id IN ('http://extstandards/invention')")

def test_multi(self):
assert (rtcons.Servicetype("http://extstandards/invention", "image"
assert (rtcons.Servicetype("http://extstandards/invention", "sia"
).get_search_condition(FAKE_GAVO)
== "standard_id IN ('http://extstandards/invention',"
" 'ivo://ivoa.net/std/sia')")

def test_includeaux(self):
assert (rtcons.Servicetype("http://extstandards/invention", "image"
assert (rtcons.Servicetype("http://extstandards/invention", "sia"
).include_auxiliary_services().get_search_condition(FAKE_GAVO)
== "standard_id IN ('http://extstandards/invention',"
" 'http://extstandards/invention#aux',"
Expand Down Expand Up @@ -160,6 +162,16 @@ def test_sia2_aux(self):
" OR standard_id like 'ivo://ivoa.net/std/sia#query-2.%'"
" OR standard_id like 'ivo://ivoa.net/std/sia#query-aux-2.%'"))

def test_image_deprecated(self):
with pytest.warns(AstropyDeprecationWarning):
assert (rtcons.Servicetype("image").get_search_condition()
== "standard_id IN ('ivo://ivoa.net/std/sia')")

def test_spectrum_deprecated(self):
with pytest.warns(AstropyDeprecationWarning):
assert (rtcons.Servicetype("spectrum").get_search_condition()
== "standard_id IN ('ivo://ivoa.net/std/ssa')")


@pytest.mark.usefixtures('messenger_vocabulary')
class TestWavebandConstraint:
Expand Down

0 comments on commit 7cabd98

Please sign in to comment.