From e4e8c9f810d0ffe85be331cb2c83762253605d8c Mon Sep 17 00:00:00 2001 From: Markus Demleitner Date: Fri, 9 Jun 2023 18:16:38 +0200 Subject: [PATCH] Deprecating image and spectrum as registry servicetype-s I'm also promising all-VO-searches in some other way in the docs. --- docs/registry/index.rst | 8 ++++++-- pyvo/registry/rtcons.py | 22 ++++++++++++++++++---- pyvo/registry/tests/test_rtcons.py | 16 ++++++++++++++-- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/docs/registry/index.rst b/docs/registry/index.rst index c97a0b7b4..418dd1418 100644 --- a/docs/registry/index.rst +++ b/docs/registry/index.rst @@ -300,13 +300,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 @@ -641,3 +641,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. diff --git a/pyvo/registry/rtcons.py b/pyvo/registry/rtcons.py index ed0ad32a2..5ffffe419 100644 --- a/pyvo/registry/rtcons.py +++ b/pyvo/registry/rtcons.py @@ -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 @@ -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 @@ -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: diff --git a/pyvo/registry/tests/test_rtcons.py b/pyvo/registry/tests/test_rtcons.py index eddf923a7..384fc4b21 100644 --- a/pyvo/registry/tests/test_rtcons.py +++ b/pyvo/registry/tests/test_rtcons.py @@ -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 @@ -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'," @@ -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: