|
6 | 6 | This module contains various methods for querying MAST observations. |
7 | 7 | """ |
8 | 8 |
|
9 | | -from pathlib import Path |
10 | | -import warnings |
11 | | -import time |
12 | 9 | import os |
| 10 | +import time |
| 11 | +import warnings |
| 12 | +from pathlib import Path |
13 | 13 | from urllib.parse import quote |
14 | 14 |
|
15 | | -import numpy as np |
16 | | -import astropy.units as u |
17 | 15 | 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 |
20 | 19 | from astropy.utils.decorators import deprecated_renamed_argument |
| 20 | +from requests import HTTPError |
21 | 21 |
|
22 | 22 | from astroquery import log |
23 | 23 | from astroquery.mast.cloud import CloudAccess |
24 | 24 | from astroquery.utils import commons |
25 | 25 |
|
| 26 | +from ..exceptions import ( |
| 27 | + CloudAccessWarning, |
| 28 | + InputWarning, |
| 29 | + InvalidQueryError, |
| 30 | + NoResultsWarning, |
| 31 | + RemoteServiceError, |
| 32 | +) |
26 | 33 | from ..utils import async_to_sync |
27 | 34 | 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 |
31 | 36 | from .core import MastQueryWithLogin |
32 | 37 |
|
33 | 38 | try: |
34 | 39 | # Optional dependency import for cloud access functionality |
35 | | - from botocore.exceptions import ClientError, BotoCoreError |
| 40 | + from botocore.exceptions import BotoCoreError, ClientError |
36 | 41 | except ImportError: |
37 | 42 | pass |
38 | 43 |
|
@@ -332,13 +337,23 @@ def query_object_async(self, object_name, *, radius=0.2*u.deg, pagesize=None, pa |
332 | 337 | return self.query_region_async(coordinates, radius=radius, pagesize=pagesize, page=page) |
333 | 338 |
|
334 | 339 | @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): |
336 | 343 | """ |
337 | 344 | Given an set of criteria, returns a list of MAST observations. |
338 | 345 | Valid criteria are returned by ``get_metadata("observations")`` |
339 | 346 |
|
340 | 347 | Parameters |
341 | 348 | ---------- |
| 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. |
342 | 357 | pagesize : int, optional |
343 | 358 | Can be used to override the default pagesize. |
344 | 359 | E.g. when using a slow internet connection. |
@@ -366,8 +381,11 @@ def query_criteria_async(self, *, pagesize=None, page=None, resolver=None, **cri |
366 | 381 | ------- |
367 | 382 | response : list of `~requests.Response` |
368 | 383 | """ |
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) |
371 | 389 |
|
372 | 390 | if not mashup_filters: |
373 | 391 | 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 |
459 | 477 |
|
460 | 478 | return self.query_region_count(coordinates, radius=radius, pagesize=pagesize, page=page) |
461 | 479 |
|
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): |
463 | 483 | """ |
464 | 484 | Given an set of filters, returns the number of MAST observations meeting those criteria. |
465 | 485 |
|
466 | 486 | Parameters |
467 | 487 | ---------- |
| 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. |
468 | 496 | pagesize : int, optional |
469 | 497 | Can be used to override the default pagesize. |
470 | 498 | E.g. when using a slow internet connection. |
@@ -493,7 +521,11 @@ def query_criteria_count(self, *, pagesize=None, page=None, resolver=None, **cri |
493 | 521 | response : int |
494 | 522 | """ |
495 | 523 |
|
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) |
497 | 529 |
|
498 | 530 | # send query |
499 | 531 | if position: |
|
0 commit comments