Skip to content

Commit a06ebef

Browse files
committed
Deprecate objectname in Observations
1 parent c3e973f commit a06ebef

1 file changed

Lines changed: 48 additions & 16 deletions

File tree

astroquery/mast/observations.py

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,38 @@
66
This module contains various methods for querying MAST observations.
77
"""
88

9-
from pathlib import Path
10-
import warnings
11-
import time
129
import os
10+
import time
11+
import warnings
12+
from pathlib import Path
1313
from urllib.parse import quote
1414

15-
import numpy as np
16-
import astropy.units as u
1715
import astropy.coordinates as coord
18-
from requests import HTTPError
19-
from astropy.table import Table, Row, vstack
16+
import astropy.units as u
17+
import numpy as np
18+
from astropy.table import Row, Table, vstack
2019
from astropy.utils.decorators import deprecated_renamed_argument
20+
from requests import HTTPError
2121

2222
from astroquery import log
2323
from astroquery.mast.cloud import CloudAccess
2424
from astroquery.utils import commons
2525

26+
from ..exceptions import (
27+
CloudAccessWarning,
28+
InputWarning,
29+
InvalidQueryError,
30+
NoResultsWarning,
31+
RemoteServiceError,
32+
)
2633
from ..utils import async_to_sync
2734
from ..utils.class_or_instance import class_or_instance
28-
from ..exceptions import (InvalidQueryError, RemoteServiceError, NoResultsWarning, InputWarning, CloudAccessWarning)
29-
30-
from . import utils, conf
35+
from . import conf, utils
3136
from .core import MastQueryWithLogin
3237

3338
try:
3439
# Optional dependency import for cloud access functionality
35-
from botocore.exceptions import ClientError, BotoCoreError
40+
from botocore.exceptions import BotoCoreError, ClientError
3641
except ImportError:
3742
pass
3843

@@ -332,13 +337,23 @@ def query_object_async(self, object_name, *, radius=0.2*u.deg, pagesize=None, pa
332337
return self.query_region_async(coordinates, radius=radius, pagesize=pagesize, page=page)
333338

334339
@class_or_instance
335-
def query_criteria_async(self, *, pagesize=None, page=None, resolver=None, **criteria):
340+
@deprecated_renamed_argument('objectname', 'object_name', since='0.4.12')
341+
def query_criteria_async(self, *, coordinates=None, object_name=None, radius=0.2*u.deg,
342+
pagesize=None, page=None, resolver=None, **criteria):
336343
"""
337344
Given an set of criteria, returns a list of MAST observations.
338345
Valid criteria are returned by ``get_metadata("observations")``
339346
340347
Parameters
341348
----------
349+
coordinates : str or `~astropy.coordinates` object, optional
350+
The target around which to search. It may be specified as a string or as the
351+
appropriate `~astropy.coordinates` object.
352+
object_name : str, optional
353+
The name of the target around which to search.
354+
radius : str or `~astropy.units.Quantity` object, optional
355+
Default 0.2 degrees. The string must be parsable by `~astropy.coordinates.Angle`.
356+
The appropriate `~astropy.units.Quantity` object from `~astropy.units` may also be used.
342357
pagesize : int, optional
343358
Can be used to override the default pagesize.
344359
E.g. when using a slow internet connection.
@@ -366,8 +381,11 @@ def query_criteria_async(self, *, pagesize=None, page=None, resolver=None, **cri
366381
-------
367382
response : list of `~requests.Response`
368383
"""
369-
370-
position, mashup_filters = self._parse_caom_criteria(resolver=resolver, **criteria)
384+
position, mashup_filters = self._parse_caom_criteria(resolver=resolver,
385+
coordinates=coordinates,
386+
object_name=object_name,
387+
radius=radius,
388+
**criteria)
371389

372390
if not mashup_filters:
373391
raise InvalidQueryError("At least one non-positional criterion must be supplied.")
@@ -459,12 +477,22 @@ def query_object_count(self, object_name, *, radius=0.2*u.deg, pagesize=None, pa
459477

460478
return self.query_region_count(coordinates, radius=radius, pagesize=pagesize, page=page)
461479

462-
def query_criteria_count(self, *, pagesize=None, page=None, resolver=None, **criteria):
480+
@deprecated_renamed_argument('objectname', 'object_name', since='0.4.12')
481+
def query_criteria_count(self, *, coordinates=None, object_name=None, radius=0.2*u.deg, pagesize=None,
482+
page=None, resolver=None, **criteria):
463483
"""
464484
Given an set of filters, returns the number of MAST observations meeting those criteria.
465485
466486
Parameters
467487
----------
488+
coordinates : str or `~astropy.coordinates` object, optional
489+
The target around which to search. It may be specified as a string or as the appropriate
490+
`~astropy.coordinates` object.
491+
object_name : str, optional
492+
The name of the target around which to search.
493+
radius : str or `~astropy.units.Quantity` object, optional
494+
Default 0.2 degrees. The string must be parsable by `~astropy.coordinates.Angle`.
495+
The appropriate `~astropy.units.Quantity` object from `~astropy.units` may also be used.
468496
pagesize : int, optional
469497
Can be used to override the default pagesize.
470498
E.g. when using a slow internet connection.
@@ -493,7 +521,11 @@ def query_criteria_count(self, *, pagesize=None, page=None, resolver=None, **cri
493521
response : int
494522
"""
495523

496-
position, mashup_filters = self._parse_caom_criteria(resolver=resolver, **criteria)
524+
position, mashup_filters = self._parse_caom_criteria(resolver=resolver,
525+
coordinates=coordinates,
526+
object_name=object_name,
527+
radius=radius,
528+
**criteria)
497529

498530
# send query
499531
if position:

0 commit comments

Comments
 (0)