1919from astropy .table import Row , Table
2020from astropy .time import Time
2121from astropy .utils .decorators import deprecated , deprecated_renamed_argument
22- from regions import CircleSkyRegion , PolygonSkyRegion
2322
2423from .. import log
2524from ..exceptions import InputWarning , InvalidQueryError , NoResultsWarning
2928from .catalog_collection import CatalogCollection
3029from .core import MastQueryWithLogin
3130
31+ try :
32+ from regions import CircleSkyRegion , PolygonSkyRegion
33+ HAS_REGIONS = True
34+ except ImportError :
35+ HAS_REGIONS = False
36+
3237__all__ = ["Catalogs" , "CatalogsClass" ]
3338
3439
@@ -232,7 +237,7 @@ def query_criteria(
232237 ):
233238 """
234239 Query a MAST catalog from a given collection using criteria filters. To return columns for a given
235- collection and catalog, use `~astroquery.mast.collections.get_catalog_metadata `.
240+ collection and catalog, use `~astroquery.mast.CatalogsClass.get_column_metadata `.
236241
237242 Parameters
238243 ----------
@@ -243,10 +248,10 @@ def query_criteria(
243248 coordinates : str or `~astropy.coordinates` object, optional
244249 The target around which to search. It may be specified as a string (e.g., '350 -80') or as an
245250 Astropy coordinates object.
246- region : str | iterable | `~astropy. regions.CircleSkyRegion` | `~astropy. regions.PolygonSkyRegion`, optional
251+ region : str | iterable | `~regions.CircleSkyRegion` | `~regions.PolygonSkyRegion`, optional
247252 The region to search within. It may be specified as a STC-S POLYGON or CIRCLE string
248253 (e.g., 'CIRCLE 350 -80 0.2'), an iterable of coordinate pairs, or as an
249- `~astropy. regions.CircleSkyRegion` or `~astropy. regions.PolygonSkyRegion`.
254+ `~regions.CircleSkyRegion` or `~regions.PolygonSkyRegion`.
250255 object_name : str, optional
251256 The name of the object to resolve and search around.
252257 radius : str or `~astropy.units.Quantity` object, optional
@@ -264,17 +269,17 @@ def query_criteria(
264269 sort_by : str or list of str, optional
265270 Column name(s) to sort the results by.
266271 sort_desc : bool or list of bool, optional
267- Indicates whether to sort in descending order for each column in `sort_by`. If a single bool,
268- applies to all columns. If a list, must match length of `sort_by`. Default is False (ascending order).
272+ Indicates whether to sort in descending order for each column in `` sort_by` `. If a single bool,
273+ applies to all columns. If a list, must match length of `` sort_by` `. Default is False (ascending order).
269274 filters : dict, optional
270275 Another parameter to specify criteria filters as a dictionary. Use this option when the name of a column
271276 conflicts with a named parameter of this method.
272277 version : str, optional
273- Deprecated. The version argument is no longer used. Please use `collection` and `catalog` instead.
278+ Deprecated. The version argument is no longer used. Please use `` collection`` and `` catalog` ` instead.
274279 pagesize : int, optional
275- Deprecated. The pagesize argument is no longer used. Please use `limit` instead.
280+ Deprecated. The pagesize argument is no longer used. Please use `` limit` ` instead.
276281 page : int, optional
277- Deprecated. The page argument is no longer used. Please use `offset` instead.
282+ Deprecated. The page argument is no longer used. Please use `` offset` ` instead.
278283 **criteria
279284 Keyword arguments representing criteria filters to apply.
280285
@@ -464,7 +469,7 @@ def query_region(
464469 ):
465470 """
466471 Query for MAST catalog entries within a specified region using criteria filters. To return columns for a given
467- collection and catalog, use `~astroquery.mast.collections.get_catalog_metadata `.
472+ collection and catalog, use `~astroquery.mast.CatalogsClass.get_column_metadata `.
468473
469474 Parameters
470475 ----------
@@ -473,10 +478,10 @@ def query_region(
473478 Astropy coordinates object.
474479 radius : str or `~astropy.units.Quantity` object, optional
475480 The search radius around the target coordinates or object. Default 0.2 degrees.
476- region : str | iterable | `~astropy. regions.CircleSkyRegion` | `~astropy. regions.PolygonSkyRegion`, optional
481+ region : str | iterable | `~regions.CircleSkyRegion` | `~regions.PolygonSkyRegion`, optional
477482 The region to search within. It may be specified as a STC-S POLYGON or CIRCLE string
478483 (e.g., 'CIRCLE 350 -80 0.2'), an iterable of coordinate pairs, or as an
479- `~astropy. regions.CircleSkyRegion` or `~astropy. regions.PolygonSkyRegion`.
484+ `~regions.CircleSkyRegion` or `~regions.PolygonSkyRegion`.
480485 collection : str, optional
481486 The collection to be queried. If None, uses the instance's `collection` attribute.
482487 catalog : str, optional
@@ -492,17 +497,17 @@ def query_region(
492497 sort_by : str or list of str, optional
493498 Column name(s) to sort the results by.
494499 sort_desc : bool or list of bool, optional
495- Indicates whether to sort in descending order for each column in `sort_by`. If a single bool,
496- applies to all columns. If a list, must match length of `sort_by`. Default is False (ascending order).
500+ Indicates whether to sort in descending order for each column in `` sort_by` `. If a single bool,
501+ applies to all columns. If a list, must match length of `` sort_by` `. Default is False (ascending order).
497502 filters : dict, optional
498503 Another parameter to specify criteria filters as a dictionary. Use this option when the name of a column
499504 conflicts with a named parameter of this method.
500505 version : str, optional
501- Deprecated. The version argument is no longer used. Please use `collection` and `catalog` instead.
506+ Deprecated. The version argument is no longer used. Please use `` collection`` and `` catalog` ` instead.
502507 pagesize : int, optional
503- Deprecated. The pagesize argument is no longer used. Please use `limit` instead.
508+ Deprecated. The pagesize argument is no longer used. Please use `` limit` ` instead.
504509 page : int, optional
505- Deprecated. The page argument is no longer used. Please use `offset` instead.
510+ Deprecated. The page argument is no longer used. Please use `` offset` ` instead.
506511 **criteria
507512 Keyword arguments representing criteria filters to apply.
508513
@@ -597,7 +602,7 @@ def query_object(
597602 ):
598603 """
599604 Query for MAST catalog entries around a specified object name using criteria filters. To return columns
600- for a given collection and catalog, use `~astroquery.mast.collections.get_catalog_metadata `.
605+ for a given collection and catalog, use `~astroquery.mast.CatalogsClass.get_column_metadata `.
601606
602607 Parameters
603608 ----------
@@ -622,17 +627,17 @@ def query_object(
622627 sort_by : str or list of str, optional
623628 Column name(s) to sort the results by.
624629 sort_desc : bool or list of bool, optional
625- Indicates whether to sort in descending order for each column in `sort_by`. If a single bool,
626- applies to all columns. If a list, must match length of `sort_by`. Default is False (ascending order).
630+ Indicates whether to sort in descending order for each column in `` sort_by` `. If a single bool,
631+ applies to all columns. If a list, must match length of `` sort_by` `. Default is False (ascending order).
627632 filters : dict, optional
628633 Another parameter to specify criteria filters as a dictionary. Use this option when the name of a column
629634 conflicts with a named parameter of this method.
630635 version : str, optional
631- Deprecated. The version argument is no longer used. Please use `collection` and `catalog` instead.
636+ Deprecated. The version argument is no longer used. Please use `` collection`` and `` catalog` ` instead.
632637 pagesize : int, optional
633- Deprecated. The pagesize argument is no longer used. Please use `limit` instead.
638+ Deprecated. The pagesize argument is no longer used. Please use `` limit` ` instead.
634639 page : int, optional
635- Deprecated. The page argument is no longer used. Please use `offset` instead.
640+ Deprecated. The page argument is no longer used. Please use `` offset` ` instead.
636641 **criteria
637642 Keyword arguments representing criteria filters to apply.
638643
@@ -1083,17 +1088,18 @@ def _create_adql_region(self, region):
10831088
10841089 # Case 2: region is an astropy region object
10851090 # TODO: When released, change these to use `CircleSphericalSkyRegion` and `PolygonSphericalSkyRegion`
1086- elif isinstance (region , CircleSkyRegion ):
1087- center = region .center .icrs
1088- radius = region .radius .to (u .deg ).value
1089- return f"CIRCLE('ICRS',{ center .ra .deg } ,{ center .dec .deg } ,{ radius } )"
1090- elif isinstance (region , PolygonSkyRegion ):
1091- verts = region .vertices .icrs
1092- point_string = "," .join (f"{ v .ra .deg } ,{ v .dec .deg } " for v in verts )
1093- return f"POLYGON('ICRS',{ point_string } )"
1091+ if HAS_REGIONS :
1092+ if isinstance (region , CircleSkyRegion ):
1093+ center = region .center .icrs
1094+ radius = region .radius .to (u .deg ).value
1095+ return f"CIRCLE('ICRS',{ center .ra .deg } ,{ center .dec .deg } ,{ radius } )"
1096+ elif isinstance (region , PolygonSkyRegion ):
1097+ verts = region .vertices .icrs
1098+ point_string = "," .join (f"{ v .ra .deg } ,{ v .dec .deg } " for v in verts )
1099+ return f"POLYGON('ICRS',{ point_string } )"
10941100
10951101 # Case 3: region is an iterable of coordinate pairs
1096- elif isinstance (region , Iterable ):
1102+ if isinstance (region , Iterable ):
10971103 # Expect something like [(ra1, dec1), (ra2, dec2), ...]
10981104 try :
10991105 points = [float (x ) for point in region for x in point ]
0 commit comments