Skip to content

Commit 16d204d

Browse files
committed
change class name
1 parent 1d1b379 commit 16d204d

File tree

7 files changed

+50
-55
lines changed

7 files changed

+50
-55
lines changed

astroquery/cds/__init__.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@
2222
import warnings
2323

2424
warnings.warn("The ``cds`` module has been moved to astroquery.mocserver,"
25-
"and ``CdsClass`` has been renamed ``MOCserver``. It means that"
26-
" 'from astroquery.cds import cds' became 'from astroquery.mocserver"
27-
" import mocserver'. Please update your imports.", DeprecationWarning, stacklevel=2)
25+
"and ``CdsClass`` has been renamed ``MOCServerClass``. "
26+
"Please update your imports.", DeprecationWarning, stacklevel=2)
2827

29-
from astroquery.mocserver import mocserver, MOCserver
28+
from astroquery.mocserver import MOCServer as cds
29+
from astroquery.mocserver import MOCServerClass as CdsClass
3030

31-
cds = mocserver
32-
CdsClass = MOCserver
33-
34-
__all__ = ['mocserver', 'MOCserver', 'cds', 'CdsClass']
31+
__all__ = ['conf', 'Conf', 'cds', 'CdsClass']

astroquery/mocserver/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ class Conf(_config.ConfigNamespace):
4343

4444
conf = Conf()
4545

46-
from .core import mocserver, MOCserver
46+
from .core import MOCServer, MOCServerClass
4747

48-
__all__ = ["Conf", "conf", "mocserver", "MOCserver"]
48+
__all__ = ["Conf", "conf", "MOCServer", "MOCServerClass"]

