From fa9aa5fc418ad915ffd3091ccf00334b7e6f30d5 Mon Sep 17 00:00:00 2001 From: Brigitta Sipocz Date: Mon, 23 Feb 2015 14:54:17 +0000 Subject: [PATCH] Changing deprecated coordinates.ICRS() calls to coordinates.SkyCoord() --- astroquery/alfalfa/core.py | 2 +- astroquery/alfalfa/tests/test_alfalfa.py | 2 +- astroquery/fermi/tests/test_fermi.py | 2 +- astroquery/irsa/tests/test_irsa.py | 6 +++--- astroquery/irsa/tests/test_irsa_remote.py | 6 +++--- astroquery/nrao/tests/test_nrao_remote.py | 4 ++-- astroquery/sdss/core.py | 6 +++--- astroquery/sdss/tests/test_sdss_remote.py | 4 ++-- astroquery/simbad/tests/test_simbad_remote.py | 8 ++++---- astroquery/utils/commons.py | 2 +- astroquery/utils/download_file_list.py | 2 +- astroquery/utils/tests/test_utils.py | 2 +- docs/alfalfa/alfalfa.rst | 4 ++-- 13 files changed, 25 insertions(+), 25 deletions(-) diff --git a/astroquery/alfalfa/core.py b/astroquery/alfalfa/core.py index 1a2e9110fc..b3162b32ce 100644 --- a/astroquery/alfalfa/core.py +++ b/astroquery/alfalfa/core.py @@ -119,7 +119,7 @@ def query_region(self, coordinates, radius=3. * u.arcmin, -------- >>> from astroquery.alfalfa import Alfalfa >>> from astropy import coordinates as coords - >>> C = coords.ICRS('0h8m05.63s +14d50m23.3s') + >>> C = coords.SkyCoord('0h8m05.63s +14d50m23.3s') >>> agc = Alfalfa.query_region(C,'3 arcmin') Returns diff --git a/astroquery/alfalfa/tests/test_alfalfa.py b/astroquery/alfalfa/tests/test_alfalfa.py index 3163eebe23..b542078a06 100644 --- a/astroquery/alfalfa/tests/test_alfalfa.py +++ b/astroquery/alfalfa/tests/test_alfalfa.py @@ -54,7 +54,7 @@ def data_path(filename): return os.path.join(data_dir, filename) # Test Case: A Seyfert 1 galaxy -coords = coordinates.ICRS('0h8m05.63s +14d50m23.3s') +coords = coordinates.SkyCoord('0h8m05.63s +14d50m23.3s') ALFALFA = alfalfa.core.Alfalfa() diff --git a/astroquery/fermi/tests/test_fermi.py b/astroquery/fermi/tests/test_fermi.py index db665807f6..52b9deb050 100644 --- a/astroquery/fermi/tests/test_fermi.py +++ b/astroquery/fermi/tests/test_fermi.py @@ -33,7 +33,7 @@ def post_mockreturn(url, data=None, timeout=50, **kwargs): response = MockResponse(r.read(), **kwargs) return response -FK5_COORDINATES = coord.ICRS(10.68471, 41.26875, unit=('deg', 'deg')) +FK5_COORDINATES = coord.SkyCoord(10.68471, 41.26875, unit=('deg', 'deg')) # disable waiting so tests run fast fermi.core.get_fermilat_datafile.TIMEOUT = 1 diff --git a/astroquery/irsa/tests/test_irsa.py b/astroquery/irsa/tests/test_irsa.py index e00b7f59ff..8eb272c7cd 100644 --- a/astroquery/irsa/tests/test_irsa.py +++ b/astroquery/irsa/tests/test_irsa.py @@ -110,9 +110,9 @@ def test_query_region_box(coordinates, patch_get): width=2 * u.arcmin) assert isinstance(result, Table) -poly1 = [coord.ICRS(ra=10.1, dec=10.1, unit=(u.deg, u.deg)), - coord.ICRS(ra=10.0, dec=10.1, unit=(u.deg, u.deg)), - coord.ICRS(ra=10.0, dec=10.0, unit=(u.deg, u.deg))] +poly1 = [coord.SkyCoord(ra=10.1, dec=10.1, unit=(u.deg, u.deg)), + coord.SkyCoord(ra=10.0, dec=10.1, unit=(u.deg, u.deg)), + coord.SkyCoord(ra=10.0, dec=10.0, unit=(u.deg, u.deg))] poly2 = [(10.1 * u.deg, 10.1 * u.deg), (10.0 * u.deg, 10.1 * u.deg), (10.0 * u.deg, 10.0 * u.deg)] diff --git a/astroquery/irsa/tests/test_irsa_remote.py b/astroquery/irsa/tests/test_irsa_remote.py index cbd8ae4c29..e16f81959f 100644 --- a/astroquery/irsa/tests/test_irsa_remote.py +++ b/astroquery/irsa/tests/test_irsa_remote.py @@ -39,9 +39,9 @@ def test_query_region_box(self): assert isinstance(result, Table) def test_query_region_async_polygon(self): - polygon = [coord.ICRS(ra=10.1, dec=10.1, unit=(u.deg, u.deg)), - coord.ICRS(ra=10.0, dec=10.1, unit=(u.deg, u.deg)), - coord.ICRS(ra=10.0, dec=10.0, unit=(u.deg, u.deg))] + polygon = [coord.SkyCoord(ra=10.1, dec=10.1, unit=(u.deg, u.deg)), + coord.SkyCoord(ra=10.0, dec=10.1, unit=(u.deg, u.deg)), + coord.SkyCoord(ra=10.0, dec=10.0, unit=(u.deg, u.deg))] response = irsa.core.Irsa.query_region_async("m31", catalog="fp_psc", spatial="Polygon", polygon=polygon) assert response is not None diff --git a/astroquery/nrao/tests/test_nrao_remote.py b/astroquery/nrao/tests/test_nrao_remote.py index 1560e83f82..71ce72dd75 100644 --- a/astroquery/nrao/tests/test_nrao_remote.py +++ b/astroquery/nrao/tests/test_nrao_remote.py @@ -15,9 +15,9 @@ class TestNrao: def test_query_region_async(self): - response = nrao.core.Nrao.query_region_async(coord.ICRS("04h33m11.1s 05d21m15.5s")) + response = nrao.core.Nrao.query_region_async(coord.SkyCoord("04h33m11.1s 05d21m15.5s")) assert response is not None def test_query_region(self): - result = nrao.core.Nrao.query_region(coord.ICRS("04h33m11.1s 05d21m15.5s")) + result = nrao.core.Nrao.query_region(coord.SkyCoord("04h33m11.1s 05d21m15.5s")) assert isinstance(result, Table) diff --git a/astroquery/sdss/core.py b/astroquery/sdss/core.py index dde26f3b48..ec6c0f767f 100644 --- a/astroquery/sdss/core.py +++ b/astroquery/sdss/core.py @@ -104,7 +104,7 @@ def query_region_async(self, coordinates, radius=u.degree / 1800., -------- >>> from astroquery.sdss import SDSS >>> from astropy import coordinates as coords - >>> co = coords.ICRS('0h8m05.63s +14d50m23.3s') + >>> co = coords.SkyCoord('0h8m05.63s +14d50m23.3s') >>> result = SDSS.query_region(co) >>> print(result[:5]) ra dec objid run rerun camcol field @@ -359,7 +359,7 @@ def get_spectra_async(self, coordinates=None, radius=u.degree / 1800., >>> from astropy import coordinates as coords >>> from astroquery.sdss import SDSS - >>> co = coords.ICRS('0h8m05.63s +14d50m23.3s') + >>> co = coords.SkyCoord('0h8m05.63s +14d50m23.3s') >>> result = SDSS.query_region(co, spectro=True) >>> spec = SDSS.get_spectra(matches=result) @@ -483,7 +483,7 @@ def get_images_async(self, coordinates=None, radius=u.degree / 1800., >>> from astropy import coordinates as coords >>> from astroquery.sdss import SDSS - >>> co = coords.ICRS('0h8m05.63s +14d50m23.3s') + >>> co = coords.SkyCoord('0h8m05.63s +14d50m23.3s') >>> result = SDSS.query_region(co) >>> imgs = SDSS.get_images(matches=result) diff --git a/astroquery/sdss/tests/test_sdss_remote.py b/astroquery/sdss/tests/test_sdss_remote.py index 3662d99ad3..ada802f050 100644 --- a/astroquery/sdss/tests/test_sdss_remote.py +++ b/astroquery/sdss/tests/test_sdss_remote.py @@ -15,7 +15,7 @@ def test_images_timeout(): An independent timeout test to verify that test_images_timeout in the TestSDSSRemote class should be working. Consider this a regression test. """ - coords = coordinates.ICRS('0h8m05.63s +14d50m23.3s') + coords = coordinates.SkyCoord('0h8m05.63s +14d50m23.3s') xid = sdss.core.SDSS.query_region(coords) assert len(xid) == 18 with pytest.raises(TimeoutError): @@ -25,7 +25,7 @@ def test_images_timeout(): @remote_data class TestSDSSRemote: # Test Case: A Seyfert 1 galaxy - coords = coordinates.ICRS('0h8m05.63s +14d50m23.3s') + coords = coordinates.SkyCoord('0h8m05.63s +14d50m23.3s') mintimeout = 1e-6 diff --git a/astroquery/simbad/tests/test_simbad_remote.py b/astroquery/simbad/tests/test_simbad_remote.py index caae9631c8..bb947efb87 100644 --- a/astroquery/simbad/tests/test_simbad_remote.py +++ b/astroquery/simbad/tests/test_simbad_remote.py @@ -12,7 +12,7 @@ imp.reload(requests) # M42 coordinates -ICRS_COORDS = coord.ICRS("05h35m17.3s -05h23m28s") +ICRS_COORDS = coord.SkyCoord("05h35m17.3s -05h23m28s", frame='icrs') @remote_data @@ -122,19 +122,19 @@ def test_query_objects_null(self): # Special case of null test: zero-sized region def test_query_region_null(self): - result = simbad.core.Simbad.query_region(coord.ICRS("00h00m0.0s 00h00m0.0s"), radius="0d", + result = simbad.core.Simbad.query_region(coord.SkyCoord("00h00m0.0s 00h00m0.0s"), radius="0d", equinox=2000.0, epoch='J2000') assert result is None # Special case of null test: very small region def test_query_small_region_null(self): - result = simbad.core.Simbad.query_region(coord.ICRS("00h00m0.0s 00h00m0.0s"), radius=1.0 * u.marcsec, + result = simbad.core.Simbad.query_region(coord.SkyCoord("00h00m0.0s 00h00m0.0s"), radius=1.0 * u.marcsec, equinox=2000.0, epoch='J2000') assert result is None # Special case : zero-sized region with one object def test_query_zero_sized_region(self): - result = simbad.core.Simbad.query_region(coord.ICRS("20h54m05.6889s 37d01m17.380s"), radius="0d", + result = simbad.core.Simbad.query_region(coord.SkyCoord("20h54m05.6889s 37d01m17.380s"), radius="0d", equinox=2000.0, epoch='J2000') # This should find a single star, BD+36 4308 assert len(result) == 1 diff --git a/astroquery/utils/commons.py b/astroquery/utils/commons.py index 2a91ad5eb2..b42b444752 100644 --- a/astroquery/utils/commons.py +++ b/astroquery/utils/commons.py @@ -159,7 +159,7 @@ def radius_to_unit(radius, unit='degree'): def parse_coordinates(coordinates): """ Takes a string or astropy.coordinates object. Checks if the - string is parsable as an astropy.coordinates.ICRS + string is parsable as an `astropy.coordinates` object or is a name that is resolvable. Otherwise asserts that the argument is an astropy.coordinates object. diff --git a/astroquery/utils/download_file_list.py b/astroquery/utils/download_file_list.py index 73976e0f4f..d02d5f1486 100644 --- a/astroquery/utils/download_file_list.py +++ b/astroquery/utils/download_file_list.py @@ -92,7 +92,7 @@ def download_list_of_fitsfiles(linklist, output_directory=None, # this part will eventually be handled by astropy.coordinates directly # ctype = h0['CTYPE1'] # if 'RA' in ctype: - # coordinate = coord.ICRS(lon,lat,unit=('deg','deg')) + # coordinate = coord.SkyCoord(lon,lat,unit=('deg','deg')) # elif 'GLON' in ctype: # coordinate = coord.Galactic(lon,lat,unit=('deg','deg')) # else: diff --git a/astroquery/utils/tests/test_utils.py b/astroquery/utils/tests/test_utils.py index 289635efa9..2bb4690b68 100644 --- a/astroquery/utils/tests/test_utils.py +++ b/astroquery/utils/tests/test_utils.py @@ -49,7 +49,7 @@ def test_class_or_instance(): @pytest.mark.parametrize(('coordinates'), - [coord.ICRS(ra=148, dec=69, unit=(u.deg, u.deg)), + [coord.SkyCoord(ra=148, dec=69, unit=(u.deg, u.deg)), ] ) def test_parse_coordinates_1(coordinates): diff --git a/docs/alfalfa/alfalfa.rst b/docs/alfalfa/alfalfa.rst index 8bfb369ee7..ecfe4edd8e 100644 --- a/docs/alfalfa/alfalfa.rst +++ b/docs/alfalfa/alfalfa.rst @@ -16,7 +16,7 @@ used in the SDSS example). >>> from astroquery.alfalfa import Alfalfa >>> from astropy import coordinates as coords - >>> pos = coords.ICRS('0h8m05.63s +14d50m23.3s') + >>> pos = coords.SkyCoord('0h8m05.63s +14d50m23.3s') >>> agc = Alfalfa.query_region(pos, optical_counterpart=True) This retrieves the AGC number of the object closest to the supplied ra and dec @@ -36,7 +36,7 @@ This returns a PyFITS HDUList object. If we want to have a look at the entire A .. code-block:: python >>> cat = Alfalfa.get_catalog() - + which returns a dictionary containing HI measurements for nearly 16,000 objects.