Skip to content

Commit 87096d2

Browse files
committed
Improve importing in astroquery.esasky
`astropy.units` is now imported as `u` like recommended by `astropy`. Furthermore, a line tried to use `astropy.io.fits...` despite the module using `from astropy.io import fits`.
1 parent 31528de commit 87096d2

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

astroquery/esasky/core.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
from zipfile import ZipFile
1111
from pathlib import Path
1212

13+
from astropy import units as u
1314
from astropy.coordinates import Angle
1415
from astropy.io import fits
1516
from astropy.utils.console import ProgressBar
1617
from astroquery import log
17-
import astropy.units
1818
from requests import HTTPError
1919
from requests import ConnectionError
2020

@@ -51,7 +51,7 @@ class ESASkyClass(BaseQuery):
5151
__ACCESS_URL_STRING = "access_url"
5252
__USE_INTERSECT_STRING = "useIntersectPolygonInsteadOfContainsPoint"
5353
__ZERO_ARCMIN_STRING = "0 arcmin"
54-
__MIN_RADIUS_CATALOG_DEG = Angle(5*astropy.units.arcsec).to_value(astropy.units.deg)
54+
__MIN_RADIUS_CATALOG_DEG = Angle(5 * u.arcsec).to_value(u.deg)
5555

5656
__HERSCHEL_STRING = 'herschel'
5757
__HST_STRING = 'hst'
@@ -114,7 +114,7 @@ def query(self, query, *, output_file=None, output_format="votable", verbose=Fal
114114
if not verbose:
115115
with warnings.catch_warnings():
116116
commons.suppress_vo_warnings()
117-
warnings.filterwarnings("ignore", category=astropy.units.core.UnitsWarning)
117+
warnings.filterwarnings("ignore", category=u.UnitsWarning)
118118
job = self._tap.launch_job(query=query, output_file=output_file, output_format=output_format,
119119
verbose=False, dump_to_file=output_file is not None)
120120
else:
@@ -1347,8 +1347,7 @@ def get_spectra_from_table(self, query_table_list, missions=__ALL_STRING,
13471347
return spectra
13481348

13491349
def _sanitize_input_radius(self, radius):
1350-
if (isinstance(radius, str) or isinstance(radius,
1351-
astropy.units.Quantity)):
1350+
if isinstance(radius, (str, u.Quantity)):
13521351
return radius
13531352
else:
13541353
raise ValueError("Radius must be either a string or "
@@ -1554,7 +1553,7 @@ def _open_fits(self, path, verbose=False):
15541553
if verbose:
15551554
return fits.open(path)
15561555
with warnings.catch_warnings():
1557-
warnings.filterwarnings("ignore", category=astropy.io.fits.verify.VerifyWarning)
1556+
warnings.filterwarnings("ignore", category=fits.verify.VerifyWarning)
15581557
return fits.open(path)
15591558

15601559
def _ends_with_fits_like_extentsion(self, name):
@@ -1709,7 +1708,7 @@ def _query(self, name, json, verbose=False, **kwargs):
17091708
def _build_region_query(self, coordinates, radius, row_limit, json):
17101709
ra = coordinates.transform_to('icrs').ra.deg
17111710
dec = coordinates.transform_to('icrs').dec.deg
1712-
radius_deg = Angle(radius).to_value(astropy.units.deg)
1711+
radius_deg = Angle(radius).to_value(u.deg)
17131712

17141713
select_query = "SELECT "
17151714
if row_limit > 0:

0 commit comments

Comments
 (0)