astroquery/mocserver/core.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
try:
1818
from mocpy import MOC
1919
except ImportError:
20-
print("Could not import mocpy, which is a requirement for the CDS service."
20+
print("Could not import mocpy, which is a requirement for the MOC server service."
2121
"Please refer to https://cds-astro.github.io/mocpy/install.html for how to install it.")
2222

2323
try:
@@ -26,11 +26,11 @@
2626
print("Could not import astropy-regions, which is a requirement for the CDS service."
2727
"Please refer to http://astropy-regions.readthedocs.io/en/latest/installation.html for how to install it.")
2828

29-
__all__ = ['mocserver', 'MOCserver']
29+
__all__ = ['MOCServerClass', 'MOCServer']
3030

3131

3232
@async_to_sync
33-
class MOCserver(BaseQuery):
33+
class MOCServerClass(BaseQuery):
3434
"""
3535
Query the `CDS MOCServer <http://alasky.unistra.fr/MocServer/query>`_
3636
@@ -40,10 +40,10 @@ class MOCserver(BaseQuery):
4040
4141
This package implements two methods:
4242
43-
* :meth:`~astroquery.mocserver.MOCserver.query_region` retrieving data-sets (their associated MOCs and meta-datas)
44-
having sources in a given region.
45-
* :meth:`~astroquery.mocserver.MOCserver.find_datasets` retrieving data-sets (their associated MOCs and meta-datas)
46-
based on the values of their meta-datas.
43+
* :meth:`~astroquery.mocserver.MOCServerClass.query_region` retrieving data-sets
44+
(their associated MOCs and meta-datas) having sources in a given region.
45+
* :meth:`~astroquery.mocserver.MOCServerClass.find_datasets` retrieving data-sets
46+
(their associated MOCs and meta-datas) based on the values of their meta-datas.
4747
4848
"""
4949
URL = conf.server
@@ -83,7 +83,7 @@ def query_region(self, *, region=None, get_query_payload=False, verbose=False, *
8383
return_moc : bool, optional
8484
Specifies if we want a `mocpy.MOC` object in return. This MOC corresponds to the union
8585
of the MOCs of all the matching data-sets. By default it is set to False and
86-
:meth:`~astroquery.mocserver.MOCserver.query_region` returns an `astropy.table.Table` object.
86+
:meth:`~astroquery.mocserver.MOCServerClass.query_region` returns an `astropy.table.Table` object.
8787
max_norder : int, optional
8888
Has sense only if ``return_moc`` is set to True. Specifies the maximum precision order of the returned MOC.
8989
fields : [str], optional
@@ -160,7 +160,7 @@ def find_datasets(self, meta_data, *, get_query_payload=False, verbose=False, **
160160
return_moc : bool, optional
161161
Specifies if we want a `mocpy.MOC` object in return. This MOC corresponds to the union of the MOCs of all
162162
the matching data-sets. By default it is set to False and
163-
:meth:`~astroquery.mocserver.MOCserver.query_region` returns an `astropy.table.Table` object.
163+
:meth:`~astroquery.mocserver.MOCServerClass.query_region` returns an `astropy.table.Table` object.
164164
max_norder : int, optional
165165
Has sense only if ``return_moc`` is set to True. Specifies the maximum precision order of the returned MOC.
166166
get_query_payload : bool, optional
@@ -183,7 +183,7 @@ def find_datasets(self, meta_data, *, get_query_payload=False, verbose=False, **
183183

184184
def query_region_async(self, *, get_query_payload=False, **kwargs):
185185
"""
186-
Serves the same purpose as :meth:`~astroquery.mocserver.MOCserver.query_region`
186+
Serves the same purpose as :meth:`~astroquery.mocserver.MOCServerClass.query_region`
187187
but only returns the HTTP response rather than the parsed result.
188188
189189
Parameters
@@ -229,12 +229,12 @@ def _args_to_payload(self, **kwargs):
229229
----------
230230
kwargs
231231
Arbitrary keyword arguments. The same as those defined in the docstring of
232-
:meth:`~astroquery.mocserver.MOCserver.query_object`.
232+
:meth:`~astroquery.mocserver.MOCServerClass.query_object`.
233233
234234
Returns
235235
-------
236236
request_payload : dict
237-
The payload submitted to the MOCServer.
237+
The payload submitted to the MOC server.
238238
"""
239239
request_payload = dict()
240240
intersect = kwargs.get('intersect', 'overlaps')
@@ -413,4 +413,4 @@ def _cast_to_float(value):
413413
return value
414414

415415

416-
mocserver = MOCserver()
416+
MOCServer = MOCServerClass()

astroquery/mocserver/tests/test_deprecation.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ def test_raises_deprecation_warning():
55
with pytest.raises(
66
DeprecationWarning,
77
match="The ``cds`` module has been moved to astroquery.mocserver,"
8-
"and ``CdsClass`` has been renamed ``MOCserver``. It means that"
9-
" 'from astroquery.cds import cds' became 'from astroquery.mocserver"
10-
" import mocserver'. Please update your imports.",
11-
):
8+
"and ``CdsClass`` has been renamed ``MOCServerClass``. "
9+
"Please update your imports."):
1210
from astroquery.cds import cds # noqa: F401

astroquery/mocserver/tests/test_mocserver.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from astropy import coordinates
99
from astropy.table import Table
1010

11-
from ..core import mocserver
11+
from ..core import MOCServer
1212
from astroquery.utils.mocks import MockResponse
1313

1414

@@ -94,7 +94,7 @@ def test_request_results(patch_get, datafile):
9494
9595
with the one obtained on the http://alasky.unistra.fr/MocServer/query
9696
"""
97-
results = mocserver.query_region(
97+
results = MOCServer.query_region(
9898
get_query_payload=False, verbose=True, data=datafile
9999
)
100100
assert type(results) == Table
@@ -117,7 +117,7 @@ def test_cone_search_spatial_request(RA, DEC, RADIUS):
117117
radius = coordinates.Angle(RADIUS, unit="deg")
118118
cone_region = CircleSkyRegion(center=center, radius=radius)
119119

120-
request_payload = mocserver.query_region(
120+
request_payload = MOCServer.query_region(
121121
region=cone_region, get_query_payload=True, intersect="overlaps"
122122
)
123123

@@ -138,7 +138,7 @@ def test_cone_search_spatial_request(RA, DEC, RADIUS):
138138
def test_polygon_spatial_request(poly, poly_payload):
139139
polygon_region = PolygonSkyRegion(vertices=poly)
140140

141-
request_payload = mocserver.query_region(
141+
request_payload = MOCServer.query_region(
142142
region=polygon_region, intersect="overlaps", get_query_payload=True
143143
)
144144

@@ -151,7 +151,7 @@ def test_intersect_param(intersect):
151151
radius = coordinates.Angle(1.5, unit="deg")
152152

153153
cone_region = CircleSkyRegion(center, radius)
154-
request_payload = mocserver.query_region(
154+
request_payload = MOCServer.query_region(
155155
region=cone_region, intersect=intersect, get_query_payload=True
156156
)
157157
if intersect == "encloses":

astroquery/mocserver/tests/test_mocserver_remote.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
except ImportError:
2121
HAS_REGIONS = False
2222

23-
from ..core import mocserver
23+
from ..core import MOCServer
2424

2525

2626
@pytest.mark.remote_data
@@ -38,7 +38,7 @@ def test_max_rec_param(self, max_rec):
3838
radius = coordinates.Angle(1.5, unit="deg")
3939

4040
cone_region = CircleSkyRegion(center, radius)
41-
result = mocserver.query_region(
41+
result = MOCServer.query_region(
4242
region=cone_region, max_rec=max_rec, get_query_payload=False
4343
)
4444

@@ -61,7 +61,7 @@ def test_field_l_param(self, field_l):
6161

6262
cone_region = CircleSkyRegion(center, radius)
6363

64-
table = mocserver.query_region(
64+
table = MOCServer.query_region(
6565
region=cone_region, fields=field_l, get_query_payload=False
6666
)
6767
assert isinstance(table, Table)
@@ -75,11 +75,11 @@ def test_field_l_param(self, field_l):
7575
@pytest.mark.parametrize("moc_order", [5, 10])
7676
def test_moc_order_param(self, moc_order, tmp_cwd):
7777
# We need a long timeout for this
78-
mocserver.TIMEOUT = 300
78+
MOCServer.TIMEOUT = 300
7979

8080
moc_region = MOC.from_json({"0": [1]})
8181

82-
result = mocserver.query_region(
82+
result = MOCServer.query_region(
8383
region=moc_region,
8484
# return a mocpy obj
8585
return_moc=True,
@@ -94,7 +94,7 @@ def test_moc_order_param(self, moc_order, tmp_cwd):
9494
["ID=*HST*", "moc_sky_fraction>0.5", "(ID=*DSS*)&&(moc_sky_fraction>0.1)"],
9595
)
9696
def test_find_data_sets(self, meta_data_expr):
97-
result = mocserver.find_datasets(
97+
result = MOCServer.find_datasets(
9898
meta_data=meta_data_expr,
9999
fields=["ID", "moc_sky_fraction"],
100100
get_query_payload=False,

docs/mocserver/mocserver.rst

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ meta-data equals to ``"image"``).
4141

4242
This package implements two methods:
4343

44-
* :meth:`~astroquery.mocserver.MOCserver.query_region` retrieving data-sets (their associated MOCs and meta-datas) having sources in a given region.
45-
* :meth:`~astroquery.mocserver.MOCserver.find_datasets` retrieving data-sets (their associated MOCs and meta-datas) based on the
44+
* :meth:`~astroquery.mocserver.MOCServerClass.query_region` retrieving data-sets (their associated MOCs and meta-datas) having sources in a given region.
45+
* :meth:`~astroquery.mocserver.MOCServerClass.find_datasets` retrieving data-sets (their associated MOCs and meta-datas) based on the
4646
values of their meta-datas.
4747

4848
Requirements
@@ -65,9 +65,9 @@ The first thing to do is to import the `regions`_ package and the ``mocserver``
6565
6666
>>> from astropy import coordinates
6767
>>> from regions import CircleSkyRegion
68-
>>> from astroquery.mocserver import mocserver
68+
>>> from astroquery.mocserver import MOCServer
6969
70-
``mocserver`` implements the method :meth:`~astroquery.mocserver.MOCserver.query_region` and this is what we will use.
70+
``mocserver`` implements the method :meth:`~astroquery.mocserver.MOCServerClass.query_region` and this is what we will use.
7171
First, we need to define a cone region. For that purpose we will instantiate a `regions.CircleSkyRegion` object:
7272

7373
.. code-block:: python
@@ -77,11 +77,11 @@ First, we need to define a cone region. For that purpose we will instantiate a `
7777
7878
>>> cone = CircleSkyRegion(center, radius)
7979
80-
And basically call the :meth:`~astroquery.mocserver.MOCserver.query_region` method with the cone and that's all.
80+
And basically call the :meth:`~astroquery.mocserver.MOCServerClass.query_region` method with the cone and that's all.
8181

8282
.. code-block:: python
8383
84-
>>> mocserver.query_region(region=cone)
84+
>>> MOCServer.query_region(region=cone)
8585
<Table masked=True length=1317>
8686
hips_service_url_8 hips_status hips_status_7 ... hipsgen_date_5 hips_master_url moc_sky_fraction
8787
object object object ... object object float64
@@ -150,7 +150,7 @@ You can also query the MOCServer on a `regions.PolygonSkyRegion` or even an `moc
150150
by replacing ``cone`` with a polygon or a MOC object.
151151

152152

153-
By default, :meth:`~astroquery.mocserver.MOCserver.query_region` returns an `astropy.table.Table` object storing the data-sets
153+
By default, :meth:`~astroquery.mocserver.MOCServerClass.query_region` returns an `astropy.table.Table` object storing the data-sets
154154
as rows and their meta-datas as columns. Data-sets might have no information for a specific meta-data. If so, the value
155155
associated with this meta-data for this data-set is set to "-". The above astropy table looks like :
156156

@@ -162,13 +162,13 @@ This table refers to a lot of meta-datas whereas we could only use a few of them
162162
MOCServer to give us a reduced set of meta-datas for the resulting data-sets. The table returned by the MOCServer
163163
will be lighter and thus faster to retrieve.
164164

165-
The parameter ``fields`` of :meth:`~astroquery.mocserver.MOCserver.query_region` allows us to provide the list of meta-datas we
165+
The parameter ``fields`` of :meth:`~astroquery.mocserver.MOCServerClass.query_region` allows us to provide the list of meta-datas we
166166
want to get. Let's say we would like only the ``ID``, the ``moc_sky_fraction`` and the ``moc_access_url`` of the
167167
resulting data-sets:
168168

169169
.. code-block:: python
170170
171-
>>> mocserver.query_region(region=cone, fields=['ID', 'moc_sky_fraction', 'moc_access_url'])
171+
>>> MOCServer.query_region(region=cone, fields=['ID', 'moc_sky_fraction', 'moc_access_url'])
172172
<Table masked=True length=1317>
173173
moc_access_url ID moc_sky_fraction
174174
object str48 float64
@@ -239,13 +239,13 @@ Retrieving data-sets based on their meta-data values
239239
----------------------------------------------------
240240

241241
As expressed in the last paragraph of the Getting Started section, we can ask the MOCServer to do some filtering tasks for us
242-
at the server side. The ``meta_data`` parameter of :meth:`~astroquery.mocserver.MOCserver.query_region` allows the user to
242+
at the server side. The ``meta_data`` parameter of :meth:`~astroquery.mocserver.MOCServerClass.query_region` allows the user to
243243
write an algebraic expression on the meta-datas. Let's query the MOCServer for retrieving what we have done using the
244244
web interface in the Getting Started section i.e. retrieving only the image data-sets that lie in the previously defined cone.
245245

246246
.. code-block:: python
247247
248-
>>> mocserver.query_region(region=cone,
248+
>>> MOCServer.query_region(region=cone,
249249
... fields=['ID', 'dataproduct_type', 'moc_sky_fraction', 'moc_access_url'],
250250
... meta_data="dataproduct_type=image")
251251
<Table masked=True length=279>
@@ -318,13 +318,13 @@ numpy operations on `astropy.table.Table` objects but here the MOCServer made it
318318

319319
`This page <http://alasky.unistra.fr/MocServer/example>`_ on the web interface of the MOCServer gives examples of some filtering expressions.
320320

321-
Alternatively, the method :meth:`~astroquery.mocserver.MOCserver.find_datasets` searches data-sets on the whole sky. If you want
321+
Alternatively, the method :meth:`~astroquery.mocserver.MOCServerClass.find_datasets` searches data-sets on the whole sky. If you want
322322
to get the MOCs or meta-datas from some specific data-sets this is the method to use. The next example retrieves all the
323323
``moc_access_url`` of the Hubble surveys:
324324

325325
.. code-block:: python
326326
327-
>>> mocserver.find_datasets(meta_data="ID=*HST*",
327+
>>> MOCServer.find_datasets(meta_data="ID=*HST*",
328328
... fields=['ID', 'moc_access_url'])
329329
<Table masked=True length=42>
330330
moc_access_url ID
@@ -383,7 +383,7 @@ Another parameter called ``max_rec`` specifies an upper limit for the number of
383383

384384
.. code-block:: python
385385
386-
>>> mocserver.query_region(region=cone, max_rec=3)
386+
>>> MOCServer.query_region(region=cone, max_rec=3)
387387
<Table masked=True length=3>
388388
publisher_id obs_description_url moc_access_url ... TIMESTAMP obs_label moc_sky_fraction
389389
str9 str52 str84 ... float64 str8 float64
@@ -410,7 +410,7 @@ As an example, we would like to obtain the union of the spatial coverage of all
410410
>>> from mocpy import MOC
411411
>>> # We want to retrieve all the HST surveys i.e. the HST surveys covering any region of the sky.
412412
>>> allsky = CircleSkyRegion(coordinates.SkyCoord(0, 0, unit="deg"), coordinates.Angle(180, unit="deg"))
413-
>>> moc = mocserver.query_region(region=allsky,
413+
>>> moc = MOCServer.query_region(region=allsky,
414414
... # We want a mocpy object instead of an astropy table
415415
... return_moc=True,
416416
... # The order of the MOC
@@ -424,14 +424,14 @@ As an example, we would like to obtain the union of the spatial coverage of all
424424
Retrieve the `~mocpy.MOC` of a specific data-set
425425
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
426426

427-
Finally, if you want to retrieve the MOC of a specific data-set, please consider using the `~astroquery.mocserver.MOCserver.find_datasets`
427+
Finally, if you want to retrieve the MOC of a specific data-set, please consider using the `~astroquery.mocserver.MOCServerClass.find_datasets`
428428
method with the ID of the data-set you want to retrieve the MOC along with the ``return_moc`` parameter set to True.
429429
The last example will show you how to get the MOC (i.e. a `mocpy.MOC` object) of the ``GALEXGR6/AIS/FUV`` survey.
430430

431431
.. code-block:: python
432432
433433
>>> from mocpy import MOC
434-
>>> moc_galex=mocserver.find_datasets(meta_data="ID=CDS/P/GALEXGR6/AIS/FUV", return_moc=True)
434+
>>> moc_galex= MOCServer.find_datasets(meta_data="ID=CDS/P/GALEXGR6/AIS/FUV", return_moc=True)
435435
>>> moc_galex.plot("MOC associated to CDS/P/GALEXGR6/AIS/FUV.")
436436
437437
.. image:: ./MOC_GALEXGR6_AIS_FUV.png

0 commit comments

Comments
 (0)