Created
May 9, 2014 07:09
-
-
Save keflavich/680ae36b1d7d12bc4557 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ python setup.py test | |
| Freezing version number to astroquery/version.py | |
| running test | |
| running build | |
| running build_py | |
| copying astroquery/query.py -> build/lib.macosx-10.6-intel-2.7/astroquery | |
| copying astroquery/version.py -> build/lib.macosx-10.6-intel-2.7/astroquery | |
| copying astroquery/alfalfa/core.py -> build/lib.macosx-10.6-intel-2.7/astroquery/alfalfa | |
| copying astroquery/besancon/core.py -> build/lib.macosx-10.6-intel-2.7/astroquery/besancon | |
| copying astroquery/eso/core.py -> build/lib.macosx-10.6-intel-2.7/astroquery/eso | |
| copying astroquery/fermi/core.py -> build/lib.macosx-10.6-intel-2.7/astroquery/fermi | |
| copying astroquery/irsa/core.py -> build/lib.macosx-10.6-intel-2.7/astroquery/irsa | |
| copying astroquery/irsa_dust/core.py -> build/lib.macosx-10.6-intel-2.7/astroquery/irsa_dust | |
| copying astroquery/lamda/core.py -> build/lib.macosx-10.6-intel-2.7/astroquery/lamda | |
| copying astroquery/magpis/core.py -> build/lib.macosx-10.6-intel-2.7/astroquery/magpis | |
| copying astroquery/ned/core.py -> build/lib.macosx-10.6-intel-2.7/astroquery/ned | |
| copying astroquery/nvas/core.py -> build/lib.macosx-10.6-intel-2.7/astroquery/nvas | |
| copying astroquery/ogle/core.py -> build/lib.macosx-10.6-intel-2.7/astroquery/ogle | |
| copying astroquery/sdss/core.py -> build/lib.macosx-10.6-intel-2.7/astroquery/sdss | |
| copying astroquery/sha/core.py -> build/lib.macosx-10.6-intel-2.7/astroquery/sha | |
| copying astroquery/simbad/core.py -> build/lib.macosx-10.6-intel-2.7/astroquery/simbad | |
| copying astroquery/splatalogue/__init__.py -> build/lib.macosx-10.6-intel-2.7/astroquery/splatalogue | |
| copying astroquery/splatalogue/core.py -> build/lib.macosx-10.6-intel-2.7/astroquery/splatalogue | |
| copying astroquery/splatalogue/load_species_table.py -> build/lib.macosx-10.6-intel-2.7/astroquery/splatalogue | |
| copying astroquery/ukidss/core.py -> build/lib.macosx-10.6-intel-2.7/astroquery/ukidss | |
| copying astroquery/utils/commons.py -> build/lib.macosx-10.6-intel-2.7/astroquery/utils | |
| copying astroquery/utils/download_file_list.py -> build/lib.macosx-10.6-intel-2.7/astroquery/utils | |
| copying astroquery/utils/process_asyncs.py -> build/lib.macosx-10.6-intel-2.7/astroquery/utils | |
| copying astroquery/utils/progressbar.py -> build/lib.macosx-10.6-intel-2.7/astroquery/utils | |
| copying astroquery/vizier/core.py -> build/lib.macosx-10.6-intel-2.7/astroquery/vizier | |
| copying astroquery/eso/tests/test_eso_remote.py -> build/lib.macosx-10.6-intel-2.7/astroquery/eso/tests | |
| copying astroquery/irsa_dust/tests/test_irsa_dust.py -> build/lib.macosx-10.6-intel-2.7/astroquery/irsa_dust/tests | |
| copying astroquery/sdss/tests/test_sdss.py -> build/lib.macosx-10.6-intel-2.7/astroquery/sdss/tests | |
| copying astroquery/simbad/tests/test_simbad.py -> build/lib.macosx-10.6-intel-2.7/astroquery/simbad/tests | |
| copying astroquery/utils/tests/test_utils.py -> build/lib.macosx-10.6-intel-2.7/astroquery/utils/tests | |
| copying astroquery/vizier/tests/test_vizier.py -> build/lib.macosx-10.6-intel-2.7/astroquery/vizier/tests | |
| running egg_info | |
| writing requirements to astroquery.egg-info/requires.txt | |
| writing astroquery.egg-info/PKG-INFO | |
| writing top-level names to astroquery.egg-info/top_level.txt | |
| writing dependency_links to astroquery.egg-info/dependency_links.txt | |
| reading manifest file 'astroquery.egg-info/SOURCES.txt' | |
| reading manifest template 'MANIFEST.in' | |
| warning: no files found matching 'distribute_setup.py' | |
| warning: no files found matching '*.pyx' under directory 'astroquery' | |
| warning: no files found matching '*.c' under directory 'astroquery' | |
| warning: no previously-included files found matching '*.pyc' | |
| warning: no previously-included files found matching '*.o' | |
| no previously-included directories found matching 'build' | |
| writing manifest file 'astroquery.egg-info/SOURCES.txt' | |
| regenerating default astroquery.cfg file | |
| copying astroquery/astroquery.cfg -> build/lib.macosx-10.6-intel-2.7/astroquery | |
| /Users/adam/repos/astropy/astropy/tests/helper.py:30: UserWarning: Module astroquery was already imported from astroquery/__init__.pyc, but /Users/adam/repos/astroquery is being added to sys.path | |
| import pkg_resources | |
| ===================================================================== test session starts ===================================================================== | |
| platform darwin -- Python 2.7.6 -- pytest-2.5.1 | |
| Running tests with Astropy version 0.4.dev8070. | |
| Running tests in astroquery /Users/adam/repos/astroquery/docs. | |
| Platform: Darwin-13.1.0-x86_64-i386-64bit | |
| Executable: /Users/adam/virtual-python/bin/python | |
| Full Python Version: | |
| 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54) | |
| [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] | |
| encodings: sys: ascii, locale: UTF-8, filesystem: utf-8, unicode bits: 15 | |
| byteorder: little | |
| float info: dig: 15, mant_dig: 15 | |
| Numpy: 1.8.1 | |
| Scipy: 0.14.0.dev-5194d3e | |
| Matplotlib: 1.4.x | |
| h5py: not available | |
| plugins: xdist | |
| collected 444 items | |
| astroquery/alfalfa/tests/test_alfalfa.py ... | |
| astroquery/besancon/tests/test_besancon.py ... | |
| astroquery/eso/tests/test_eso.py x | |
| astroquery/eso/tests/test_eso_remote.py ss | |
| astroquery/fermi/tests/test_fermi.py .... | |
| astroquery/gama/tests/test_gama.py ss | |
| astroquery/irsa/tests/test_irsa.py ............................. | |
| astroquery/irsa/tests/test_irsa_remote.py ssssss | |
| astroquery/irsa_dust/tests/test_irsa_dust.py ............................................................... | |
| astroquery/irsa_dust/tests/test_irsa_dust_remote.py ssssssssssssssssssssssssssssssssssssssssss | |
| astroquery/lamda/tests/test_lamda.py .... | |
| astroquery/lamda/tests/test_lamda_remote.py sss | |
| astroquery/magpis/tests/test_magpis.py ...x | |
| astroquery/magpis/tests/test_magpis_remote.py ss | |
| astroquery/ned/tests/test_ned.py ....x..................... | |
| astroquery/ned/tests/test_ned_remote.py ssssssssssssssssssss | |
| astroquery/nist/tests/test_nist.py ... | |
| astroquery/nist/tests/test_nist_remote.py ss | |
| astroquery/nrao/tests/test_nrao.py .. | |
| astroquery/nrao/tests/test_nrao_remote.py ss | |
| astroquery/nvas/tests/test_nvas.py ........ | |
| astroquery/nvas/tests/test_nvas_remote.py sss | |
| astroquery/ogle/tests/test_ogle.py ... | |
| astroquery/sdss/tests/test_sdss.py ............ | |
| astroquery/sdss/tests/test_sdss_remote.py ssssssssssss | |
| astroquery/sha/tests/test_sha.py ..... | |
| astroquery/simbad/core.py .... | |
| astroquery/simbad/tests/test_simbad.py .................................................. | |
| astroquery/simbad/tests/test_simbad_remote.py sssssssssssss | |
| astroquery/splatalogue/tests/test_splatalogue.py ......... | |
| astroquery/splatalogue/tests/test_utils.py ... | |
| astroquery/tests/test_internet.py s | |
| astroquery/ukidss/tests/test_ukidss.py ........... | |
| astroquery/ukidss/tests/test_ukidss_remote.py ssssss | |
| astroquery/utils/commons.py . | |
| astroquery/utils/tests/test_utils.py s..ss................. | |
| astroquery/vizier/tests/test_vizier.py ........................ | |
| astroquery/vizier/tests/test_vizier_remote.py sssssss | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/api.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/gallery.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/index.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/query.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/template.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/testing.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/utils.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/alfalfa/alfalfa.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/besancon/besancon.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/eso/eso.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/fermi/fermi.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/gama/gama.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/irsa/irsa.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/irsa/irsa_dust.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/lamda/lamda.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/magpis/magpis.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/ned/ned.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/nist/nist.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/nrao/nrao.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/nvas/nvas.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/ogle/ogle.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/sdss/sdss.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/sha/sha.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/simbad/simbad.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/splatalogue/splatalogue.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/ukidss/ukidss.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/vizier/vizier.rst . | |
| ===================================================== 315 passed, 126 skipped, 3 xfailed in 14.27 seconds ===================================================== | |
| cyg ~/repos/astroquery master$ python setup.py test --remote-data | |
| running test | |
| running build | |
| running build_py | |
| running egg_info | |
| writing requirements to astroquery.egg-info/requires.txt | |
| writing astroquery.egg-info/PKG-INFO | |
| writing top-level names to astroquery.egg-info/top_level.txt | |
| writing dependency_links to astroquery.egg-info/dependency_links.txt | |
| reading manifest file 'astroquery.egg-info/SOURCES.txt' | |
| reading manifest template 'MANIFEST.in' | |
| warning: no files found matching 'distribute_setup.py' | |
| warning: no files found matching '*.pyx' under directory 'astroquery' | |
| warning: no files found matching '*.c' under directory 'astroquery' | |
| warning: no previously-included files found matching '*.pyc' | |
| warning: no previously-included files found matching '*.o' | |
| no previously-included directories found matching 'build' | |
| writing manifest file 'astroquery.egg-info/SOURCES.txt' | |
| regenerating default astroquery.cfg file | |
| copying astroquery/astroquery.cfg -> build/lib.macosx-10.6-intel-2.7/astroquery | |
| /Users/adam/repos/astropy/astropy/tests/helper.py:30: UserWarning: Module astroquery was already imported from astroquery/__init__.pyc, but /Users/adam/repos/astroquery is being added to sys.path | |
| import pkg_resources | |
| ===================================================================== test session starts ===================================================================== | |
| platform darwin -- Python 2.7.6 -- pytest-2.5.1 | |
| Running tests with Astropy version 0.4.dev8070. | |
| Running tests in astroquery /Users/adam/repos/astroquery/docs. | |
| Platform: Darwin-13.1.0-x86_64-i386-64bit | |
| Executable: /Users/adam/virtual-python/bin/python | |
| Full Python Version: | |
| 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54) | |
| [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] | |
| encodings: sys: ascii, locale: UTF-8, filesystem: utf-8, unicode bits: 15 | |
| byteorder: little | |
| float info: dig: 15, mant_dig: 15 | |
| Numpy: 1.8.1 | |
| Scipy: 0.14.0.dev-5194d3e | |
| Matplotlib: 1.4.x | |
| h5py: not available | |
| Using Astropy options: remote_data. | |
| plugins: xdist | |
| collected 444 items | |
| astroquery/alfalfa/tests/test_alfalfa.py ... | |
| astroquery/besancon/tests/test_besancon.py ... | |
| astroquery/eso/tests/test_eso.py X | |
| astroquery/eso/tests/test_eso_remote.py .. | |
| astroquery/fermi/tests/test_fermi.py .... | |
| astroquery/gama/tests/test_gama.py .. | |
| astroquery/irsa/tests/test_irsa.py ............................. | |
| astroquery/irsa/tests/test_irsa_remote.py ...... | |
| astroquery/irsa_dust/tests/test_irsa_dust.py ............................................................... | |
| astroquery/irsa_dust/tests/test_irsa_dust_remote.py ....^@.....................................^[[D. | |
| astroquery/lamda/tests/test_lamda.py .... | |
| astroquery/lamda/tests/test_lamda_remote.py ... | |
| astroquery/magpis/tests/test_magpis.py ...x | |
| astroquery/magpis/tests/test_magpis_remote.py .. | |
| astroquery/ned/tests/test_ned.py ....x..................... | |
| astroquery/ned/tests/test_ned_remote.py X................... | |
| astroquery/nist/tests/test_nist.py ... | |
| astroquery/nist/tests/test_nist_remote.py .. | |
| astroquery/nrao/tests/test_nrao.py .. | |
| astroquery/nrao/tests/test_nrao_remote.py .. | |
| astroquery/nvas/tests/test_nvas.py ........ | |
| astroquery/nvas/tests/test_nvas_remote.py ... | |
| astroquery/ogle/tests/test_ogle.py ... | |
| astroquery/sdss/tests/test_sdss.py ............ | |
| astroquery/sdss/tests/test_sdss_remote.py .^@..^@........F | |
| astroquery/sha/tests/test_sha.py ..... | |
| astroquery/simbad/core.py .... | |
| astroquery/simbad/tests/test_simbad.py ..........F.FF................FFF.FFF............. | |
| astroquery/simbad/tests/test_simbad_remote.py ............. | |
| astroquery/splatalogue/tests/test_splatalogue.py ......... | |
| astroquery/splatalogue/tests/test_utils.py ... | |
| astroquery/tests/test_internet.py . | |
| astroquery/ukidss/tests/test_ukidss.py ........FF. | |
| astroquery/ukidss/tests/test_ukidss_remote.py .F.^@.FF | |
| astroquery/utils/commons.py . | |
| astroquery/utils/tests/test_utils.py F..................... | |
| astroquery/vizier/tests/test_vizier.py ........................ | |
| astroquery/vizier/tests/test_vizier_remote.py ....... | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/api.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/gallery.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/index.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/query.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/template.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/testing.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/utils.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/alfalfa/alfalfa.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/besancon/besancon.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/eso/eso.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/fermi/fermi.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/gama/gama.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/irsa/irsa.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/irsa/irsa_dust.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/lamda/lamda.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/magpis/magpis.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/ned/ned.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/nist/nist.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/nrao/nrao.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/nvas/nvas.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/ogle/ogle.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/sdss/sdss.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/sha/sha.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/simbad/simbad.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/splatalogue/splatalogue.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/ukidss/ukidss.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/vizier/vizier.rst . | |
| ========================================================================== FAILURES =========================================================================== | |
| _____________________________________________________________ TestSDSSRemote.test_images_timeout ______________________________________________________________ | |
| self = <astroquery.sdss.tests.test_sdss_remote.TestSDSSRemote instance at 0x10a14cf38> | |
| def test_images_timeout(self): | |
| xid = sdss.core.SDSS.query_region(self.coords) | |
| with pytest.raises(TimeoutError): | |
| > img = sdss.core.SDSS.get_images(matches=xid, timeout=self.mintimeout) | |
| E Failed: DID NOT RAISE | |
| astroquery/sdss/tests/test_sdss_remote.py:98: Failed | |
| ________________________________________________________ test_get_frame_coordinates[coordinates0-GAL] _________________________________________________________ | |
| coordinates = <Galactic l=292.97916 deg, b=-29.75447 deg>, expected_frame = 'GAL' | |
| @pytest.mark.parametrize(('coordinates', 'expected_frame'), | |
| [(GALACTIC_COORDS, 'GAL'), | |
| (ICRS_COORDS, 'ICRS'), | |
| (FK4_COORDS, 'FK4'), | |
| (FK5_COORDS, 'FK5') | |
| ]) | |
| def test_get_frame_coordinates(coordinates, expected_frame): | |
| > actual_frame = simbad.core._get_frame_coords(coordinates)[2] | |
| astroquery/simbad/tests/test_simbad.py:97: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| c = <Galactic l=292.97916 deg, b=-29.75447 deg> | |
| def _get_frame_coords(c): | |
| > if c.icrs == c: | |
| astroquery/simbad/core.py:695: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <Galactic l=292.97916 deg, b=-29.75447 deg>, name = 'icrs' | |
| def __getattr__(self, name): | |
| """ | |
| Overrides getattr to return coordinates that this can be transformed | |
| to, based on the alias name in the master transform graph. | |
| """ | |
| from .transformations import master_transform_graph | |
| nmsys = master_transform_graph.lookup_name(name) | |
| if self.__class__ is nmsys: | |
| return self | |
| if nmsys is not None and self.is_transformable_to(nmsys): | |
| > return self.transform_to(nmsys) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:659: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <Galactic l=292.97916 deg, b=-29.75447 deg>, tosys = <class 'astropy.coordinates.builtin_systems.ICRS'> | |
| def transform_to(self, tosys): | |
| """ | |
| Transform this coordinate to a new system. | |
| Parameters | |
| ---------- | |
| tosys : class | |
| The system to transform this coordinate into. | |
| Returns | |
| ------- | |
| transcoord | |
| A new object with this coordinate represented in the | |
| ``tosys`` system. | |
| Raises | |
| ------ | |
| ValueError | |
| If there is no possible transformation route. | |
| """ | |
| from .transformations import master_transform_graph | |
| from .errors import ConvertError | |
| if tosys is self.__class__: | |
| return copy.deepcopy(self) | |
| trans = master_transform_graph.get_transform(self.__class__, tosys) | |
| if trans is None: | |
| raise ConvertError('Cannot transform from {0} to ' | |
| '{1}'.format(self.__class__, tosys)) | |
| > return trans(self) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:622: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.CompositeTransform object at 0x108242c10>, fromcoord = <Galactic l=292.97916 deg, b=-29.75447 deg> | |
| super(CompositeTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| > coord = fromcoord | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:742: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.DynamicMatrixTransform object at 0x1067c5990>, fromcoord = <Galactic l=292.97916 deg, b=-29.75447 deg> | |
| super(DynamicMatrixTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| c = fromcoord.cartesian | |
| v = c.reshape((3, c.size // 3)) | |
| v2 = np.dot(np.asarray(self.matrix_func(fromcoord)), v) | |
| subshape = c.shape[1:] | |
| x = v2[0].reshape(subshape) | |
| y = v2[1].reshape(subshape) | |
| z = v2[2].reshape(subshape) | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:708: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x119888638>, args = () | |
| kwargs = {'unit': None, 'x': <CartesianPoints 0.0170822506606243>, 'y': <CartesianPoints 0.15781058025053168>, 'z': <CartesianPoints -0.9873216383090963>} | |
| def __init__(self, *args, **kwargs): | |
| super(FK5, self).__init__() | |
| self._equinox = kwargs.pop('equinox', _EQUINOX_J2000) | |
| self._obstime = kwargs.pop('obstime', None) | |
| if not isinstance(self._equinox, Time): | |
| raise TypeError('specified equinox is not a Time object') | |
| if self._obstime is not None and not isinstance(self._obstime, Time): | |
| raise TypeError('specified obstime is not None or a Time object') | |
| if not self._equinox.isscalar: | |
| raise ValueError('specified equinox is not a scalar') | |
| if len(args) == 1 and len(kwargs) == 0 and isinstance(args[0], SphericalCoordinatesBase): | |
| newcoord = args[0].transform_to(self.__class__) | |
| self._latangle = newcoord._latangle | |
| self._lonangle = newcoord._lonangle | |
| self._distance = newcoord._distance | |
| else: | |
| > super(FK5, self)._initialize_latlon('ra', 'dec', args, kwargs) | |
| /Users/adam/repos/astropy/astropy/coordinates/builtin_systems.py:140: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x119888a28>, lonname = 'ra' | |
| latname = 'dec', initargs = (), initkwargs = {} | |
| def _initialize_latlon(self, lonname, latname, initargs, initkwargs): | |
| """ | |
| Subclasses should use this to initialize standard lat/lon-style | |
| coordinates. | |
| This recognizes both the lat/lon style and the cartesian form. | |
| Parameters | |
| ---------- | |
| lonname : str | |
| The name of the longitude-like coordinate attribute | |
| latname : str | |
| The name of the latitude-like coordinate attribute | |
| initargs : list | |
| The ``*args`` from the initializer | |
| initkwargs : dict | |
| The ``**kwargs`` from the initializer | |
| """ | |
| initkwargs = dict(initkwargs) # copy | |
| nargs = len(initargs) | |
| sclsnm = self.__class__.__name__ | |
| if nargs == 1: | |
| if isinstance(initargs[0], CartesianPoints): | |
| initkwargs['cartpoint'] = initargs[0] | |
| else: | |
| initkwargs['coordstr'] = initargs[0] | |
| if nargs > 1: | |
| if lonname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, lonname)) | |
| initkwargs[lonname] = initargs[0] | |
| if nargs >= 2: | |
| if latname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, latname)) | |
| initkwargs[latname] = initargs[1] | |
| if nargs > 2: | |
| raise TypeError('{0} takes up to 2 positional arguments ' | |
| '({1} given)'.format(sclsnm, len(initargs))) | |
| unit = initkwargs.pop('unit', None) | |
| coordstr = initkwargs.pop('coordstr', None) | |
| lonval = initkwargs.pop(lonname, None) | |
| latval = initkwargs.pop(latname, None) | |
| distval = initkwargs.pop('distance', None) | |
| cartpoint = initkwargs.pop('cartpoint', None) | |
| x = initkwargs.pop('x', None) | |
| y = initkwargs.pop('y', None) | |
| z = initkwargs.pop('z', None) | |
| if len(initkwargs) > 0: | |
| raise TypeError('{0} got unexpected keyword argument' | |
| ' {1}'.format(sclsnm, initkwargs.keys())) | |
| angleinit = ((lonval is not None and latval is not None) or | |
| coordstr is not None) | |
| cartinit = ((x is not None and y is not None and z is not None) or | |
| cartpoint is not None) | |
| if angleinit and not cartinit: | |
| # lat/lon-style initialization | |
| for v in [x, y, z, cartpoint]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| try: | |
| # this raises a TypeError if `unit` is not None or iterable | |
| units = [None, None] if unit is None else list(unit) | |
| except TypeError: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a ' | |
| 'non-sequence {1}'.format(sclsnm, unit)) | |
| if len(units) == 2: | |
| try: | |
| if units[0] is not None: | |
| units[0] = u.Unit(units[0]) | |
| if units[1] is not None: | |
| units[1] = u.Unit(units[1]) | |
| except ValueError: | |
| raise ValueError('Could not convert units to unit objects ' | |
| 'while initializing ' + sclsnm) | |
| else: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a sequence ' | |
| 'of {1}.'.format(sclsnm, len(units))) | |
| if coordstr is not None: | |
| # need to try to parse the coordinate from a single argument | |
| # populates latval and lonval variables, which then get made | |
| # into coordinates below | |
| if isinstance(coordstr, six.string_types): | |
| if "," in coordstr: | |
| lonval, latval = coordstr.split(",") | |
| else: | |
| coosplit = coordstr.split() | |
| if len(coosplit) == 6: | |
| lonval = " ".join(coosplit[0:3]) | |
| latval = " ".join(coosplit[3:]) | |
| elif len(coosplit) == 2: | |
| lonval, latval = coosplit | |
| else: | |
| msg = ("Could not parse {lonname}/{latname} values " | |
| "from the string provided: '{coordstr}'.") | |
| raise ValueError(msg.format(lonname=lonname, | |
| latname=latname, | |
| coordstr=coordstr)) | |
| else: | |
| raise ValueError("A {0} cannot be created with a single value of type " | |
| "'{1}', must be a string.".format(sclsnm, type(coordstr).__name__)) | |
| # now actually create the angle objects | |
| lonang = Longitude(lonval, unit=units[0]) | |
| latang = Latitude(latval, unit=units[1]) | |
| dist = None if distval is None else Distance(distval) # copy | |
| elif cartinit and not angleinit: | |
| # cartesian-style initialization | |
| for v in [coordstr, lonval, latval, distval]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| if cartpoint is not None: | |
| for v in [x, y, z, unit]: | |
| if v is not None: | |
| raise ValueError('Cannot give both a CartesianPoints ' | |
| 'and x/y/z/unit parameters while ' | |
| 'initializing ' + sclsnm) | |
| x = cartpoint.x | |
| y = cartpoint.y | |
| z = cartpoint.z | |
| unit = cartpoint.unit | |
| > r, latval, lonval = cartesian_to_spherical(x, y, z) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:235: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| x = <CartesianPoints 0.0170822506606243>, y = <CartesianPoints 0.15781058025053168>, z = <CartesianPoints -0.9873216383090963> | |
| x : scalar or array-like | |
| The first cartesian coordinate. | |
| y : scalar or array-like | |
| The second cartesian coordinate. | |
| z : scalar or array-like | |
| The third cartesian coordinate. | |
| Returns | |
| ------- | |
| r : float or array | |
| The radial coordinate (in the same units as the inputs). | |
| lat : float or array | |
| The latitude in radians | |
| lon : float or array | |
| The longitude in radians | |
| """ | |
| xsq = x ** 2 | |
| ysq = y ** 2 | |
| zsq = z ** 2 | |
| r = (xsq + ysq + zsq) ** 0.5 | |
| s = (xsq + ysq) ** 0.5 | |
| if np.isscalar(x) and np.isscalar(y) and np.isscalar(z): | |
| lon = math.atan2(y, x) | |
| lat = math.atan2(z, s) | |
| else: | |
| lon = np.arctan2(y, x) | |
| lat = np.arctan2(z, s) | |
| return r, lat, lon | |
| def spherical_to_cartesian(r, lat, lon): | |
| """ | |
| Converts spherical polar coordinates to rectangular cartesian | |
| coordinates. | |
| Note that the input angles should be in latitude/longitude or | |
| elevation/azimuthal form. I.e., the origin is along the equator | |
| rather than at the north pole. | |
| .. note:: | |
| This is a low-level function used internally in | |
| > `astropy.coordinates`. It is provided for users if they really | |
| want to use it, but it is recommended that you use the | |
| `astropy.coordinates` coordinate systems. | |
| Parameters | |
| ---------- | |
| r : scalar or array-like | |
| The radial coordinate (in the same units as the inputs). | |
| lat : scalar or array-like | |
| The latitude in radians | |
| lon : scalar or array-like | |
| The longitude in radians | |
| Returns | |
| ------- | |
| x : float or array | |
| The first cartesian coordinate. | |
| y : float or array | |
| The second cartesian coordinate. | |
| z : float or array | |
| The third cartesian coordinate. | |
| """ | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:441: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints 0.15781058025053168>, obj = array(2.315841784746324e+77) | |
| context = (<ufunc 'arctan2'>, (<CartesianPoints 0.15781058025053168>, <CartesianPoints 0.0170822506606243>), 0) | |
| raise TypeError("The value must be a valid Python or " | |
| "Numpy numeric type.") | |
| # by default, cast any integer, boolean, etc., to float | |
| if dtype is None and not np.can_cast(np.float32, value.dtype): | |
| value = value.astype(np.float) | |
| value = value.view(cls) | |
| value._unit = unit | |
| return value | |
| def __array_finalize__(self, obj): | |
| self._unit = getattr(obj, '_unit', None) | |
| def __array_prepare__(self, obj, context=None): | |
| # This method gets called by Numpy whenever a ufunc is called on the | |
| # array. The object passed in ``obj`` is an empty version of the | |
| # output array which we can e.g. change to an array sub-class, add | |
| # attributes to, etc. After this is called, then the ufunc is called | |
| # and the values in this empty array are set. | |
| # If no context is set, just return the input | |
| if context is None: | |
| return obj | |
| # Find out which ufunc is being used | |
| function = context[0] | |
| from .quantity_helper import UNSUPPORTED_UFUNCS, UFUNC_HELPERS | |
| # Check whether we even support this ufunc | |
| if function in UNSUPPORTED_UFUNCS: | |
| raise TypeError("Cannot use function '{0}' with quantities" | |
| .format(function.__name__)) | |
| # Now find out what arguments were passed to the ufunc, usually, this | |
| # will include at least the present object, and another, which could | |
| # be a Quantity, or a Numpy array, etc. when using two-argument ufuncs. | |
| args = context[1][:function.nin] | |
| units = [getattr(arg, 'unit', None) for arg in args] | |
| # If the ufunc is supported, then we call a helper function (defined | |
| # in quantity_helper.py) which returns the scale by which the inputs | |
| # should be multiplied before being passed to the ufunc, as well as | |
| # the unit the output from the ufunc will have. | |
| if function in UFUNC_HELPERS: | |
| scales, result_unit = UFUNC_HELPERS[function](function, *units) | |
| else: | |
| raise TypeError("Unknown ufunc {0}. Please raise issue on " | |
| "https://github.com/astropy/astropy" | |
| .format(function.__name__)) | |
| if any(scale == 0. for scale in scales): | |
| # for two-argument ufuncs with a quantity and a non-quantity, | |
| # the quantity normally needs to be dimensionless, *except* | |
| # if the non-quantity can have arbitrary unit, i.e., when it | |
| # is all zero, infinity or NaN. In that case, the non-quantity | |
| # can just have the unit of the quantity | |
| # (this allows, e.g., `q > 0.` independent of unit) | |
| maybe_arbitrary_arg = args[scales.index(0.)] | |
| if _can_have_arbitrary_unit(maybe_arbitrary_arg): | |
| scales = [1., 1.] | |
| else: | |
| raise UnitsError("Can only apply '{0}' function to " | |
| "dimensionless quantities when other " | |
| "argument is not a quantity (unless the " | |
| "latter is all zero/infinity/nan)" | |
| .format(function.__name__)) | |
| # In the case of np.power, the unit itself needs to be modified by an | |
| # amount that depends on one of the input values, so we need to treat | |
| # this as a special case. | |
| # TODO: find a better way to deal with this case | |
| if function is np.power and result_unit is not None: | |
| if units[1] is None: | |
| p = args[1] | |
| else: | |
| p = args[1].to(dimensionless_unscaled).value | |
| result_unit = result_unit ** validate_power(p) | |
| # We now prepare the output object | |
| if self is obj: # happens if the output object is self, which happens | |
| # for in-place operations such as q1 += q2 | |
| # In some cases, the result of a ufunc should be a plain Numpy | |
| # array, which we can't do if we are doing an in-place operation. | |
| if result_unit is None: | |
| raise TypeError("Cannot store non-quantity output from {0} " | |
| "function in Quantity object" | |
| .format(function.__name__)) | |
| /Users/adam/repos/astropy/astropy/units/quantity.py:311: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints 0.15781058025053168>, obj = array(2.315841784746324e+77), unit = Unit("rad") | |
| #screw up the units are killed by _convert_to_and_validate_length_unit | |
| obj = super(CartesianPoints, self).__array_wrap__(obj, context=context) | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:310: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = AssertionError(), args = (), f = <py._code.code.Frame object at 0x1082594d0> | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| > ??? | |
| _pytest.assertion.reinterpret:40: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| frame = <py._code.code.Frame object at 0x1082594d0>, should_fail = True | |
| > ??? | |
| _pytest.assertion.newinterpret:46: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| filename = '<unknown>', mode = 'exec' | |
| def parse(source, filename='<unknown>', mode='exec'): | |
| """ | |
| Parse the source into an AST node. | |
| Equivalent to compile(source, filename, mode, PyCF_ONLY_AST). | |
| """ | |
| > return compile(source, filename, mode, PyCF_ONLY_AST) | |
| E File "<unknown>", line 1 | |
| E .. note:: | |
| E ^ | |
| E SyntaxError: invalid syntax | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py:37: SyntaxError | |
| ________________________________________________________ test_get_frame_coordinates[coordinates2-FK4] _________________________________________________________ | |
| coordinates = <FK4 RA=84.90759 deg, Dec=-80.89403 deg>, expected_frame = 'FK4' | |
| @pytest.mark.parametrize(('coordinates', 'expected_frame'), | |
| [(GALACTIC_COORDS, 'GAL'), | |
| (ICRS_COORDS, 'ICRS'), | |
| (FK4_COORDS, 'FK4'), | |
| (FK5_COORDS, 'FK5') | |
| ]) | |
| def test_get_frame_coordinates(coordinates, expected_frame): | |
| > actual_frame = simbad.core._get_frame_coords(coordinates)[2] | |
| astroquery/simbad/tests/test_simbad.py:97: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| c = <FK4 RA=84.90759 deg, Dec=-80.89403 deg> | |
| def _get_frame_coords(c): | |
| > if c.icrs == c: | |
| astroquery/simbad/core.py:695: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <FK4 RA=84.90759 deg, Dec=-80.89403 deg>, name = 'icrs' | |
| def __getattr__(self, name): | |
| """ | |
| Overrides getattr to return coordinates that this can be transformed | |
| to, based on the alias name in the master transform graph. | |
| """ | |
| from .transformations import master_transform_graph | |
| nmsys = master_transform_graph.lookup_name(name) | |
| if self.__class__ is nmsys: | |
| return self | |
| if nmsys is not None and self.is_transformable_to(nmsys): | |
| > return self.transform_to(nmsys) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:659: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <FK4 RA=84.90759 deg, Dec=-80.89403 deg>, tosys = <class 'astropy.coordinates.builtin_systems.ICRS'> | |
| def transform_to(self, tosys): | |
| """ | |
| Transform this coordinate to a new system. | |
| Parameters | |
| ---------- | |
| tosys : class | |
| The system to transform this coordinate into. | |
| Returns | |
| ------- | |
| transcoord | |
| A new object with this coordinate represented in the | |
| ``tosys`` system. | |
| Raises | |
| ------ | |
| ValueError | |
| If there is no possible transformation route. | |
| """ | |
| from .transformations import master_transform_graph | |
| from .errors import ConvertError | |
| if tosys is self.__class__: | |
| return copy.deepcopy(self) | |
| trans = master_transform_graph.get_transform(self.__class__, tosys) | |
| if trans is None: | |
| raise ConvertError('Cannot transform from {0} to ' | |
| '{1}'.format(self.__class__, tosys)) | |
| > return trans(self) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:622: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.CompositeTransform object at 0x10825b350>, fromcoord = <FK4 RA=84.90759 deg, Dec=-80.89403 deg> | |
| super(CompositeTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| > coord = fromcoord | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:742: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.DynamicMatrixTransform object at 0x1067c58d0>, fromcoord = <FK4NoETerms RA=84.90701 deg, Dec=-80.89400 deg> | |
| super(DynamicMatrixTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| c = fromcoord.cartesian | |
| v = c.reshape((3, c.size // 3)) | |
| v2 = np.dot(np.asarray(self.matrix_func(fromcoord)), v) | |
| subshape = c.shape[1:] | |
| x = v2[0].reshape(subshape) | |
| y = v2[1].reshape(subshape) | |
| z = v2[2].reshape(subshape) | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:708: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x109e799e0>, args = () | |
| kwargs = {'unit': None, 'x': <CartesianPoints 0.017083352278353055>, 'y': <CartesianPoints 0.15781065479713563>, 'z': <CartesianPoints -0.9873216073334123>} | |
| def __init__(self, *args, **kwargs): | |
| super(FK5, self).__init__() | |
| self._equinox = kwargs.pop('equinox', _EQUINOX_J2000) | |
| self._obstime = kwargs.pop('obstime', None) | |
| if not isinstance(self._equinox, Time): | |
| raise TypeError('specified equinox is not a Time object') | |
| if self._obstime is not None and not isinstance(self._obstime, Time): | |
| raise TypeError('specified obstime is not None or a Time object') | |
| if not self._equinox.isscalar: | |
| raise ValueError('specified equinox is not a scalar') | |
| if len(args) == 1 and len(kwargs) == 0 and isinstance(args[0], SphericalCoordinatesBase): | |
| newcoord = args[0].transform_to(self.__class__) | |
| self._latangle = newcoord._latangle | |
| self._lonangle = newcoord._lonangle | |
| self._distance = newcoord._distance | |
| else: | |
| > super(FK5, self)._initialize_latlon('ra', 'dec', args, kwargs) | |
| /Users/adam/repos/astropy/astropy/coordinates/builtin_systems.py:140: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x109e794d0>, lonname = 'ra' | |
| latname = 'dec', initargs = (), initkwargs = {} | |
| def _initialize_latlon(self, lonname, latname, initargs, initkwargs): | |
| """ | |
| Subclasses should use this to initialize standard lat/lon-style | |
| coordinates. | |
| This recognizes both the lat/lon style and the cartesian form. | |
| Parameters | |
| ---------- | |
| lonname : str | |
| The name of the longitude-like coordinate attribute | |
| latname : str | |
| The name of the latitude-like coordinate attribute | |
| initargs : list | |
| The ``*args`` from the initializer | |
| initkwargs : dict | |
| The ``**kwargs`` from the initializer | |
| """ | |
| initkwargs = dict(initkwargs) # copy | |
| nargs = len(initargs) | |
| sclsnm = self.__class__.__name__ | |
| if nargs == 1: | |
| if isinstance(initargs[0], CartesianPoints): | |
| initkwargs['cartpoint'] = initargs[0] | |
| else: | |
| initkwargs['coordstr'] = initargs[0] | |
| if nargs > 1: | |
| if lonname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, lonname)) | |
| initkwargs[lonname] = initargs[0] | |
| if nargs >= 2: | |
| if latname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, latname)) | |
| initkwargs[latname] = initargs[1] | |
| if nargs > 2: | |
| raise TypeError('{0} takes up to 2 positional arguments ' | |
| '({1} given)'.format(sclsnm, len(initargs))) | |
| unit = initkwargs.pop('unit', None) | |
| coordstr = initkwargs.pop('coordstr', None) | |
| lonval = initkwargs.pop(lonname, None) | |
| latval = initkwargs.pop(latname, None) | |
| distval = initkwargs.pop('distance', None) | |
| cartpoint = initkwargs.pop('cartpoint', None) | |
| x = initkwargs.pop('x', None) | |
| y = initkwargs.pop('y', None) | |
| z = initkwargs.pop('z', None) | |
| if len(initkwargs) > 0: | |
| raise TypeError('{0} got unexpected keyword argument' | |
| ' {1}'.format(sclsnm, initkwargs.keys())) | |
| angleinit = ((lonval is not None and latval is not None) or | |
| coordstr is not None) | |
| cartinit = ((x is not None and y is not None and z is not None) or | |
| cartpoint is not None) | |
| if angleinit and not cartinit: | |
| # lat/lon-style initialization | |
| for v in [x, y, z, cartpoint]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| try: | |
| # this raises a TypeError if `unit` is not None or iterable | |
| units = [None, None] if unit is None else list(unit) | |
| except TypeError: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a ' | |
| 'non-sequence {1}'.format(sclsnm, unit)) | |
| if len(units) == 2: | |
| try: | |
| if units[0] is not None: | |
| units[0] = u.Unit(units[0]) | |
| if units[1] is not None: | |
| units[1] = u.Unit(units[1]) | |
| except ValueError: | |
| raise ValueError('Could not convert units to unit objects ' | |
| 'while initializing ' + sclsnm) | |
| else: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a sequence ' | |
| 'of {1}.'.format(sclsnm, len(units))) | |
| if coordstr is not None: | |
| # need to try to parse the coordinate from a single argument | |
| # populates latval and lonval variables, which then get made | |
| # into coordinates below | |
| if isinstance(coordstr, six.string_types): | |
| if "," in coordstr: | |
| lonval, latval = coordstr.split(",") | |
| else: | |
| coosplit = coordstr.split() | |
| if len(coosplit) == 6: | |
| lonval = " ".join(coosplit[0:3]) | |
| latval = " ".join(coosplit[3:]) | |
| elif len(coosplit) == 2: | |
| lonval, latval = coosplit | |
| else: | |
| msg = ("Could not parse {lonname}/{latname} values " | |
| "from the string provided: '{coordstr}'.") | |
| raise ValueError(msg.format(lonname=lonname, | |
| latname=latname, | |
| coordstr=coordstr)) | |
| else: | |
| raise ValueError("A {0} cannot be created with a single value of type " | |
| "'{1}', must be a string.".format(sclsnm, type(coordstr).__name__)) | |
| # now actually create the angle objects | |
| lonang = Longitude(lonval, unit=units[0]) | |
| latang = Latitude(latval, unit=units[1]) | |
| dist = None if distval is None else Distance(distval) # copy | |
| elif cartinit and not angleinit: | |
| # cartesian-style initialization | |
| for v in [coordstr, lonval, latval, distval]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| if cartpoint is not None: | |
| for v in [x, y, z, unit]: | |
| if v is not None: | |
| raise ValueError('Cannot give both a CartesianPoints ' | |
| 'and x/y/z/unit parameters while ' | |
| 'initializing ' + sclsnm) | |
| x = cartpoint.x | |
| y = cartpoint.y | |
| z = cartpoint.z | |
| unit = cartpoint.unit | |
| > r, latval, lonval = cartesian_to_spherical(x, y, z) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:235: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| x = <CartesianPoints 0.017083352278353055>, y = <CartesianPoints 0.15781065479713563>, z = <CartesianPoints -0.9873216073334123> | |
| x : scalar or array-like | |
| The first cartesian coordinate. | |
| y : scalar or array-like | |
| The second cartesian coordinate. | |
| z : scalar or array-like | |
| The third cartesian coordinate. | |
| Returns | |
| ------- | |
| r : float or array | |
| The radial coordinate (in the same units as the inputs). | |
| lat : float or array | |
| The latitude in radians | |
| lon : float or array | |
| The longitude in radians | |
| """ | |
| xsq = x ** 2 | |
| ysq = y ** 2 | |
| zsq = z ** 2 | |
| r = (xsq + ysq + zsq) ** 0.5 | |
| s = (xsq + ysq) ** 0.5 | |
| if np.isscalar(x) and np.isscalar(y) and np.isscalar(z): | |
| lon = math.atan2(y, x) | |
| lat = math.atan2(z, s) | |
| else: | |
| lon = np.arctan2(y, x) | |
| lat = np.arctan2(z, s) | |
| return r, lat, lon | |
| def spherical_to_cartesian(r, lat, lon): | |
| """ | |
| Converts spherical polar coordinates to rectangular cartesian | |
| coordinates. | |
| Note that the input angles should be in latitude/longitude or | |
| elevation/azimuthal form. I.e., the origin is along the equator | |
| rather than at the north pole. | |
| .. note:: | |
| This is a low-level function used internally in | |
| > `astropy.coordinates`. It is provided for users if they really | |
| want to use it, but it is recommended that you use the | |
| `astropy.coordinates` coordinate systems. | |
| Parameters | |
| ---------- | |
| r : scalar or array-like | |
| The radial coordinate (in the same units as the inputs). | |
| lat : scalar or array-like | |
| The latitude in radians | |
| lon : scalar or array-like | |
| The longitude in radians | |
| Returns | |
| ------- | |
| x : float or array | |
| The first cartesian coordinate. | |
| y : float or array | |
| The second cartesian coordinate. | |
| z : float or array | |
| The third cartesian coordinate. | |
| """ | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:441: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints 0.15781065479713563>, obj = array(2.315841784746324e+77) | |
| context = (<ufunc 'arctan2'>, (<CartesianPoints 0.15781065479713563>, <CartesianPoints 0.017083352278353055>), 0) | |
| raise TypeError("The value must be a valid Python or " | |
| "Numpy numeric type.") | |
| # by default, cast any integer, boolean, etc., to float | |
| if dtype is None and not np.can_cast(np.float32, value.dtype): | |
| value = value.astype(np.float) | |
| value = value.view(cls) | |
| value._unit = unit | |
| return value | |
| def __array_finalize__(self, obj): | |
| self._unit = getattr(obj, '_unit', None) | |
| def __array_prepare__(self, obj, context=None): | |
| # This method gets called by Numpy whenever a ufunc is called on the | |
| # array. The object passed in ``obj`` is an empty version of the | |
| # output array which we can e.g. change to an array sub-class, add | |
| # attributes to, etc. After this is called, then the ufunc is called | |
| # and the values in this empty array are set. | |
| # If no context is set, just return the input | |
| if context is None: | |
| return obj | |
| # Find out which ufunc is being used | |
| function = context[0] | |
| from .quantity_helper import UNSUPPORTED_UFUNCS, UFUNC_HELPERS | |
| # Check whether we even support this ufunc | |
| if function in UNSUPPORTED_UFUNCS: | |
| raise TypeError("Cannot use function '{0}' with quantities" | |
| .format(function.__name__)) | |
| # Now find out what arguments were passed to the ufunc, usually, this | |
| # will include at least the present object, and another, which could | |
| # be a Quantity, or a Numpy array, etc. when using two-argument ufuncs. | |
| args = context[1][:function.nin] | |
| units = [getattr(arg, 'unit', None) for arg in args] | |
| # If the ufunc is supported, then we call a helper function (defined | |
| # in quantity_helper.py) which returns the scale by which the inputs | |
| # should be multiplied before being passed to the ufunc, as well as | |
| # the unit the output from the ufunc will have. | |
| if function in UFUNC_HELPERS: | |
| scales, result_unit = UFUNC_HELPERS[function](function, *units) | |
| else: | |
| raise TypeError("Unknown ufunc {0}. Please raise issue on " | |
| "https://github.com/astropy/astropy" | |
| .format(function.__name__)) | |
| if any(scale == 0. for scale in scales): | |
| # for two-argument ufuncs with a quantity and a non-quantity, | |
| # the quantity normally needs to be dimensionless, *except* | |
| # if the non-quantity can have arbitrary unit, i.e., when it | |
| # is all zero, infinity or NaN. In that case, the non-quantity | |
| # can just have the unit of the quantity | |
| # (this allows, e.g., `q > 0.` independent of unit) | |
| maybe_arbitrary_arg = args[scales.index(0.)] | |
| if _can_have_arbitrary_unit(maybe_arbitrary_arg): | |
| scales = [1., 1.] | |
| else: | |
| raise UnitsError("Can only apply '{0}' function to " | |
| "dimensionless quantities when other " | |
| "argument is not a quantity (unless the " | |
| "latter is all zero/infinity/nan)" | |
| .format(function.__name__)) | |
| # In the case of np.power, the unit itself needs to be modified by an | |
| # amount that depends on one of the input values, so we need to treat | |
| # this as a special case. | |
| # TODO: find a better way to deal with this case | |
| if function is np.power and result_unit is not None: | |
| if units[1] is None: | |
| p = args[1] | |
| else: | |
| p = args[1].to(dimensionless_unscaled).value | |
| result_unit = result_unit ** validate_power(p) | |
| # We now prepare the output object | |
| if self is obj: # happens if the output object is self, which happens | |
| # for in-place operations such as q1 += q2 | |
| # In some cases, the result of a ufunc should be a plain Numpy | |
| # array, which we can't do if we are doing an in-place operation. | |
| if result_unit is None: | |
| raise TypeError("Cannot store non-quantity output from {0} " | |
| "function in Quantity object" | |
| .format(function.__name__)) | |
| /Users/adam/repos/astropy/astropy/units/quantity.py:311: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints 0.15781065479713563>, obj = array(2.315841784746324e+77), unit = Unit("rad") | |
| #screw up the units are killed by _convert_to_and_validate_length_unit | |
| obj = super(CartesianPoints, self).__array_wrap__(obj, context=context) | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:310: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = AssertionError(), args = (), f = <py._code.code.Frame object at 0x10825bed0> | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| > ??? | |
| _pytest.assertion.reinterpret:40: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| frame = <py._code.code.Frame object at 0x10825bed0>, should_fail = True | |
| > ??? | |
| _pytest.assertion.newinterpret:46: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| filename = '<unknown>', mode = 'exec' | |
| def parse(source, filename='<unknown>', mode='exec'): | |
| """ | |
| Parse the source into an AST node. | |
| Equivalent to compile(source, filename, mode, PyCF_ONLY_AST). | |
| """ | |
| > return compile(source, filename, mode, PyCF_ONLY_AST) | |
| E File "<unknown>", line 1 | |
| E .. note:: | |
| E ^ | |
| E SyntaxError: invalid syntax | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py:37: SyntaxError | |
| ________________________________________________________ test_get_frame_coordinates[coordinates3-FK5] _________________________________________________________ | |
| coordinates = <FK5 RA=83.82207 deg, Dec=-80.86667 deg>, expected_frame = 'FK5' | |
| @pytest.mark.parametrize(('coordinates', 'expected_frame'), | |
| [(GALACTIC_COORDS, 'GAL'), | |
| (ICRS_COORDS, 'ICRS'), | |
| (FK4_COORDS, 'FK4'), | |
| (FK5_COORDS, 'FK5') | |
| ]) | |
| def test_get_frame_coordinates(coordinates, expected_frame): | |
| > actual_frame = simbad.core._get_frame_coords(coordinates)[2] | |
| astroquery/simbad/tests/test_simbad.py:97: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| c = <FK5 RA=83.82207 deg, Dec=-80.86667 deg> | |
| def _get_frame_coords(c): | |
| > if c.icrs == c: | |
| astroquery/simbad/core.py:695: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <FK5 RA=83.82207 deg, Dec=-80.86667 deg>, name = 'icrs' | |
| def __getattr__(self, name): | |
| """ | |
| Overrides getattr to return coordinates that this can be transformed | |
| to, based on the alias name in the master transform graph. | |
| """ | |
| from .transformations import master_transform_graph | |
| nmsys = master_transform_graph.lookup_name(name) | |
| if self.__class__ is nmsys: | |
| return self | |
| if nmsys is not None and self.is_transformable_to(nmsys): | |
| > return self.transform_to(nmsys) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:659: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <FK5 RA=83.82207 deg, Dec=-80.86667 deg>, tosys = <class 'astropy.coordinates.builtin_systems.ICRS'> | |
| def transform_to(self, tosys): | |
| """ | |
| Transform this coordinate to a new system. | |
| Parameters | |
| ---------- | |
| tosys : class | |
| The system to transform this coordinate into. | |
| Returns | |
| ------- | |
| transcoord | |
| A new object with this coordinate represented in the | |
| ``tosys`` system. | |
| Raises | |
| ------ | |
| ValueError | |
| If there is no possible transformation route. | |
| """ | |
| from .transformations import master_transform_graph | |
| from .errors import ConvertError | |
| if tosys is self.__class__: | |
| return copy.deepcopy(self) | |
| trans = master_transform_graph.get_transform(self.__class__, tosys) | |
| if trans is None: | |
| raise ConvertError('Cannot transform from {0} to ' | |
| '{1}'.format(self.__class__, tosys)) | |
| > return trans(self) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:622: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.DynamicMatrixTransform object at 0x1067c5390>, fromcoord = <FK5 RA=83.82207 deg, Dec=-80.86667 deg> | |
| super(DynamicMatrixTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| c = fromcoord.cartesian | |
| v = c.reshape((3, c.size // 3)) | |
| v2 = np.dot(np.asarray(self.matrix_func(fromcoord)), v) | |
| subshape = c.shape[1:] | |
| x = v2[0].reshape(subshape) | |
| y = v2[1].reshape(subshape) | |
| z = v2[2].reshape(subshape) | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:708: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'ICRS' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x109489488>, args = () | |
| kwargs = {'unit': None, 'x': <CartesianPoints 0.01708218844397828>, 'y': <CartesianPoints 0.15781069037526652>, 'z': <CartesianPoints -0.9873216217835231>} | |
| def __init__(self, *args, **kwargs): | |
| super(ICRS, self).__init__() | |
| self._obstime = kwargs.pop('obstime', None) | |
| if self._obstime is not None and not isinstance(self._obstime, Time): | |
| raise TypeError('specified obstime is not None or a Time object') | |
| if len(args) == 1 and len(kwargs) == 0 and isinstance(args[0], SphericalCoordinatesBase): | |
| newcoord = args[0].transform_to(self.__class__) | |
| self._latangle = newcoord._latangle | |
| self._lonangle = newcoord._lonangle | |
| self._distance = newcoord._distance | |
| else: | |
| > super(ICRS, self)._initialize_latlon('ra', 'dec', args, kwargs) | |
| /Users/adam/repos/astropy/astropy/coordinates/builtin_systems.py:72: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'ICRS' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x108258368>, lonname = 'ra' | |
| latname = 'dec', initargs = (), initkwargs = {} | |
| def _initialize_latlon(self, lonname, latname, initargs, initkwargs): | |
| """ | |
| Subclasses should use this to initialize standard lat/lon-style | |
| coordinates. | |
| This recognizes both the lat/lon style and the cartesian form. | |
| Parameters | |
| ---------- | |
| lonname : str | |
| The name of the longitude-like coordinate attribute | |
| latname : str | |
| The name of the latitude-like coordinate attribute | |
| initargs : list | |
| The ``*args`` from the initializer | |
| initkwargs : dict | |
| The ``**kwargs`` from the initializer | |
| """ | |
| initkwargs = dict(initkwargs) # copy | |
| nargs = len(initargs) | |
| sclsnm = self.__class__.__name__ | |
| if nargs == 1: | |
| if isinstance(initargs[0], CartesianPoints): | |
| initkwargs['cartpoint'] = initargs[0] | |
| else: | |
| initkwargs['coordstr'] = initargs[0] | |
| if nargs > 1: | |
| if lonname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, lonname)) | |
| initkwargs[lonname] = initargs[0] | |
| if nargs >= 2: | |
| if latname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, latname)) | |
| initkwargs[latname] = initargs[1] | |
| if nargs > 2: | |
| raise TypeError('{0} takes up to 2 positional arguments ' | |
| '({1} given)'.format(sclsnm, len(initargs))) | |
| unit = initkwargs.pop('unit', None) | |
| coordstr = initkwargs.pop('coordstr', None) | |
| lonval = initkwargs.pop(lonname, None) | |
| latval = initkwargs.pop(latname, None) | |
| distval = initkwargs.pop('distance', None) | |
| cartpoint = initkwargs.pop('cartpoint', None) | |
| x = initkwargs.pop('x', None) | |
| y = initkwargs.pop('y', None) | |
| z = initkwargs.pop('z', None) | |
| if len(initkwargs) > 0: | |
| raise TypeError('{0} got unexpected keyword argument' | |
| ' {1}'.format(sclsnm, initkwargs.keys())) | |
| angleinit = ((lonval is not None and latval is not None) or | |
| coordstr is not None) | |
| cartinit = ((x is not None and y is not None and z is not None) or | |
| cartpoint is not None) | |
| if angleinit and not cartinit: | |
| # lat/lon-style initialization | |
| for v in [x, y, z, cartpoint]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| try: | |
| # this raises a TypeError if `unit` is not None or iterable | |
| units = [None, None] if unit is None else list(unit) | |
| except TypeError: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a ' | |
| 'non-sequence {1}'.format(sclsnm, unit)) | |
| if len(units) == 2: | |
| try: | |
| if units[0] is not None: | |
| units[0] = u.Unit(units[0]) | |
| if units[1] is not None: | |
| units[1] = u.Unit(units[1]) | |
| except ValueError: | |
| raise ValueError('Could not convert units to unit objects ' | |
| 'while initializing ' + sclsnm) | |
| else: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a sequence ' | |
| 'of {1}.'.format(sclsnm, len(units))) | |
| if coordstr is not None: | |
| # need to try to parse the coordinate from a single argument | |
| # populates latval and lonval variables, which then get made | |
| # into coordinates below | |
| if isinstance(coordstr, six.string_types): | |
| if "," in coordstr: | |
| lonval, latval = coordstr.split(",") | |
| else: | |
| coosplit = coordstr.split() | |
| if len(coosplit) == 6: | |
| lonval = " ".join(coosplit[0:3]) | |
| latval = " ".join(coosplit[3:]) | |
| elif len(coosplit) == 2: | |
| lonval, latval = coosplit | |
| else: | |
| msg = ("Could not parse {lonname}/{latname} values " | |
| "from the string provided: '{coordstr}'.") | |
| raise ValueError(msg.format(lonname=lonname, | |
| latname=latname, | |
| coordstr=coordstr)) | |
| else: | |
| raise ValueError("A {0} cannot be created with a single value of type " | |
| "'{1}', must be a string.".format(sclsnm, type(coordstr).__name__)) | |
| # now actually create the angle objects | |
| lonang = Longitude(lonval, unit=units[0]) | |
| latang = Latitude(latval, unit=units[1]) | |
| dist = None if distval is None else Distance(distval) # copy | |
| elif cartinit and not angleinit: | |
| # cartesian-style initialization | |
| for v in [coordstr, lonval, latval, distval]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| if cartpoint is not None: | |
| for v in [x, y, z, unit]: | |
| if v is not None: | |
| raise ValueError('Cannot give both a CartesianPoints ' | |
| 'and x/y/z/unit parameters while ' | |
| 'initializing ' + sclsnm) | |
| x = cartpoint.x | |
| y = cartpoint.y | |
| z = cartpoint.z | |
| unit = cartpoint.unit | |
| > r, latval, lonval = cartesian_to_spherical(x, y, z) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:235: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| x = <CartesianPoints 0.01708218844397828>, y = <CartesianPoints 0.15781069037526652>, z = <CartesianPoints -0.9873216217835231> | |
| x : scalar or array-like | |
| The first cartesian coordinate. | |
| y : scalar or array-like | |
| The second cartesian coordinate. | |
| z : scalar or array-like | |
| The third cartesian coordinate. | |
| Returns | |
| ------- | |
| r : float or array | |
| The radial coordinate (in the same units as the inputs). | |
| lat : float or array | |
| The latitude in radians | |
| lon : float or array | |
| The longitude in radians | |
| """ | |
| xsq = x ** 2 | |
| ysq = y ** 2 | |
| zsq = z ** 2 | |
| r = (xsq + ysq + zsq) ** 0.5 | |
| s = (xsq + ysq) ** 0.5 | |
| if np.isscalar(x) and np.isscalar(y) and np.isscalar(z): | |
| lon = math.atan2(y, x) | |
| lat = math.atan2(z, s) | |
| else: | |
| lon = np.arctan2(y, x) | |
| lat = np.arctan2(z, s) | |
| return r, lat, lon | |
| def spherical_to_cartesian(r, lat, lon): | |
| """ | |
| Converts spherical polar coordinates to rectangular cartesian | |
| coordinates. | |
| Note that the input angles should be in latitude/longitude or | |
| elevation/azimuthal form. I.e., the origin is along the equator | |
| rather than at the north pole. | |
| .. note:: | |
| This is a low-level function used internally in | |
| > `astropy.coordinates`. It is provided for users if they really | |
| want to use it, but it is recommended that you use the | |
| `astropy.coordinates` coordinate systems. | |
| Parameters | |
| ---------- | |
| r : scalar or array-like | |
| The radial coordinate (in the same units as the inputs). | |
| lat : scalar or array-like | |
| The latitude in radians | |
| lon : scalar or array-like | |
| The longitude in radians | |
| Returns | |
| ------- | |
| x : float or array | |
| The first cartesian coordinate. | |
| y : float or array | |
| The second cartesian coordinate. | |
| z : float or array | |
| The third cartesian coordinate. | |
| """ | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:441: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints 0.15781069037526652>, obj = array(2.315841784746324e+77) | |
| context = (<ufunc 'arctan2'>, (<CartesianPoints 0.15781069037526652>, <CartesianPoints 0.01708218844397828>), 0) | |
| raise TypeError("The value must be a valid Python or " | |
| "Numpy numeric type.") | |
| # by default, cast any integer, boolean, etc., to float | |
| if dtype is None and not np.can_cast(np.float32, value.dtype): | |
| value = value.astype(np.float) | |
| value = value.view(cls) | |
| value._unit = unit | |
| return value | |
| def __array_finalize__(self, obj): | |
| self._unit = getattr(obj, '_unit', None) | |
| def __array_prepare__(self, obj, context=None): | |
| # This method gets called by Numpy whenever a ufunc is called on the | |
| # array. The object passed in ``obj`` is an empty version of the | |
| # output array which we can e.g. change to an array sub-class, add | |
| # attributes to, etc. After this is called, then the ufunc is called | |
| # and the values in this empty array are set. | |
| # If no context is set, just return the input | |
| if context is None: | |
| return obj | |
| # Find out which ufunc is being used | |
| function = context[0] | |
| from .quantity_helper import UNSUPPORTED_UFUNCS, UFUNC_HELPERS | |
| # Check whether we even support this ufunc | |
| if function in UNSUPPORTED_UFUNCS: | |
| raise TypeError("Cannot use function '{0}' with quantities" | |
| .format(function.__name__)) | |
| # Now find out what arguments were passed to the ufunc, usually, this | |
| # will include at least the present object, and another, which could | |
| # be a Quantity, or a Numpy array, etc. when using two-argument ufuncs. | |
| args = context[1][:function.nin] | |
| units = [getattr(arg, 'unit', None) for arg in args] | |
| # If the ufunc is supported, then we call a helper function (defined | |
| # in quantity_helper.py) which returns the scale by which the inputs | |
| # should be multiplied before being passed to the ufunc, as well as | |
| # the unit the output from the ufunc will have. | |
| if function in UFUNC_HELPERS: | |
| scales, result_unit = UFUNC_HELPERS[function](function, *units) | |
| else: | |
| raise TypeError("Unknown ufunc {0}. Please raise issue on " | |
| "https://github.com/astropy/astropy" | |
| .format(function.__name__)) | |
| if any(scale == 0. for scale in scales): | |
| # for two-argument ufuncs with a quantity and a non-quantity, | |
| # the quantity normally needs to be dimensionless, *except* | |
| # if the non-quantity can have arbitrary unit, i.e., when it | |
| # is all zero, infinity or NaN. In that case, the non-quantity | |
| # can just have the unit of the quantity | |
| # (this allows, e.g., `q > 0.` independent of unit) | |
| maybe_arbitrary_arg = args[scales.index(0.)] | |
| if _can_have_arbitrary_unit(maybe_arbitrary_arg): | |
| scales = [1., 1.] | |
| else: | |
| raise UnitsError("Can only apply '{0}' function to " | |
| "dimensionless quantities when other " | |
| "argument is not a quantity (unless the " | |
| "latter is all zero/infinity/nan)" | |
| .format(function.__name__)) | |
| # In the case of np.power, the unit itself needs to be modified by an | |
| # amount that depends on one of the input values, so we need to treat | |
| # this as a special case. | |
| # TODO: find a better way to deal with this case | |
| if function is np.power and result_unit is not None: | |
| if units[1] is None: | |
| p = args[1] | |
| else: | |
| p = args[1].to(dimensionless_unscaled).value | |
| result_unit = result_unit ** validate_power(p) | |
| # We now prepare the output object | |
| if self is obj: # happens if the output object is self, which happens | |
| # for in-place operations such as q1 += q2 | |
| # In some cases, the result of a ufunc should be a plain Numpy | |
| # array, which we can't do if we are doing an in-place operation. | |
| if result_unit is None: | |
| raise TypeError("Cannot store non-quantity output from {0} " | |
| "function in Quantity object" | |
| .format(function.__name__)) | |
| /Users/adam/repos/astropy/astropy/units/quantity.py:311: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints 0.15781069037526652>, obj = array(2.315841784746324e+77), unit = Unit("rad") | |
| #screw up the units are killed by _convert_to_and_validate_length_unit | |
| obj = super(CartesianPoints, self).__array_wrap__(obj, context=context) | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:310: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = AssertionError(), args = (), f = <py._code.code.Frame object at 0x11988bb10> | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| > ??? | |
| _pytest.assertion.reinterpret:40: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| frame = <py._code.code.Frame object at 0x11988bb10>, should_fail = True | |
| > ??? | |
| _pytest.assertion.newinterpret:46: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| filename = '<unknown>', mode = 'exec' | |
| def parse(source, filename='<unknown>', mode='exec'): | |
| """ | |
| Parse the source into an AST node. | |
| Equivalent to compile(source, filename, mode, PyCF_ONLY_AST). | |
| """ | |
| > return compile(source, filename, mode, PyCF_ONLY_AST) | |
| E File "<unknown>", line 1 | |
| E .. note:: | |
| E ^ | |
| E SyntaxError: invalid syntax | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py:37: SyntaxError | |
| _________________________________________________ test_query_region_async[coordinates1-radius1-2000.0-J2000] __________________________________________________ | |
| patch_post = <_pytest.monkeypatch.monkeypatch instance at 0x10ac627e8>, coordinates = <Galactic l=292.97916 deg, b=-29.75447 deg>, radius = <Quantity 5.0 deg> | |
| equinox = 2000.0, epoch = 'J2000' | |
| @pytest.mark.parametrize(('coordinates', 'radius', 'equinox', 'epoch'), | |
| [(ICRS_COORDS, None, None, None), | |
| (GALACTIC_COORDS, 5 * u.deg, 2000.0, 'J2000'), | |
| (FK4_COORDS, '5d0m0s', None, None), | |
| (FK5_COORDS, None, None, None) | |
| ]) | |
| def test_query_region_async(patch_post, coordinates, radius, equinox, epoch): | |
| response1 = simbad.core.Simbad.query_region_async(coordinates, radius=radius, | |
| > equinox=equinox, epoch=epoch) | |
| astroquery/simbad/tests/test_simbad.py:212: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.simbad.core.SimbadClass object at 0x107c40e50>, coordinates = <Galactic l=292.97916 deg, b=-29.75447 deg>, radius = <Quantity 5.0 deg> | |
| equinox = 2000.0, epoch = 'J2000' | |
| def query_region_async(self, coordinates, radius=None, equinox=None, | |
| epoch=None): | |
| """ | |
| Serves the same function as `query_region`, but | |
| only collects the reponse from the Simbad server and returns. | |
| Parameters | |
| ---------- | |
| coordinates : str/`astropy.coordinates` | |
| the identifier or coordinates around which to query. | |
| radius : str/`~astropy.units.Quantity`, optional | |
| the radius of the region. If missing, set to default | |
| value of 20 arcmin. | |
| equinox : float, optional | |
| the equinox of the coordinates. If missing set to | |
| default 2000.0. | |
| epoch : str, optional | |
| the epoch of the input coordiantes. Must be specified as | |
| [J|B] <epoch>. If missing, set to default J2000. | |
| Returns | |
| ------- | |
| response : `requests.Response` | |
| Response of the query from the server. | |
| """ | |
| request_payload = self._args_to_payload(coordinates, radius=radius, | |
| equinox=equinox, epoch=epoch, | |
| > caller='query_region_async') | |
| astroquery/simbad/core.py:469: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| args = (<astroquery.simbad.core.SimbadClass object at 0x107c40e50>, <Galactic l=292.97916 deg, b=-29.75447 deg>) | |
| kwargs = {'caller': 'query_region_async', 'epoch': 'J2000', 'equinox': 2000.0, 'radius': <Quantity 5.0 deg>}, value = 'J2000' | |
| p = <_sre.SRE_Pattern object at 0x109db8060> | |
| def wrapper(*args, **kwargs): | |
| if kwargs.get('epoch'): | |
| value = kwargs['epoch'] | |
| try: | |
| p = re.compile('^[JB]\d+[.]?\d+$', re.IGNORECASE) | |
| assert p.match(value) is not None | |
| except (AssertionError, TypeError): | |
| raise ValueError("Epoch must be specified as [J|B]<epoch>.\n" | |
| "Example: epoch='J2000'") | |
| > return func(*args, **kwargs) | |
| astroquery/simbad/core.py:43: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| args = (<astroquery.simbad.core.SimbadClass object at 0x107c40e50>, <Galactic l=292.97916 deg, b=-29.75447 deg>) | |
| kwargs = {'caller': 'query_region_async', 'epoch': 'J2000', 'equinox': 2000.0, 'radius': <Quantity 5.0 deg>}, value = 2000.0 | |
| def wrapper(*args, **kwargs): | |
| if kwargs.get('equinox'): | |
| value = kwargs['equinox'] | |
| try: | |
| float(value) | |
| except ValueError: | |
| raise ValueError("Equinox must be a number") | |
| > return func(*args, **kwargs) | |
| astroquery/simbad/core.py:59: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.simbad.core.SimbadClass object at 0x107c40e50>, args = (), kwargs = {'epoch': 'J2000', 'equinox': 2000.0, 'radius': <Quantity 5.0 deg>} | |
| script = '\nvotable {main_id,coordinates}\nvotable open\nquery coo', caller = 'query_region_async', get_raw = False, command = 'query coo' | |
| votable_fields = 'main_id,coordinates', votable_def = 'votable {main_id,coordinates}', votable_open = 'votable open', votable_close = 'votable close' | |
| coordinates = <Galactic l=292.97916 deg, b=-29.75447 deg> | |
| @validate_epoch | |
| @validate_equinox | |
| def _args_to_payload(self, *args, **kwargs): | |
| """ | |
| Takes the arguments from any of the query functions | |
| and returns a dictionary that can be used as the | |
| data for an HTTP POST request. | |
| """ | |
| script = "" | |
| caller = kwargs['caller'] | |
| del kwargs['caller'] | |
| get_raw = kwargs.get('get_raw', False) | |
| if get_raw: | |
| del kwargs['get_raw'] | |
| command = self._function_to_command[caller] | |
| votable_fields = ','.join(self.get_votable_fields()) | |
| # if get_raw is set then don't fetch as votable | |
| votable_def = ("votable {" + votable_fields + "}", "")[get_raw] | |
| votable_open = ("votable open", "")[get_raw] | |
| votable_close = ("votable close", "")[get_raw] | |
| if self.ROW_LIMIT > 0: | |
| script = "set limit " + str(self.ROW_LIMIT) | |
| script = "\n".join([script, votable_def, votable_open, command]) | |
| if kwargs.get('wildcard'): | |
| script += " wildcard" # necessary to have a space at the beginning | |
| del kwargs['wildcard'] | |
| # now append args and kwds as per the caller | |
| # if caller is query_region_async write coordinates as separate ra dec | |
| if caller == 'query_region_async': | |
| coordinates = args[0] | |
| args = args[1:] | |
| > ra, dec, frame = _parse_coordinates(coordinates) | |
| astroquery/simbad/core.py:635: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| coordinates = <Galactic l=292.97916 deg, b=-29.75447 deg> | |
| def _parse_coordinates(coordinates): | |
| try: | |
| c = commons.parse_coordinates(coordinates) | |
| # now c has some subclass of astropy.coordinate | |
| # get ra, dec and frame | |
| > return _get_frame_coords(c) | |
| astroquery/simbad/core.py:689: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| c = <Galactic l=292.97916 deg, b=-29.75447 deg> | |
| def _get_frame_coords(c): | |
| > if c.icrs == c: | |
| astroquery/simbad/core.py:695: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <Galactic l=292.97916 deg, b=-29.75447 deg>, name = 'icrs' | |
| def __getattr__(self, name): | |
| """ | |
| Overrides getattr to return coordinates that this can be transformed | |
| to, based on the alias name in the master transform graph. | |
| """ | |
| from .transformations import master_transform_graph | |
| nmsys = master_transform_graph.lookup_name(name) | |
| if self.__class__ is nmsys: | |
| return self | |
| if nmsys is not None and self.is_transformable_to(nmsys): | |
| > return self.transform_to(nmsys) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:659: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <Galactic l=292.97916 deg, b=-29.75447 deg>, tosys = <class 'astropy.coordinates.builtin_systems.ICRS'> | |
| def transform_to(self, tosys): | |
| """ | |
| Transform this coordinate to a new system. | |
| Parameters | |
| ---------- | |
| tosys : class | |
| The system to transform this coordinate into. | |
| Returns | |
| ------- | |
| transcoord | |
| A new object with this coordinate represented in the | |
| ``tosys`` system. | |
| Raises | |
| ------ | |
| ValueError | |
| If there is no possible transformation route. | |
| """ | |
| from .transformations import master_transform_graph | |
| from .errors import ConvertError | |
| if tosys is self.__class__: | |
| return copy.deepcopy(self) | |
| trans = master_transform_graph.get_transform(self.__class__, tosys) | |
| if trans is None: | |
| raise ConvertError('Cannot transform from {0} to ' | |
| '{1}'.format(self.__class__, tosys)) | |
| > return trans(self) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:622: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.CompositeTransform object at 0x10968f750>, fromcoord = <Galactic l=292.97916 deg, b=-29.75447 deg> | |
| super(CompositeTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| > coord = fromcoord | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:742: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.DynamicMatrixTransform object at 0x1067c5990>, fromcoord = <Galactic l=292.97916 deg, b=-29.75447 deg> | |
| super(DynamicMatrixTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| c = fromcoord.cartesian | |
| v = c.reshape((3, c.size // 3)) | |
| v2 = np.dot(np.asarray(self.matrix_func(fromcoord)), v) | |
| subshape = c.shape[1:] | |
| x = v2[0].reshape(subshape) | |
| y = v2[1].reshape(subshape) | |
| z = v2[2].reshape(subshape) | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:708: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x109691a70>, args = () | |
| kwargs = {'unit': None, 'x': <CartesianPoints 0.0170822506606243>, 'y': <CartesianPoints 0.15781058025053168>, 'z': <CartesianPoints -0.9873216383090963>} | |
| def __init__(self, *args, **kwargs): | |
| super(FK5, self).__init__() | |
| self._equinox = kwargs.pop('equinox', _EQUINOX_J2000) | |
| self._obstime = kwargs.pop('obstime', None) | |
| if not isinstance(self._equinox, Time): | |
| raise TypeError('specified equinox is not a Time object') | |
| if self._obstime is not None and not isinstance(self._obstime, Time): | |
| raise TypeError('specified obstime is not None or a Time object') | |
| if not self._equinox.isscalar: | |
| raise ValueError('specified equinox is not a scalar') | |
| if len(args) == 1 and len(kwargs) == 0 and isinstance(args[0], SphericalCoordinatesBase): | |
| newcoord = args[0].transform_to(self.__class__) | |
| self._latangle = newcoord._latangle | |
| self._lonangle = newcoord._lonangle | |
| self._distance = newcoord._distance | |
| else: | |
| > super(FK5, self)._initialize_latlon('ra', 'dec', args, kwargs) | |
| /Users/adam/repos/astropy/astropy/coordinates/builtin_systems.py:140: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x10948e4d0>, lonname = 'ra' | |
| latname = 'dec', initargs = (), initkwargs = {} | |
| def _initialize_latlon(self, lonname, latname, initargs, initkwargs): | |
| """ | |
| Subclasses should use this to initialize standard lat/lon-style | |
| coordinates. | |
| This recognizes both the lat/lon style and the cartesian form. | |
| Parameters | |
| ---------- | |
| lonname : str | |
| The name of the longitude-like coordinate attribute | |
| latname : str | |
| The name of the latitude-like coordinate attribute | |
| initargs : list | |
| The ``*args`` from the initializer | |
| initkwargs : dict | |
| The ``**kwargs`` from the initializer | |
| """ | |
| initkwargs = dict(initkwargs) # copy | |
| nargs = len(initargs) | |
| sclsnm = self.__class__.__name__ | |
| if nargs == 1: | |
| if isinstance(initargs[0], CartesianPoints): | |
| initkwargs['cartpoint'] = initargs[0] | |
| else: | |
| initkwargs['coordstr'] = initargs[0] | |
| if nargs > 1: | |
| if lonname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, lonname)) | |
| initkwargs[lonname] = initargs[0] | |
| if nargs >= 2: | |
| if latname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, latname)) | |
| initkwargs[latname] = initargs[1] | |
| if nargs > 2: | |
| raise TypeError('{0} takes up to 2 positional arguments ' | |
| '({1} given)'.format(sclsnm, len(initargs))) | |
| unit = initkwargs.pop('unit', None) | |
| coordstr = initkwargs.pop('coordstr', None) | |
| lonval = initkwargs.pop(lonname, None) | |
| latval = initkwargs.pop(latname, None) | |
| distval = initkwargs.pop('distance', None) | |
| cartpoint = initkwargs.pop('cartpoint', None) | |
| x = initkwargs.pop('x', None) | |
| y = initkwargs.pop('y', None) | |
| z = initkwargs.pop('z', None) | |
| if len(initkwargs) > 0: | |
| raise TypeError('{0} got unexpected keyword argument' | |
| ' {1}'.format(sclsnm, initkwargs.keys())) | |
| angleinit = ((lonval is not None and latval is not None) or | |
| coordstr is not None) | |
| cartinit = ((x is not None and y is not None and z is not None) or | |
| cartpoint is not None) | |
| if angleinit and not cartinit: | |
| # lat/lon-style initialization | |
| for v in [x, y, z, cartpoint]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| try: | |
| # this raises a TypeError if `unit` is not None or iterable | |
| units = [None, None] if unit is None else list(unit) | |
| except TypeError: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a ' | |
| 'non-sequence {1}'.format(sclsnm, unit)) | |
| if len(units) == 2: | |
| try: | |
| if units[0] is not None: | |
| units[0] = u.Unit(units[0]) | |
| if units[1] is not None: | |
| units[1] = u.Unit(units[1]) | |
| except ValueError: | |
| raise ValueError('Could not convert units to unit objects ' | |
| 'while initializing ' + sclsnm) | |
| else: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a sequence ' | |
| 'of {1}.'.format(sclsnm, len(units))) | |
| if coordstr is not None: | |
| # need to try to parse the coordinate from a single argument | |
| # populates latval and lonval variables, which then get made | |
| # into coordinates below | |
| if isinstance(coordstr, six.string_types): | |
| if "," in coordstr: | |
| lonval, latval = coordstr.split(",") | |
| else: | |
| coosplit = coordstr.split() | |
| if len(coosplit) == 6: | |
| lonval = " ".join(coosplit[0:3]) | |
| latval = " ".join(coosplit[3:]) | |
| elif len(coosplit) == 2: | |
| lonval, latval = coosplit | |
| else: | |
| msg = ("Could not parse {lonname}/{latname} values " | |
| "from the string provided: '{coordstr}'.") | |
| raise ValueError(msg.format(lonname=lonname, | |
| latname=latname, | |
| coordstr=coordstr)) | |
| else: | |
| raise ValueError("A {0} cannot be created with a single value of type " | |
| "'{1}', must be a string.".format(sclsnm, type(coordstr).__name__)) | |
| # now actually create the angle objects | |
| lonang = Longitude(lonval, unit=units[0]) | |
| latang = Latitude(latval, unit=units[1]) | |
| dist = None if distval is None else Distance(distval) # copy | |
| elif cartinit and not angleinit: | |
| # cartesian-style initialization | |
| for v in [coordstr, lonval, latval, distval]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| if cartpoint is not None: | |
| for v in [x, y, z, unit]: | |
| if v is not None: | |
| raise ValueError('Cannot give both a CartesianPoints ' | |
| 'and x/y/z/unit parameters while ' | |
| 'initializing ' + sclsnm) | |
| x = cartpoint.x | |
| y = cartpoint.y | |
| z = cartpoint.z | |
| unit = cartpoint.unit | |
| > r, latval, lonval = cartesian_to_spherical(x, y, z) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:235: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| x = <CartesianPoints 0.0170822506606243>, y = <CartesianPoints 0.15781058025053168>, z = <CartesianPoints -0.9873216383090963> | |
| x : scalar or array-like | |
| The first cartesian coordinate. | |
| y : scalar or array-like | |
| The second cartesian coordinate. | |
| z : scalar or array-like | |
| The third cartesian coordinate. | |
| Returns | |
| ------- | |
| r : float or array | |
| The radial coordinate (in the same units as the inputs). | |
| lat : float or array | |
| The latitude in radians | |
| lon : float or array | |
| The longitude in radians | |
| """ | |
| xsq = x ** 2 | |
| ysq = y ** 2 | |
| zsq = z ** 2 | |
| r = (xsq + ysq + zsq) ** 0.5 | |
| s = (xsq + ysq) ** 0.5 | |
| if np.isscalar(x) and np.isscalar(y) and np.isscalar(z): | |
| lon = math.atan2(y, x) | |
| lat = math.atan2(z, s) | |
| else: | |
| lon = np.arctan2(y, x) | |
| lat = np.arctan2(z, s) | |
| return r, lat, lon | |
| def spherical_to_cartesian(r, lat, lon): | |
| """ | |
| Converts spherical polar coordinates to rectangular cartesian | |
| coordinates. | |
| Note that the input angles should be in latitude/longitude or | |
| elevation/azimuthal form. I.e., the origin is along the equator | |
| rather than at the north pole. | |
| .. note:: | |
| This is a low-level function used internally in | |
| > `astropy.coordinates`. It is provided for users if they really | |
| want to use it, but it is recommended that you use the | |
| `astropy.coordinates` coordinate systems. | |
| Parameters | |
| ---------- | |
| r : scalar or array-like | |
| The radial coordinate (in the same units as the inputs). | |
| lat : scalar or array-like | |
| The latitude in radians | |
| lon : scalar or array-like | |
| The longitude in radians | |
| Returns | |
| ------- | |
| x : float or array | |
| The first cartesian coordinate. | |
| y : float or array | |
| The second cartesian coordinate. | |
| z : float or array | |
| The third cartesian coordinate. | |
| """ | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:441: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints 0.15781058025053168>, obj = array(2.315841784746324e+77) | |
| context = (<ufunc 'arctan2'>, (<CartesianPoints 0.15781058025053168>, <CartesianPoints 0.0170822506606243>), 0) | |
| raise TypeError("The value must be a valid Python or " | |
| "Numpy numeric type.") | |
| # by default, cast any integer, boolean, etc., to float | |
| if dtype is None and not np.can_cast(np.float32, value.dtype): | |
| value = value.astype(np.float) | |
| value = value.view(cls) | |
| value._unit = unit | |
| return value | |
| def __array_finalize__(self, obj): | |
| self._unit = getattr(obj, '_unit', None) | |
| def __array_prepare__(self, obj, context=None): | |
| # This method gets called by Numpy whenever a ufunc is called on the | |
| # array. The object passed in ``obj`` is an empty version of the | |
| # output array which we can e.g. change to an array sub-class, add | |
| # attributes to, etc. After this is called, then the ufunc is called | |
| # and the values in this empty array are set. | |
| # If no context is set, just return the input | |
| if context is None: | |
| return obj | |
| # Find out which ufunc is being used | |
| function = context[0] | |
| from .quantity_helper import UNSUPPORTED_UFUNCS, UFUNC_HELPERS | |
| # Check whether we even support this ufunc | |
| if function in UNSUPPORTED_UFUNCS: | |
| raise TypeError("Cannot use function '{0}' with quantities" | |
| .format(function.__name__)) | |
| # Now find out what arguments were passed to the ufunc, usually, this | |
| # will include at least the present object, and another, which could | |
| # be a Quantity, or a Numpy array, etc. when using two-argument ufuncs. | |
| args = context[1][:function.nin] | |
| units = [getattr(arg, 'unit', None) for arg in args] | |
| # If the ufunc is supported, then we call a helper function (defined | |
| # in quantity_helper.py) which returns the scale by which the inputs | |
| # should be multiplied before being passed to the ufunc, as well as | |
| # the unit the output from the ufunc will have. | |
| if function in UFUNC_HELPERS: | |
| scales, result_unit = UFUNC_HELPERS[function](function, *units) | |
| else: | |
| raise TypeError("Unknown ufunc {0}. Please raise issue on " | |
| "https://github.com/astropy/astropy" | |
| .format(function.__name__)) | |
| if any(scale == 0. for scale in scales): | |
| # for two-argument ufuncs with a quantity and a non-quantity, | |
| # the quantity normally needs to be dimensionless, *except* | |
| # if the non-quantity can have arbitrary unit, i.e., when it | |
| # is all zero, infinity or NaN. In that case, the non-quantity | |
| # can just have the unit of the quantity | |
| # (this allows, e.g., `q > 0.` independent of unit) | |
| maybe_arbitrary_arg = args[scales.index(0.)] | |
| if _can_have_arbitrary_unit(maybe_arbitrary_arg): | |
| scales = [1., 1.] | |
| else: | |
| raise UnitsError("Can only apply '{0}' function to " | |
| "dimensionless quantities when other " | |
| "argument is not a quantity (unless the " | |
| "latter is all zero/infinity/nan)" | |
| .format(function.__name__)) | |
| # In the case of np.power, the unit itself needs to be modified by an | |
| # amount that depends on one of the input values, so we need to treat | |
| # this as a special case. | |
| # TODO: find a better way to deal with this case | |
| if function is np.power and result_unit is not None: | |
| if units[1] is None: | |
| p = args[1] | |
| else: | |
| p = args[1].to(dimensionless_unscaled).value | |
| result_unit = result_unit ** validate_power(p) | |
| # We now prepare the output object | |
| if self is obj: # happens if the output object is self, which happens | |
| # for in-place operations such as q1 += q2 | |
| # In some cases, the result of a ufunc should be a plain Numpy | |
| # array, which we can't do if we are doing an in-place operation. | |
| if result_unit is None: | |
| raise TypeError("Cannot store non-quantity output from {0} " | |
| "function in Quantity object" | |
| .format(function.__name__)) | |
| /Users/adam/repos/astropy/astropy/units/quantity.py:311: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints 0.15781058025053168>, obj = array(2.315841784746324e+77), unit = Unit("rad") | |
| #screw up the units are killed by _convert_to_and_validate_length_unit | |
| obj = super(CartesianPoints, self).__array_wrap__(obj, context=context) | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:310: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = AssertionError(), args = (), f = <py._code.code.Frame object at 0x1022aa290> | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| > ??? | |
| _pytest.assertion.reinterpret:40: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| frame = <py._code.code.Frame object at 0x1022aa290>, should_fail = True | |
| > ??? | |
| _pytest.assertion.newinterpret:46: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| filename = '<unknown>', mode = 'exec' | |
| def parse(source, filename='<unknown>', mode='exec'): | |
| """ | |
| Parse the source into an AST node. | |
| Equivalent to compile(source, filename, mode, PyCF_ONLY_AST). | |
| """ | |
| > return compile(source, filename, mode, PyCF_ONLY_AST) | |
| E File "<unknown>", line 1 | |
| E .. note:: | |
| E ^ | |
| E SyntaxError: invalid syntax | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py:37: SyntaxError | |
| ___________________________________________________ test_query_region_async[coordinates2-5d0m0s-None-None] ____________________________________________________ | |
| patch_post = <_pytest.monkeypatch.monkeypatch instance at 0x108245ef0>, coordinates = <FK4 RA=84.90759 deg, Dec=-80.89403 deg>, radius = '5d0m0s' | |
| equinox = None, epoch = None | |
| @pytest.mark.parametrize(('coordinates', 'radius', 'equinox', 'epoch'), | |
| [(ICRS_COORDS, None, None, None), | |
| (GALACTIC_COORDS, 5 * u.deg, 2000.0, 'J2000'), | |
| (FK4_COORDS, '5d0m0s', None, None), | |
| (FK5_COORDS, None, None, None) | |
| ]) | |
| def test_query_region_async(patch_post, coordinates, radius, equinox, epoch): | |
| response1 = simbad.core.Simbad.query_region_async(coordinates, radius=radius, | |
| > equinox=equinox, epoch=epoch) | |
| astroquery/simbad/tests/test_simbad.py:212: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.simbad.core.SimbadClass object at 0x107c40e50>, coordinates = <FK4 RA=84.90759 deg, Dec=-80.89403 deg>, radius = '5d0m0s', equinox = None | |
| epoch = None | |
| def query_region_async(self, coordinates, radius=None, equinox=None, | |
| epoch=None): | |
| """ | |
| Serves the same function as `query_region`, but | |
| only collects the reponse from the Simbad server and returns. | |
| Parameters | |
| ---------- | |
| coordinates : str/`astropy.coordinates` | |
| the identifier or coordinates around which to query. | |
| radius : str/`~astropy.units.Quantity`, optional | |
| the radius of the region. If missing, set to default | |
| value of 20 arcmin. | |
| equinox : float, optional | |
| the equinox of the coordinates. If missing set to | |
| default 2000.0. | |
| epoch : str, optional | |
| the epoch of the input coordiantes. Must be specified as | |
| [J|B] <epoch>. If missing, set to default J2000. | |
| Returns | |
| ------- | |
| response : `requests.Response` | |
| Response of the query from the server. | |
| """ | |
| request_payload = self._args_to_payload(coordinates, radius=radius, | |
| equinox=equinox, epoch=epoch, | |
| > caller='query_region_async') | |
| astroquery/simbad/core.py:469: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| args = (<astroquery.simbad.core.SimbadClass object at 0x107c40e50>, <FK4 RA=84.90759 deg, Dec=-80.89403 deg>) | |
| kwargs = {'caller': 'query_region_async', 'epoch': None, 'equinox': None, 'radius': '5d0m0s'} | |
| def wrapper(*args, **kwargs): | |
| if kwargs.get('epoch'): | |
| value = kwargs['epoch'] | |
| try: | |
| p = re.compile('^[JB]\d+[.]?\d+$', re.IGNORECASE) | |
| assert p.match(value) is not None | |
| except (AssertionError, TypeError): | |
| raise ValueError("Epoch must be specified as [J|B]<epoch>.\n" | |
| "Example: epoch='J2000'") | |
| > return func(*args, **kwargs) | |
| astroquery/simbad/core.py:43: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| args = (<astroquery.simbad.core.SimbadClass object at 0x107c40e50>, <FK4 RA=84.90759 deg, Dec=-80.89403 deg>) | |
| kwargs = {'caller': 'query_region_async', 'epoch': None, 'equinox': None, 'radius': '5d0m0s'} | |
| def wrapper(*args, **kwargs): | |
| if kwargs.get('equinox'): | |
| value = kwargs['equinox'] | |
| try: | |
| float(value) | |
| except ValueError: | |
| raise ValueError("Equinox must be a number") | |
| > return func(*args, **kwargs) | |
| astroquery/simbad/core.py:59: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.simbad.core.SimbadClass object at 0x107c40e50>, args = (), kwargs = {'epoch': None, 'equinox': None, 'radius': '5d0m0s'} | |
| script = '\nvotable {main_id,coordinates}\nvotable open\nquery coo', caller = 'query_region_async', get_raw = False, command = 'query coo' | |
| votable_fields = 'main_id,coordinates', votable_def = 'votable {main_id,coordinates}', votable_open = 'votable open', votable_close = 'votable close' | |
| coordinates = <FK4 RA=84.90759 deg, Dec=-80.89403 deg> | |
| @validate_epoch | |
| @validate_equinox | |
| def _args_to_payload(self, *args, **kwargs): | |
| """ | |
| Takes the arguments from any of the query functions | |
| and returns a dictionary that can be used as the | |
| data for an HTTP POST request. | |
| """ | |
| script = "" | |
| caller = kwargs['caller'] | |
| del kwargs['caller'] | |
| get_raw = kwargs.get('get_raw', False) | |
| if get_raw: | |
| del kwargs['get_raw'] | |
| command = self._function_to_command[caller] | |
| votable_fields = ','.join(self.get_votable_fields()) | |
| # if get_raw is set then don't fetch as votable | |
| votable_def = ("votable {" + votable_fields + "}", "")[get_raw] | |
| votable_open = ("votable open", "")[get_raw] | |
| votable_close = ("votable close", "")[get_raw] | |
| if self.ROW_LIMIT > 0: | |
| script = "set limit " + str(self.ROW_LIMIT) | |
| script = "\n".join([script, votable_def, votable_open, command]) | |
| if kwargs.get('wildcard'): | |
| script += " wildcard" # necessary to have a space at the beginning | |
| del kwargs['wildcard'] | |
| # now append args and kwds as per the caller | |
| # if caller is query_region_async write coordinates as separate ra dec | |
| if caller == 'query_region_async': | |
| coordinates = args[0] | |
| args = args[1:] | |
| > ra, dec, frame = _parse_coordinates(coordinates) | |
| astroquery/simbad/core.py:635: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| coordinates = <FK4 RA=84.90759 deg, Dec=-80.89403 deg> | |
| def _parse_coordinates(coordinates): | |
| try: | |
| c = commons.parse_coordinates(coordinates) | |
| # now c has some subclass of astropy.coordinate | |
| # get ra, dec and frame | |
| > return _get_frame_coords(c) | |
| astroquery/simbad/core.py:689: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| c = <FK4 RA=84.90759 deg, Dec=-80.89403 deg> | |
| def _get_frame_coords(c): | |
| > if c.icrs == c: | |
| astroquery/simbad/core.py:695: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <FK4 RA=84.90759 deg, Dec=-80.89403 deg>, name = 'icrs' | |
| def __getattr__(self, name): | |
| """ | |
| Overrides getattr to return coordinates that this can be transformed | |
| to, based on the alias name in the master transform graph. | |
| """ | |
| from .transformations import master_transform_graph | |
| nmsys = master_transform_graph.lookup_name(name) | |
| if self.__class__ is nmsys: | |
| return self | |
| if nmsys is not None and self.is_transformable_to(nmsys): | |
| > return self.transform_to(nmsys) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:659: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <FK4 RA=84.90759 deg, Dec=-80.89403 deg>, tosys = <class 'astropy.coordinates.builtin_systems.ICRS'> | |
| def transform_to(self, tosys): | |
| """ | |
| Transform this coordinate to a new system. | |
| Parameters | |
| ---------- | |
| tosys : class | |
| The system to transform this coordinate into. | |
| Returns | |
| ------- | |
| transcoord | |
| A new object with this coordinate represented in the | |
| ``tosys`` system. | |
| Raises | |
| ------ | |
| ValueError | |
| If there is no possible transformation route. | |
| """ | |
| from .transformations import master_transform_graph | |
| from .errors import ConvertError | |
| if tosys is self.__class__: | |
| return copy.deepcopy(self) | |
| trans = master_transform_graph.get_transform(self.__class__, tosys) | |
| if trans is None: | |
| raise ConvertError('Cannot transform from {0} to ' | |
| '{1}'.format(self.__class__, tosys)) | |
| > return trans(self) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:622: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.CompositeTransform object at 0x10a172b90>, fromcoord = <FK4 RA=84.90759 deg, Dec=-80.89403 deg> | |
| super(CompositeTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| > coord = fromcoord | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:742: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.DynamicMatrixTransform object at 0x1067c58d0>, fromcoord = <FK4NoETerms RA=84.90701 deg, Dec=-80.89400 deg> | |
| super(DynamicMatrixTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| c = fromcoord.cartesian | |
| v = c.reshape((3, c.size // 3)) | |
| v2 = np.dot(np.asarray(self.matrix_func(fromcoord)), v) | |
| subshape = c.shape[1:] | |
| x = v2[0].reshape(subshape) | |
| y = v2[1].reshape(subshape) | |
| z = v2[2].reshape(subshape) | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:708: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x1095a7758>, args = () | |
| kwargs = {'unit': None, 'x': <CartesianPoints 0.017083352278353055>, 'y': <CartesianPoints 0.15781065479713563>, 'z': <CartesianPoints -0.9873216073334123>} | |
| def __init__(self, *args, **kwargs): | |
| super(FK5, self).__init__() | |
| self._equinox = kwargs.pop('equinox', _EQUINOX_J2000) | |
| self._obstime = kwargs.pop('obstime', None) | |
| if not isinstance(self._equinox, Time): | |
| raise TypeError('specified equinox is not a Time object') | |
| if self._obstime is not None and not isinstance(self._obstime, Time): | |
| raise TypeError('specified obstime is not None or a Time object') | |
| if not self._equinox.isscalar: | |
| raise ValueError('specified equinox is not a scalar') | |
| if len(args) == 1 and len(kwargs) == 0 and isinstance(args[0], SphericalCoordinatesBase): | |
| newcoord = args[0].transform_to(self.__class__) | |
| self._latangle = newcoord._latangle | |
| self._lonangle = newcoord._lonangle | |
| self._distance = newcoord._distance | |
| else: | |
| > super(FK5, self)._initialize_latlon('ra', 'dec', args, kwargs) | |
| /Users/adam/repos/astropy/astropy/coordinates/builtin_systems.py:140: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x108260680>, lonname = 'ra' | |
| latname = 'dec', initargs = (), initkwargs = {} | |
| def _initialize_latlon(self, lonname, latname, initargs, initkwargs): | |
| """ | |
| Subclasses should use this to initialize standard lat/lon-style | |
| coordinates. | |
| This recognizes both the lat/lon style and the cartesian form. | |
| Parameters | |
| ---------- | |
| lonname : str | |
| The name of the longitude-like coordinate attribute | |
| latname : str | |
| The name of the latitude-like coordinate attribute | |
| initargs : list | |
| The ``*args`` from the initializer | |
| initkwargs : dict | |
| The ``**kwargs`` from the initializer | |
| """ | |
| initkwargs = dict(initkwargs) # copy | |
| nargs = len(initargs) | |
| sclsnm = self.__class__.__name__ | |
| if nargs == 1: | |
| if isinstance(initargs[0], CartesianPoints): | |
| initkwargs['cartpoint'] = initargs[0] | |
| else: | |
| initkwargs['coordstr'] = initargs[0] | |
| if nargs > 1: | |
| if lonname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, lonname)) | |
| initkwargs[lonname] = initargs[0] | |
| if nargs >= 2: | |
| if latname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, latname)) | |
| initkwargs[latname] = initargs[1] | |
| if nargs > 2: | |
| raise TypeError('{0} takes up to 2 positional arguments ' | |
| '({1} given)'.format(sclsnm, len(initargs))) | |
| unit = initkwargs.pop('unit', None) | |
| coordstr = initkwargs.pop('coordstr', None) | |
| lonval = initkwargs.pop(lonname, None) | |
| latval = initkwargs.pop(latname, None) | |
| distval = initkwargs.pop('distance', None) | |
| cartpoint = initkwargs.pop('cartpoint', None) | |
| x = initkwargs.pop('x', None) | |
| y = initkwargs.pop('y', None) | |
| z = initkwargs.pop('z', None) | |
| if len(initkwargs) > 0: | |
| raise TypeError('{0} got unexpected keyword argument' | |
| ' {1}'.format(sclsnm, initkwargs.keys())) | |
| angleinit = ((lonval is not None and latval is not None) or | |
| coordstr is not None) | |
| cartinit = ((x is not None and y is not None and z is not None) or | |
| cartpoint is not None) | |
| if angleinit and not cartinit: | |
| # lat/lon-style initialization | |
| for v in [x, y, z, cartpoint]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| try: | |
| # this raises a TypeError if `unit` is not None or iterable | |
| units = [None, None] if unit is None else list(unit) | |
| except TypeError: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a ' | |
| 'non-sequence {1}'.format(sclsnm, unit)) | |
| if len(units) == 2: | |
| try: | |
| if units[0] is not None: | |
| units[0] = u.Unit(units[0]) | |
| if units[1] is not None: | |
| units[1] = u.Unit(units[1]) | |
| except ValueError: | |
| raise ValueError('Could not convert units to unit objects ' | |
| 'while initializing ' + sclsnm) | |
| else: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a sequence ' | |
| 'of {1}.'.format(sclsnm, len(units))) | |
| if coordstr is not None: | |
| # need to try to parse the coordinate from a single argument | |
| # populates latval and lonval variables, which then get made | |
| # into coordinates below | |
| if isinstance(coordstr, six.string_types): | |
| if "," in coordstr: | |
| lonval, latval = coordstr.split(",") | |
| else: | |
| coosplit = coordstr.split() | |
| if len(coosplit) == 6: | |
| lonval = " ".join(coosplit[0:3]) | |
| latval = " ".join(coosplit[3:]) | |
| elif len(coosplit) == 2: | |
| lonval, latval = coosplit | |
| else: | |
| msg = ("Could not parse {lonname}/{latname} values " | |
| "from the string provided: '{coordstr}'.") | |
| raise ValueError(msg.format(lonname=lonname, | |
| latname=latname, | |
| coordstr=coordstr)) | |
| else: | |
| raise ValueError("A {0} cannot be created with a single value of type " | |
| "'{1}', must be a string.".format(sclsnm, type(coordstr).__name__)) | |
| # now actually create the angle objects | |
| lonang = Longitude(lonval, unit=units[0]) | |
| latang = Latitude(latval, unit=units[1]) | |
| dist = None if distval is None else Distance(distval) # copy | |
| elif cartinit and not angleinit: | |
| # cartesian-style initialization | |
| for v in [coordstr, lonval, latval, distval]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| if cartpoint is not None: | |
| for v in [x, y, z, unit]: | |
| if v is not None: | |
| raise ValueError('Cannot give both a CartesianPoints ' | |
| 'and x/y/z/unit parameters while ' | |
| 'initializing ' + sclsnm) | |
| x = cartpoint.x | |
| y = cartpoint.y | |
| z = cartpoint.z | |
| unit = cartpoint.unit | |
| > r, latval, lonval = cartesian_to_spherical(x, y, z) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:235: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| x = <CartesianPoints 0.017083352278353055>, y = <CartesianPoints 0.15781065479713563>, z = <CartesianPoints -0.9873216073334123> | |
| x : scalar or array-like | |
| The first cartesian coordinate. | |
| y : scalar or array-like | |
| The second cartesian coordinate. | |
| z : scalar or array-like | |
| The third cartesian coordinate. | |
| Returns | |
| ------- | |
| r : float or array | |
| The radial coordinate (in the same units as the inputs). | |
| lat : float or array | |
| The latitude in radians | |
| lon : float or array | |
| The longitude in radians | |
| """ | |
| xsq = x ** 2 | |
| ysq = y ** 2 | |
| zsq = z ** 2 | |
| r = (xsq + ysq + zsq) ** 0.5 | |
| s = (xsq + ysq) ** 0.5 | |
| if np.isscalar(x) and np.isscalar(y) and np.isscalar(z): | |
| lon = math.atan2(y, x) | |
| lat = math.atan2(z, s) | |
| else: | |
| lon = np.arctan2(y, x) | |
| lat = np.arctan2(z, s) | |
| return r, lat, lon | |
| def spherical_to_cartesian(r, lat, lon): | |
| """ | |
| Converts spherical polar coordinates to rectangular cartesian | |
| coordinates. | |
| Note that the input angles should be in latitude/longitude or | |
| elevation/azimuthal form. I.e., the origin is along the equator | |
| rather than at the north pole. | |
| .. note:: | |
| This is a low-level function used internally in | |
| > `astropy.coordinates`. It is provided for users if they really | |
| want to use it, but it is recommended that you use the | |
| `astropy.coordinates` coordinate systems. | |
| Parameters | |
| ---------- | |
| r : scalar or array-like | |
| The radial coordinate (in the same units as the inputs). | |
| lat : scalar or array-like | |
| The latitude in radians | |
| lon : scalar or array-like | |
| The longitude in radians | |
| Returns | |
| ------- | |
| x : float or array | |
| The first cartesian coordinate. | |
| y : float or array | |
| The second cartesian coordinate. | |
| z : float or array | |
| The third cartesian coordinate. | |
| """ | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:441: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints 0.15781065479713563>, obj = array(2.315841784746324e+77) | |
| context = (<ufunc 'arctan2'>, (<CartesianPoints 0.15781065479713563>, <CartesianPoints 0.017083352278353055>), 0) | |
| raise TypeError("The value must be a valid Python or " | |
| "Numpy numeric type.") | |
| # by default, cast any integer, boolean, etc., to float | |
| if dtype is None and not np.can_cast(np.float32, value.dtype): | |
| value = value.astype(np.float) | |
| value = value.view(cls) | |
| value._unit = unit | |
| return value | |
| def __array_finalize__(self, obj): | |
| self._unit = getattr(obj, '_unit', None) | |
| def __array_prepare__(self, obj, context=None): | |
| # This method gets called by Numpy whenever a ufunc is called on the | |
| # array. The object passed in ``obj`` is an empty version of the | |
| # output array which we can e.g. change to an array sub-class, add | |
| # attributes to, etc. After this is called, then the ufunc is called | |
| # and the values in this empty array are set. | |
| # If no context is set, just return the input | |
| if context is None: | |
| return obj | |
| # Find out which ufunc is being used | |
| function = context[0] | |
| from .quantity_helper import UNSUPPORTED_UFUNCS, UFUNC_HELPERS | |
| # Check whether we even support this ufunc | |
| if function in UNSUPPORTED_UFUNCS: | |
| raise TypeError("Cannot use function '{0}' with quantities" | |
| .format(function.__name__)) | |
| # Now find out what arguments were passed to the ufunc, usually, this | |
| # will include at least the present object, and another, which could | |
| # be a Quantity, or a Numpy array, etc. when using two-argument ufuncs. | |
| args = context[1][:function.nin] | |
| units = [getattr(arg, 'unit', None) for arg in args] | |
| # If the ufunc is supported, then we call a helper function (defined | |
| # in quantity_helper.py) which returns the scale by which the inputs | |
| # should be multiplied before being passed to the ufunc, as well as | |
| # the unit the output from the ufunc will have. | |
| if function in UFUNC_HELPERS: | |
| scales, result_unit = UFUNC_HELPERS[function](function, *units) | |
| else: | |
| raise TypeError("Unknown ufunc {0}. Please raise issue on " | |
| "https://github.com/astropy/astropy" | |
| .format(function.__name__)) | |
| if any(scale == 0. for scale in scales): | |
| # for two-argument ufuncs with a quantity and a non-quantity, | |
| # the quantity normally needs to be dimensionless, *except* | |
| # if the non-quantity can have arbitrary unit, i.e., when it | |
| # is all zero, infinity or NaN. In that case, the non-quantity | |
| # can just have the unit of the quantity | |
| # (this allows, e.g., `q > 0.` independent of unit) | |
| maybe_arbitrary_arg = args[scales.index(0.)] | |
| if _can_have_arbitrary_unit(maybe_arbitrary_arg): | |
| scales = [1., 1.] | |
| else: | |
| raise UnitsError("Can only apply '{0}' function to " | |
| "dimensionless quantities when other " | |
| "argument is not a quantity (unless the " | |
| "latter is all zero/infinity/nan)" | |
| .format(function.__name__)) | |
| # In the case of np.power, the unit itself needs to be modified by an | |
| # amount that depends on one of the input values, so we need to treat | |
| # this as a special case. | |
| # TODO: find a better way to deal with this case | |
| if function is np.power and result_unit is not None: | |
| if units[1] is None: | |
| p = args[1] | |
| else: | |
| p = args[1].to(dimensionless_unscaled).value | |
| result_unit = result_unit ** validate_power(p) | |
| # We now prepare the output object | |
| if self is obj: # happens if the output object is self, which happens | |
| # for in-place operations such as q1 += q2 | |
| # In some cases, the result of a ufunc should be a plain Numpy | |
| # array, which we can't do if we are doing an in-place operation. | |
| if result_unit is None: | |
| raise TypeError("Cannot store non-quantity output from {0} " | |
| "function in Quantity object" | |
| .format(function.__name__)) | |
| /Users/adam/repos/astropy/astropy/units/quantity.py:311: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints 0.15781065479713563>, obj = array(2.315841784746324e+77), unit = Unit("rad") | |
| #screw up the units are killed by _convert_to_and_validate_length_unit | |
| obj = super(CartesianPoints, self).__array_wrap__(obj, context=context) | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:310: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = AssertionError(), args = (), f = <py._code.code.Frame object at 0x10a172110> | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| > ??? | |
| _pytest.assertion.reinterpret:40: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| frame = <py._code.code.Frame object at 0x10a172110>, should_fail = True | |
| > ??? | |
| _pytest.assertion.newinterpret:46: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| filename = '<unknown>', mode = 'exec' | |
| def parse(source, filename='<unknown>', mode='exec'): | |
| """ | |
| Parse the source into an AST node. | |
| Equivalent to compile(source, filename, mode, PyCF_ONLY_AST). | |
| """ | |
| > return compile(source, filename, mode, PyCF_ONLY_AST) | |
| E File "<unknown>", line 1 | |
| E .. note:: | |
| E ^ | |
| E SyntaxError: invalid syntax | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py:37: SyntaxError | |
| ____________________________________________________ test_query_region_async[coordinates3-None-None-None] _____________________________________________________ | |
| patch_post = <_pytest.monkeypatch.monkeypatch instance at 0x1082455a8>, coordinates = <FK5 RA=83.82207 deg, Dec=-80.86667 deg>, radius = None, equinox = None | |
| epoch = None | |
| @pytest.mark.parametrize(('coordinates', 'radius', 'equinox', 'epoch'), | |
| [(ICRS_COORDS, None, None, None), | |
| (GALACTIC_COORDS, 5 * u.deg, 2000.0, 'J2000'), | |
| (FK4_COORDS, '5d0m0s', None, None), | |
| (FK5_COORDS, None, None, None) | |
| ]) | |
| def test_query_region_async(patch_post, coordinates, radius, equinox, epoch): | |
| response1 = simbad.core.Simbad.query_region_async(coordinates, radius=radius, | |
| > equinox=equinox, epoch=epoch) | |
| astroquery/simbad/tests/test_simbad.py:212: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.simbad.core.SimbadClass object at 0x107c40e50>, coordinates = <FK5 RA=83.82207 deg, Dec=-80.86667 deg>, radius = None, equinox = None | |
| epoch = None | |
| def query_region_async(self, coordinates, radius=None, equinox=None, | |
| epoch=None): | |
| """ | |
| Serves the same function as `query_region`, but | |
| only collects the reponse from the Simbad server and returns. | |
| Parameters | |
| ---------- | |
| coordinates : str/`astropy.coordinates` | |
| the identifier or coordinates around which to query. | |
| radius : str/`~astropy.units.Quantity`, optional | |
| the radius of the region. If missing, set to default | |
| value of 20 arcmin. | |
| equinox : float, optional | |
| the equinox of the coordinates. If missing set to | |
| default 2000.0. | |
| epoch : str, optional | |
| the epoch of the input coordiantes. Must be specified as | |
| [J|B] <epoch>. If missing, set to default J2000. | |
| Returns | |
| ------- | |
| response : `requests.Response` | |
| Response of the query from the server. | |
| """ | |
| request_payload = self._args_to_payload(coordinates, radius=radius, | |
| equinox=equinox, epoch=epoch, | |
| > caller='query_region_async') | |
| astroquery/simbad/core.py:469: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| args = (<astroquery.simbad.core.SimbadClass object at 0x107c40e50>, <FK5 RA=83.82207 deg, Dec=-80.86667 deg>) | |
| kwargs = {'caller': 'query_region_async', 'epoch': None, 'equinox': None, 'radius': None} | |
| def wrapper(*args, **kwargs): | |
| if kwargs.get('epoch'): | |
| value = kwargs['epoch'] | |
| try: | |
| p = re.compile('^[JB]\d+[.]?\d+$', re.IGNORECASE) | |
| assert p.match(value) is not None | |
| except (AssertionError, TypeError): | |
| raise ValueError("Epoch must be specified as [J|B]<epoch>.\n" | |
| "Example: epoch='J2000'") | |
| > return func(*args, **kwargs) | |
| astroquery/simbad/core.py:43: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| args = (<astroquery.simbad.core.SimbadClass object at 0x107c40e50>, <FK5 RA=83.82207 deg, Dec=-80.86667 deg>) | |
| kwargs = {'caller': 'query_region_async', 'epoch': None, 'equinox': None, 'radius': None} | |
| def wrapper(*args, **kwargs): | |
| if kwargs.get('equinox'): | |
| value = kwargs['equinox'] | |
| try: | |
| float(value) | |
| except ValueError: | |
| raise ValueError("Equinox must be a number") | |
| > return func(*args, **kwargs) | |
| astroquery/simbad/core.py:59: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.simbad.core.SimbadClass object at 0x107c40e50>, args = (), kwargs = {'epoch': None, 'equinox': None, 'radius': None} | |
| script = '\nvotable {main_id,coordinates}\nvotable open\nquery coo', caller = 'query_region_async', get_raw = False, command = 'query coo' | |
| votable_fields = 'main_id,coordinates', votable_def = 'votable {main_id,coordinates}', votable_open = 'votable open', votable_close = 'votable close' | |
| coordinates = <FK5 RA=83.82207 deg, Dec=-80.86667 deg> | |
| @validate_epoch | |
| @validate_equinox | |
| def _args_to_payload(self, *args, **kwargs): | |
| """ | |
| Takes the arguments from any of the query functions | |
| and returns a dictionary that can be used as the | |
| data for an HTTP POST request. | |
| """ | |
| script = "" | |
| caller = kwargs['caller'] | |
| del kwargs['caller'] | |
| get_raw = kwargs.get('get_raw', False) | |
| if get_raw: | |
| del kwargs['get_raw'] | |
| command = self._function_to_command[caller] | |
| votable_fields = ','.join(self.get_votable_fields()) | |
| # if get_raw is set then don't fetch as votable | |
| votable_def = ("votable {" + votable_fields + "}", "")[get_raw] | |
| votable_open = ("votable open", "")[get_raw] | |
| votable_close = ("votable close", "")[get_raw] | |
| if self.ROW_LIMIT > 0: | |
| script = "set limit " + str(self.ROW_LIMIT) | |
| script = "\n".join([script, votable_def, votable_open, command]) | |
| if kwargs.get('wildcard'): | |
| script += " wildcard" # necessary to have a space at the beginning | |
| del kwargs['wildcard'] | |
| # now append args and kwds as per the caller | |
| # if caller is query_region_async write coordinates as separate ra dec | |
| if caller == 'query_region_async': | |
| coordinates = args[0] | |
| args = args[1:] | |
| > ra, dec, frame = _parse_coordinates(coordinates) | |
| astroquery/simbad/core.py:635: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| coordinates = <FK5 RA=83.82207 deg, Dec=-80.86667 deg> | |
| def _parse_coordinates(coordinates): | |
| try: | |
| c = commons.parse_coordinates(coordinates) | |
| # now c has some subclass of astropy.coordinate | |
| # get ra, dec and frame | |
| > return _get_frame_coords(c) | |
| astroquery/simbad/core.py:689: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| c = <FK5 RA=83.82207 deg, Dec=-80.86667 deg> | |
| def _get_frame_coords(c): | |
| > if c.icrs == c: | |
| astroquery/simbad/core.py:695: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <FK5 RA=83.82207 deg, Dec=-80.86667 deg>, name = 'icrs' | |
| def __getattr__(self, name): | |
| """ | |
| Overrides getattr to return coordinates that this can be transformed | |
| to, based on the alias name in the master transform graph. | |
| """ | |
| from .transformations import master_transform_graph | |
| nmsys = master_transform_graph.lookup_name(name) | |
| if self.__class__ is nmsys: | |
| return self | |
| if nmsys is not None and self.is_transformable_to(nmsys): | |
| > return self.transform_to(nmsys) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:659: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <FK5 RA=83.82207 deg, Dec=-80.86667 deg>, tosys = <class 'astropy.coordinates.builtin_systems.ICRS'> | |
| def transform_to(self, tosys): | |
| """ | |
| Transform this coordinate to a new system. | |
| Parameters | |
| ---------- | |
| tosys : class | |
| The system to transform this coordinate into. | |
| Returns | |
| ------- | |
| transcoord | |
| A new object with this coordinate represented in the | |
| ``tosys`` system. | |
| Raises | |
| ------ | |
| ValueError | |
| If there is no possible transformation route. | |
| """ | |
| from .transformations import master_transform_graph | |
| from .errors import ConvertError | |
| if tosys is self.__class__: | |
| return copy.deepcopy(self) | |
| trans = master_transform_graph.get_transform(self.__class__, tosys) | |
| if trans is None: | |
| raise ConvertError('Cannot transform from {0} to ' | |
| '{1}'.format(self.__class__, tosys)) | |
| > return trans(self) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:622: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.DynamicMatrixTransform object at 0x1067c5390>, fromcoord = <FK5 RA=83.82207 deg, Dec=-80.86667 deg> | |
| super(DynamicMatrixTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| c = fromcoord.cartesian | |
| v = c.reshape((3, c.size // 3)) | |
| v2 = np.dot(np.asarray(self.matrix_func(fromcoord)), v) | |
| subshape = c.shape[1:] | |
| x = v2[0].reshape(subshape) | |
| y = v2[1].reshape(subshape) | |
| z = v2[2].reshape(subshape) | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:708: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'ICRS' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x10ac6d7a0>, args = () | |
| kwargs = {'unit': None, 'x': <CartesianPoints 0.01708218844397828>, 'y': <CartesianPoints 0.15781069037526652>, 'z': <CartesianPoints -0.9873216217835231>} | |
| def __init__(self, *args, **kwargs): | |
| super(ICRS, self).__init__() | |
| self._obstime = kwargs.pop('obstime', None) | |
| if self._obstime is not None and not isinstance(self._obstime, Time): | |
| raise TypeError('specified obstime is not None or a Time object') | |
| if len(args) == 1 and len(kwargs) == 0 and isinstance(args[0], SphericalCoordinatesBase): | |
| newcoord = args[0].transform_to(self.__class__) | |
| self._latangle = newcoord._latangle | |
| self._lonangle = newcoord._lonangle | |
| self._distance = newcoord._distance | |
| else: | |
| > super(ICRS, self)._initialize_latlon('ra', 'dec', args, kwargs) | |
| /Users/adam/repos/astropy/astropy/coordinates/builtin_systems.py:72: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'ICRS' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x10830f7a0>, lonname = 'ra' | |
| latname = 'dec', initargs = (), initkwargs = {} | |
| def _initialize_latlon(self, lonname, latname, initargs, initkwargs): | |
| """ | |
| Subclasses should use this to initialize standard lat/lon-style | |
| coordinates. | |
| This recognizes both the lat/lon style and the cartesian form. | |
| Parameters | |
| ---------- | |
| lonname : str | |
| The name of the longitude-like coordinate attribute | |
| latname : str | |
| The name of the latitude-like coordinate attribute | |
| initargs : list | |
| The ``*args`` from the initializer | |
| initkwargs : dict | |
| The ``**kwargs`` from the initializer | |
| """ | |
| initkwargs = dict(initkwargs) # copy | |
| nargs = len(initargs) | |
| sclsnm = self.__class__.__name__ | |
| if nargs == 1: | |
| if isinstance(initargs[0], CartesianPoints): | |
| initkwargs['cartpoint'] = initargs[0] | |
| else: | |
| initkwargs['coordstr'] = initargs[0] | |
| if nargs > 1: | |
| if lonname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, lonname)) | |
| initkwargs[lonname] = initargs[0] | |
| if nargs >= 2: | |
| if latname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, latname)) | |
| initkwargs[latname] = initargs[1] | |
| if nargs > 2: | |
| raise TypeError('{0} takes up to 2 positional arguments ' | |
| '({1} given)'.format(sclsnm, len(initargs))) | |
| unit = initkwargs.pop('unit', None) | |
| coordstr = initkwargs.pop('coordstr', None) | |
| lonval = initkwargs.pop(lonname, None) | |
| latval = initkwargs.pop(latname, None) | |
| distval = initkwargs.pop('distance', None) | |
| cartpoint = initkwargs.pop('cartpoint', None) | |
| x = initkwargs.pop('x', None) | |
| y = initkwargs.pop('y', None) | |
| z = initkwargs.pop('z', None) | |
| if len(initkwargs) > 0: | |
| raise TypeError('{0} got unexpected keyword argument' | |
| ' {1}'.format(sclsnm, initkwargs.keys())) | |
| angleinit = ((lonval is not None and latval is not None) or | |
| coordstr is not None) | |
| cartinit = ((x is not None and y is not None and z is not None) or | |
| cartpoint is not None) | |
| if angleinit and not cartinit: | |
| # lat/lon-style initialization | |
| for v in [x, y, z, cartpoint]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| try: | |
| # this raises a TypeError if `unit` is not None or iterable | |
| units = [None, None] if unit is None else list(unit) | |
| except TypeError: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a ' | |
| 'non-sequence {1}'.format(sclsnm, unit)) | |
| if len(units) == 2: | |
| try: | |
| if units[0] is not None: | |
| units[0] = u.Unit(units[0]) | |
| if units[1] is not None: | |
| units[1] = u.Unit(units[1]) | |
| except ValueError: | |
| raise ValueError('Could not convert units to unit objects ' | |
| 'while initializing ' + sclsnm) | |
| else: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a sequence ' | |
| 'of {1}.'.format(sclsnm, len(units))) | |
| if coordstr is not None: | |
| # need to try to parse the coordinate from a single argument | |
| # populates latval and lonval variables, which then get made | |
| # into coordinates below | |
| if isinstance(coordstr, six.string_types): | |
| if "," in coordstr: | |
| lonval, latval = coordstr.split(",") | |
| else: | |
| coosplit = coordstr.split() | |
| if len(coosplit) == 6: | |
| lonval = " ".join(coosplit[0:3]) | |
| latval = " ".join(coosplit[3:]) | |
| elif len(coosplit) == 2: | |
| lonval, latval = coosplit | |
| else: | |
| msg = ("Could not parse {lonname}/{latname} values " | |
| "from the string provided: '{coordstr}'.") | |
| raise ValueError(msg.format(lonname=lonname, | |
| latname=latname, | |
| coordstr=coordstr)) | |
| else: | |
| raise ValueError("A {0} cannot be created with a single value of type " | |
| "'{1}', must be a string.".format(sclsnm, type(coordstr).__name__)) | |
| # now actually create the angle objects | |
| lonang = Longitude(lonval, unit=units[0]) | |
| latang = Latitude(latval, unit=units[1]) | |
| dist = None if distval is None else Distance(distval) # copy | |
| elif cartinit and not angleinit: | |
| # cartesian-style initialization | |
| for v in [coordstr, lonval, latval, distval]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| if cartpoint is not None: | |
| for v in [x, y, z, unit]: | |
| if v is not None: | |
| raise ValueError('Cannot give both a CartesianPoints ' | |
| 'and x/y/z/unit parameters while ' | |
| 'initializing ' + sclsnm) | |
| x = cartpoint.x | |
| y = cartpoint.y | |
| z = cartpoint.z | |
| unit = cartpoint.unit | |
| > r, latval, lonval = cartesian_to_spherical(x, y, z) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:235: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| x = <CartesianPoints 0.01708218844397828>, y = <CartesianPoints 0.15781069037526652>, z = <CartesianPoints -0.9873216217835231> | |
| x : scalar or array-like | |
| The first cartesian coordinate. | |
| y : scalar or array-like | |
| The second cartesian coordinate. | |
| z : scalar or array-like | |
| The third cartesian coordinate. | |
| Returns | |
| ------- | |
| r : float or array | |
| The radial coordinate (in the same units as the inputs). | |
| lat : float or array | |
| The latitude in radians | |
| lon : float or array | |
| The longitude in radians | |
| """ | |
| xsq = x ** 2 | |
| ysq = y ** 2 | |
| zsq = z ** 2 | |
| r = (xsq + ysq + zsq) ** 0.5 | |
| s = (xsq + ysq) ** 0.5 | |
| if np.isscalar(x) and np.isscalar(y) and np.isscalar(z): | |
| lon = math.atan2(y, x) | |
| lat = math.atan2(z, s) | |
| else: | |
| lon = np.arctan2(y, x) | |
| lat = np.arctan2(z, s) | |
| return r, lat, lon | |
| def spherical_to_cartesian(r, lat, lon): | |
| """ | |
| Converts spherical polar coordinates to rectangular cartesian | |
| coordinates. | |
| Note that the input angles should be in latitude/longitude or | |
| elevation/azimuthal form. I.e., the origin is along the equator | |
| rather than at the north pole. | |
| .. note:: | |
| This is a low-level function used internally in | |
| > `astropy.coordinates`. It is provided for users if they really | |
| want to use it, but it is recommended that you use the | |
| `astropy.coordinates` coordinate systems. | |
| Parameters | |
| ---------- | |
| r : scalar or array-like | |
| The radial coordinate (in the same units as the inputs). | |
| lat : scalar or array-like | |
| The latitude in radians | |
| lon : scalar or array-like | |
| The longitude in radians | |
| Returns | |
| ------- | |
| x : float or array | |
| The first cartesian coordinate. | |
| y : float or array | |
| The second cartesian coordinate. | |
| z : float or array | |
| The third cartesian coordinate. | |
| """ | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:441: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints 0.15781069037526652>, obj = array(2.315841784746324e+77) | |
| context = (<ufunc 'arctan2'>, (<CartesianPoints 0.15781069037526652>, <CartesianPoints 0.01708218844397828>), 0) | |
| raise TypeError("The value must be a valid Python or " | |
| "Numpy numeric type.") | |
| # by default, cast any integer, boolean, etc., to float | |
| if dtype is None and not np.can_cast(np.float32, value.dtype): | |
| value = value.astype(np.float) | |
| value = value.view(cls) | |
| value._unit = unit | |
| return value | |
| def __array_finalize__(self, obj): | |
| self._unit = getattr(obj, '_unit', None) | |
| def __array_prepare__(self, obj, context=None): | |
| # This method gets called by Numpy whenever a ufunc is called on the | |
| # array. The object passed in ``obj`` is an empty version of the | |
| # output array which we can e.g. change to an array sub-class, add | |
| # attributes to, etc. After this is called, then the ufunc is called | |
| # and the values in this empty array are set. | |
| # If no context is set, just return the input | |
| if context is None: | |
| return obj | |
| # Find out which ufunc is being used | |
| function = context[0] | |
| from .quantity_helper import UNSUPPORTED_UFUNCS, UFUNC_HELPERS | |
| # Check whether we even support this ufunc | |
| if function in UNSUPPORTED_UFUNCS: | |
| raise TypeError("Cannot use function '{0}' with quantities" | |
| .format(function.__name__)) | |
| # Now find out what arguments were passed to the ufunc, usually, this | |
| # will include at least the present object, and another, which could | |
| # be a Quantity, or a Numpy array, etc. when using two-argument ufuncs. | |
| args = context[1][:function.nin] | |
| units = [getattr(arg, 'unit', None) for arg in args] | |
| # If the ufunc is supported, then we call a helper function (defined | |
| # in quantity_helper.py) which returns the scale by which the inputs | |
| # should be multiplied before being passed to the ufunc, as well as | |
| # the unit the output from the ufunc will have. | |
| if function in UFUNC_HELPERS: | |
| scales, result_unit = UFUNC_HELPERS[function](function, *units) | |
| else: | |
| raise TypeError("Unknown ufunc {0}. Please raise issue on " | |
| "https://github.com/astropy/astropy" | |
| .format(function.__name__)) | |
| if any(scale == 0. for scale in scales): | |
| # for two-argument ufuncs with a quantity and a non-quantity, | |
| # the quantity normally needs to be dimensionless, *except* | |
| # if the non-quantity can have arbitrary unit, i.e., when it | |
| # is all zero, infinity or NaN. In that case, the non-quantity | |
| # can just have the unit of the quantity | |
| # (this allows, e.g., `q > 0.` independent of unit) | |
| maybe_arbitrary_arg = args[scales.index(0.)] | |
| if _can_have_arbitrary_unit(maybe_arbitrary_arg): | |
| scales = [1., 1.] | |
| else: | |
| raise UnitsError("Can only apply '{0}' function to " | |
| "dimensionless quantities when other " | |
| "argument is not a quantity (unless the " | |
| "latter is all zero/infinity/nan)" | |
| .format(function.__name__)) | |
| # In the case of np.power, the unit itself needs to be modified by an | |
| # amount that depends on one of the input values, so we need to treat | |
| # this as a special case. | |
| # TODO: find a better way to deal with this case | |
| if function is np.power and result_unit is not None: | |
| if units[1] is None: | |
| p = args[1] | |
| else: | |
| p = args[1].to(dimensionless_unscaled).value | |
| result_unit = result_unit ** validate_power(p) | |
| # We now prepare the output object | |
| if self is obj: # happens if the output object is self, which happens | |
| # for in-place operations such as q1 += q2 | |
| # In some cases, the result of a ufunc should be a plain Numpy | |
| # array, which we can't do if we are doing an in-place operation. | |
| if result_unit is None: | |
| raise TypeError("Cannot store non-quantity output from {0} " | |
| "function in Quantity object" | |
| .format(function.__name__)) | |
| /Users/adam/repos/astropy/astropy/units/quantity.py:311: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints 0.15781069037526652>, obj = array(2.315841784746324e+77), unit = Unit("rad") | |
| #screw up the units are killed by _convert_to_and_validate_length_unit | |
| obj = super(CartesianPoints, self).__array_wrap__(obj, context=context) | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:310: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = AssertionError(), args = (), f = <py._code.code.Frame object at 0x11996e3d0> | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| > ??? | |
| _pytest.assertion.reinterpret:40: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| frame = <py._code.code.Frame object at 0x11996e3d0>, should_fail = True | |
| > ??? | |
| _pytest.assertion.newinterpret:46: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| filename = '<unknown>', mode = 'exec' | |
| def parse(source, filename='<unknown>', mode='exec'): | |
| """ | |
| Parse the source into an AST node. | |
| Equivalent to compile(source, filename, mode, PyCF_ONLY_AST). | |
| """ | |
| > return compile(source, filename, mode, PyCF_ONLY_AST) | |
| E File "<unknown>", line 1 | |
| E .. note:: | |
| E ^ | |
| E SyntaxError: invalid syntax | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py:37: SyntaxError | |
| ____________________________________________________ test_query_region[coordinates1-radius1-2000.0-J2000] _____________________________________________________ | |
| patch_post = <_pytest.monkeypatch.monkeypatch instance at 0x1096a69e0>, coordinates = <Galactic l=292.97916 deg, b=-29.75447 deg>, radius = <Quantity 5.0 deg> | |
| equinox = 2000.0, epoch = 'J2000' | |
| @pytest.mark.parametrize(('coordinates', 'radius', 'equinox', 'epoch'), | |
| [(ICRS_COORDS, None, None, None), | |
| (GALACTIC_COORDS, 5 * u.deg, 2000.0, 'J2000'), | |
| (FK4_COORDS, '5d0m0s', None, None), | |
| (FK5_COORDS, None, None, None) | |
| ]) | |
| def test_query_region(patch_post, coordinates, radius, equinox, epoch): | |
| result1 = simbad.core.Simbad.query_region(coordinates, radius=radius, | |
| > equinox=equinox, epoch=epoch) | |
| astroquery/simbad/tests/test_simbad.py:227: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.simbad.core.SimbadClass object at 0x107c40e50>, coordinates = <Galactic l=292.97916 deg, b=-29.75447 deg>, radius = <Quantity 5.0 deg> | |
| equinox = 2000.0, epoch = 'J2000', verbose = False | |
| def query_region(self, coordinates, radius=None, | |
| equinox=None, epoch=None, verbose=False): | |
| """ | |
| Queries around an object or coordinates as per the specified radius and | |
| returns the results in a `~astropy.table.Table`. | |
| Parameters | |
| ---------- | |
| coordinates : str / `astropy.coordinates` | |
| the identifier or coordinates around which to query. | |
| radius : str / `~astropy.units.Quantity`, optional | |
| the radius of the region. If missing, set to default | |
| value of 20 arcmin. | |
| equinox : float, optional | |
| the equinox of the coordinates. If missing set to | |
| default 2000.0. | |
| epoch : str, optional | |
| the epoch of the input coordiantes. Must be specified as | |
| [J|B] <epoch>. If missing, set to default J2000. | |
| Returns | |
| ------- | |
| table : `~astropy.table.Table` | |
| Query results table | |
| """ | |
| # if the identifier is given rather than the coordinates, convert to | |
| # coordinates | |
| result = self.query_region_async(coordinates, radius=radius, | |
| > equinox=equinox, epoch=epoch) | |
| astroquery/simbad/core.py:439: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.simbad.core.SimbadClass object at 0x107c40e50>, coordinates = <Galactic l=292.97916 deg, b=-29.75447 deg>, radius = <Quantity 5.0 deg> | |
| equinox = 2000.0, epoch = 'J2000' | |
| def query_region_async(self, coordinates, radius=None, equinox=None, | |
| epoch=None): | |
| """ | |
| Serves the same function as `query_region`, but | |
| only collects the reponse from the Simbad server and returns. | |
| Parameters | |
| ---------- | |
| coordinates : str/`astropy.coordinates` | |
| the identifier or coordinates around which to query. | |
| radius : str/`~astropy.units.Quantity`, optional | |
| the radius of the region. If missing, set to default | |
| value of 20 arcmin. | |
| equinox : float, optional | |
| the equinox of the coordinates. If missing set to | |
| default 2000.0. | |
| epoch : str, optional | |
| the epoch of the input coordiantes. Must be specified as | |
| [J|B] <epoch>. If missing, set to default J2000. | |
| Returns | |
| ------- | |
| response : `requests.Response` | |
| Response of the query from the server. | |
| """ | |
| request_payload = self._args_to_payload(coordinates, radius=radius, | |
| equinox=equinox, epoch=epoch, | |
| > caller='query_region_async') | |
| astroquery/simbad/core.py:469: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| args = (<astroquery.simbad.core.SimbadClass object at 0x107c40e50>, <Galactic l=292.97916 deg, b=-29.75447 deg>) | |
| kwargs = {'caller': 'query_region_async', 'epoch': 'J2000', 'equinox': 2000.0, 'radius': <Quantity 5.0 deg>}, value = 'J2000' | |
| p = <_sre.SRE_Pattern object at 0x109db8060> | |
| def wrapper(*args, **kwargs): | |
| if kwargs.get('epoch'): | |
| value = kwargs['epoch'] | |
| try: | |
| p = re.compile('^[JB]\d+[.]?\d+$', re.IGNORECASE) | |
| assert p.match(value) is not None | |
| except (AssertionError, TypeError): | |
| raise ValueError("Epoch must be specified as [J|B]<epoch>.\n" | |
| "Example: epoch='J2000'") | |
| > return func(*args, **kwargs) | |
| astroquery/simbad/core.py:43: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| args = (<astroquery.simbad.core.SimbadClass object at 0x107c40e50>, <Galactic l=292.97916 deg, b=-29.75447 deg>) | |
| kwargs = {'caller': 'query_region_async', 'epoch': 'J2000', 'equinox': 2000.0, 'radius': <Quantity 5.0 deg>}, value = 2000.0 | |
| def wrapper(*args, **kwargs): | |
| if kwargs.get('equinox'): | |
| value = kwargs['equinox'] | |
| try: | |
| float(value) | |
| except ValueError: | |
| raise ValueError("Equinox must be a number") | |
| > return func(*args, **kwargs) | |
| astroquery/simbad/core.py:59: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.simbad.core.SimbadClass object at 0x107c40e50>, args = (), kwargs = {'epoch': 'J2000', 'equinox': 2000.0, 'radius': <Quantity 5.0 deg>} | |
| script = '\nvotable {main_id,coordinates}\nvotable open\nquery coo', caller = 'query_region_async', get_raw = False, command = 'query coo' | |
| votable_fields = 'main_id,coordinates', votable_def = 'votable {main_id,coordinates}', votable_open = 'votable open', votable_close = 'votable close' | |
| coordinates = <Galactic l=292.97916 deg, b=-29.75447 deg> | |
| @validate_epoch | |
| @validate_equinox | |
| def _args_to_payload(self, *args, **kwargs): | |
| """ | |
| Takes the arguments from any of the query functions | |
| and returns a dictionary that can be used as the | |
| data for an HTTP POST request. | |
| """ | |
| script = "" | |
| caller = kwargs['caller'] | |
| del kwargs['caller'] | |
| get_raw = kwargs.get('get_raw', False) | |
| if get_raw: | |
| del kwargs['get_raw'] | |
| command = self._function_to_command[caller] | |
| votable_fields = ','.join(self.get_votable_fields()) | |
| # if get_raw is set then don't fetch as votable | |
| votable_def = ("votable {" + votable_fields + "}", "")[get_raw] | |
| votable_open = ("votable open", "")[get_raw] | |
| votable_close = ("votable close", "")[get_raw] | |
| if self.ROW_LIMIT > 0: | |
| script = "set limit " + str(self.ROW_LIMIT) | |
| script = "\n".join([script, votable_def, votable_open, command]) | |
| if kwargs.get('wildcard'): | |
| script += " wildcard" # necessary to have a space at the beginning | |
| del kwargs['wildcard'] | |
| # now append args and kwds as per the caller | |
| # if caller is query_region_async write coordinates as separate ra dec | |
| if caller == 'query_region_async': | |
| coordinates = args[0] | |
| args = args[1:] | |
| > ra, dec, frame = _parse_coordinates(coordinates) | |
| astroquery/simbad/core.py:635: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| coordinates = <Galactic l=292.97916 deg, b=-29.75447 deg> | |
| def _parse_coordinates(coordinates): | |
| try: | |
| c = commons.parse_coordinates(coordinates) | |
| # now c has some subclass of astropy.coordinate | |
| # get ra, dec and frame | |
| > return _get_frame_coords(c) | |
| astroquery/simbad/core.py:689: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| c = <Galactic l=292.97916 deg, b=-29.75447 deg> | |
| def _get_frame_coords(c): | |
| > if c.icrs == c: | |
| astroquery/simbad/core.py:695: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <Galactic l=292.97916 deg, b=-29.75447 deg>, name = 'icrs' | |
| def __getattr__(self, name): | |
| """ | |
| Overrides getattr to return coordinates that this can be transformed | |
| to, based on the alias name in the master transform graph. | |
| """ | |
| from .transformations import master_transform_graph | |
| nmsys = master_transform_graph.lookup_name(name) | |
| if self.__class__ is nmsys: | |
| return self | |
| if nmsys is not None and self.is_transformable_to(nmsys): | |
| > return self.transform_to(nmsys) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:659: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <Galactic l=292.97916 deg, b=-29.75447 deg>, tosys = <class 'astropy.coordinates.builtin_systems.ICRS'> | |
| def transform_to(self, tosys): | |
| """ | |
| Transform this coordinate to a new system. | |
| Parameters | |
| ---------- | |
| tosys : class | |
| The system to transform this coordinate into. | |
| Returns | |
| ------- | |
| transcoord | |
| A new object with this coordinate represented in the | |
| ``tosys`` system. | |
| Raises | |
| ------ | |
| ValueError | |
| If there is no possible transformation route. | |
| """ | |
| from .transformations import master_transform_graph | |
| from .errors import ConvertError | |
| if tosys is self.__class__: | |
| return copy.deepcopy(self) | |
| trans = master_transform_graph.get_transform(self.__class__, tosys) | |
| if trans is None: | |
| raise ConvertError('Cannot transform from {0} to ' | |
| '{1}'.format(self.__class__, tosys)) | |
| > return trans(self) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:622: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.CompositeTransform object at 0x1096b2b50>, fromcoord = <Galactic l=292.97916 deg, b=-29.75447 deg> | |
| super(CompositeTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| > coord = fromcoord | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:742: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.DynamicMatrixTransform object at 0x1067c5990>, fromcoord = <Galactic l=292.97916 deg, b=-29.75447 deg> | |
| super(DynamicMatrixTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| c = fromcoord.cartesian | |
| v = c.reshape((3, c.size // 3)) | |
| v2 = np.dot(np.asarray(self.matrix_func(fromcoord)), v) | |
| subshape = c.shape[1:] | |
| x = v2[0].reshape(subshape) | |
| y = v2[1].reshape(subshape) | |
| z = v2[2].reshape(subshape) | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:708: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x11989fc68>, args = () | |
| kwargs = {'unit': None, 'x': <CartesianPoints 0.0170822506606243>, 'y': <CartesianPoints 0.15781058025053168>, 'z': <CartesianPoints -0.9873216383090963>} | |
| def __init__(self, *args, **kwargs): | |
| super(FK5, self).__init__() | |
| self._equinox = kwargs.pop('equinox', _EQUINOX_J2000) | |
| self._obstime = kwargs.pop('obstime', None) | |
| if not isinstance(self._equinox, Time): | |
| raise TypeError('specified equinox is not a Time object') | |
| if self._obstime is not None and not isinstance(self._obstime, Time): | |
| raise TypeError('specified obstime is not None or a Time object') | |
| if not self._equinox.isscalar: | |
| raise ValueError('specified equinox is not a scalar') | |
| if len(args) == 1 and len(kwargs) == 0 and isinstance(args[0], SphericalCoordinatesBase): | |
| newcoord = args[0].transform_to(self.__class__) | |
| self._latangle = newcoord._latangle | |
| self._lonangle = newcoord._lonangle | |
| self._distance = newcoord._distance | |
| else: | |
| > super(FK5, self)._initialize_latlon('ra', 'dec', args, kwargs) | |
| /Users/adam/repos/astropy/astropy/coordinates/builtin_systems.py:140: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x11989fea8>, lonname = 'ra' | |
| latname = 'dec', initargs = (), initkwargs = {} | |
| def _initialize_latlon(self, lonname, latname, initargs, initkwargs): | |
| """ | |
| Subclasses should use this to initialize standard lat/lon-style | |
| coordinates. | |
| This recognizes both the lat/lon style and the cartesian form. | |
| Parameters | |
| ---------- | |
| lonname : str | |
| The name of the longitude-like coordinate attribute | |
| latname : str | |
| The name of the latitude-like coordinate attribute | |
| initargs : list | |
| The ``*args`` from the initializer | |
| initkwargs : dict | |
| The ``**kwargs`` from the initializer | |
| """ | |
| initkwargs = dict(initkwargs) # copy | |
| nargs = len(initargs) | |
| sclsnm = self.__class__.__name__ | |
| if nargs == 1: | |
| if isinstance(initargs[0], CartesianPoints): | |
| initkwargs['cartpoint'] = initargs[0] | |
| else: | |
| initkwargs['coordstr'] = initargs[0] | |
| if nargs > 1: | |
| if lonname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, lonname)) | |
| initkwargs[lonname] = initargs[0] | |
| if nargs >= 2: | |
| if latname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, latname)) | |
| initkwargs[latname] = initargs[1] | |
| if nargs > 2: | |
| raise TypeError('{0} takes up to 2 positional arguments ' | |
| '({1} given)'.format(sclsnm, len(initargs))) | |
| unit = initkwargs.pop('unit', None) | |
| coordstr = initkwargs.pop('coordstr', None) | |
| lonval = initkwargs.pop(lonname, None) | |
| latval = initkwargs.pop(latname, None) | |
| distval = initkwargs.pop('distance', None) | |
| cartpoint = initkwargs.pop('cartpoint', None) | |
| x = initkwargs.pop('x', None) | |
| y = initkwargs.pop('y', None) | |
| z = initkwargs.pop('z', None) | |
| if len(initkwargs) > 0: | |
| raise TypeError('{0} got unexpected keyword argument' | |
| ' {1}'.format(sclsnm, initkwargs.keys())) | |
| angleinit = ((lonval is not None and latval is not None) or | |
| coordstr is not None) | |
| cartinit = ((x is not None and y is not None and z is not None) or | |
| cartpoint is not None) | |
| if angleinit and not cartinit: | |
| # lat/lon-style initialization | |
| for v in [x, y, z, cartpoint]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| try: | |
| # this raises a TypeError if `unit` is not None or iterable | |
| units = [None, None] if unit is None else list(unit) | |
| except TypeError: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a ' | |
| 'non-sequence {1}'.format(sclsnm, unit)) | |
| if len(units) == 2: | |
| try: | |
| if units[0] is not None: | |
| units[0] = u.Unit(units[0]) | |
| if units[1] is not None: | |
| units[1] = u.Unit(units[1]) | |
| except ValueError: | |
| raise ValueError('Could not convert units to unit objects ' | |
| 'while initializing ' + sclsnm) | |
| else: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a sequence ' | |
| 'of {1}.'.format(sclsnm, len(units))) | |
| if coordstr is not None: | |
| # need to try to parse the coordinate from a single argument | |
| # populates latval and lonval variables, which then get made | |
| # into coordinates below | |
| if isinstance(coordstr, six.string_types): | |
| if "," in coordstr: | |
| lonval, latval = coordstr.split(",") | |
| else: | |
| coosplit = coordstr.split() | |
| if len(coosplit) == 6: | |
| lonval = " ".join(coosplit[0:3]) | |
| latval = " ".join(coosplit[3:]) | |
| elif len(coosplit) == 2: | |
| lonval, latval = coosplit | |
| else: | |
| msg = ("Could not parse {lonname}/{latname} values " | |
| "from the string provided: '{coordstr}'.") | |
| raise ValueError(msg.format(lonname=lonname, | |
| latname=latname, | |
| coordstr=coordstr)) | |
| else: | |
| raise ValueError("A {0} cannot be created with a single value of type " | |
| "'{1}', must be a string.".format(sclsnm, type(coordstr).__name__)) | |
| # now actually create the angle objects | |
| lonang = Longitude(lonval, unit=units[0]) | |
| latang = Latitude(latval, unit=units[1]) | |
| dist = None if distval is None else Distance(distval) # copy | |
| elif cartinit and not angleinit: | |
| # cartesian-style initialization | |
| for v in [coordstr, lonval, latval, distval]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| if cartpoint is not None: | |
| for v in [x, y, z, unit]: | |
| if v is not None: | |
| raise ValueError('Cannot give both a CartesianPoints ' | |
| 'and x/y/z/unit parameters while ' | |
| 'initializing ' + sclsnm) | |
| x = cartpoint.x | |
| y = cartpoint.y | |
| z = cartpoint.z | |
| unit = cartpoint.unit | |
| > r, latval, lonval = cartesian_to_spherical(x, y, z) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:235: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| x = <CartesianPoints 0.0170822506606243>, y = <CartesianPoints 0.15781058025053168>, z = <CartesianPoints -0.9873216383090963> | |
| x : scalar or array-like | |
| The first cartesian coordinate. | |
| y : scalar or array-like | |
| The second cartesian coordinate. | |
| z : scalar or array-like | |
| The third cartesian coordinate. | |
| Returns | |
| ------- | |
| r : float or array | |
| The radial coordinate (in the same units as the inputs). | |
| lat : float or array | |
| The latitude in radians | |
| lon : float or array | |
| The longitude in radians | |
| """ | |
| xsq = x ** 2 | |
| ysq = y ** 2 | |
| zsq = z ** 2 | |
| r = (xsq + ysq + zsq) ** 0.5 | |
| s = (xsq + ysq) ** 0.5 | |
| if np.isscalar(x) and np.isscalar(y) and np.isscalar(z): | |
| lon = math.atan2(y, x) | |
| lat = math.atan2(z, s) | |
| else: | |
| lon = np.arctan2(y, x) | |
| lat = np.arctan2(z, s) | |
| return r, lat, lon | |
| def spherical_to_cartesian(r, lat, lon): | |
| """ | |
| Converts spherical polar coordinates to rectangular cartesian | |
| coordinates. | |
| Note that the input angles should be in latitude/longitude or | |
| elevation/azimuthal form. I.e., the origin is along the equator | |
| rather than at the north pole. | |
| .. note:: | |
| This is a low-level function used internally in | |
| > `astropy.coordinates`. It is provided for users if they really | |
| want to use it, but it is recommended that you use the | |
| `astropy.coordinates` coordinate systems. | |
| Parameters | |
| ---------- | |
| r : scalar or array-like | |
| The radial coordinate (in the same units as the inputs). | |
| lat : scalar or array-like | |
| The latitude in radians | |
| lon : scalar or array-like | |
| The longitude in radians | |
| Returns | |
| ------- | |
| x : float or array | |
| The first cartesian coordinate. | |
| y : float or array | |
| The second cartesian coordinate. | |
| z : float or array | |
| The third cartesian coordinate. | |
| """ | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:441: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints 0.15781058025053168>, obj = array(2.315841784746324e+77) | |
| context = (<ufunc 'arctan2'>, (<CartesianPoints 0.15781058025053168>, <CartesianPoints 0.0170822506606243>), 0) | |
| raise TypeError("The value must be a valid Python or " | |
| "Numpy numeric type.") | |
| # by default, cast any integer, boolean, etc., to float | |
| if dtype is None and not np.can_cast(np.float32, value.dtype): | |
| value = value.astype(np.float) | |
| value = value.view(cls) | |
| value._unit = unit | |
| return value | |
| def __array_finalize__(self, obj): | |
| self._unit = getattr(obj, '_unit', None) | |
| def __array_prepare__(self, obj, context=None): | |
| # This method gets called by Numpy whenever a ufunc is called on the | |
| # array. The object passed in ``obj`` is an empty version of the | |
| # output array which we can e.g. change to an array sub-class, add | |
| # attributes to, etc. After this is called, then the ufunc is called | |
| # and the values in this empty array are set. | |
| # If no context is set, just return the input | |
| if context is None: | |
| return obj | |
| # Find out which ufunc is being used | |
| function = context[0] | |
| from .quantity_helper import UNSUPPORTED_UFUNCS, UFUNC_HELPERS | |
| # Check whether we even support this ufunc | |
| if function in UNSUPPORTED_UFUNCS: | |
| raise TypeError("Cannot use function '{0}' with quantities" | |
| .format(function.__name__)) | |
| # Now find out what arguments were passed to the ufunc, usually, this | |
| # will include at least the present object, and another, which could | |
| # be a Quantity, or a Numpy array, etc. when using two-argument ufuncs. | |
| args = context[1][:function.nin] | |
| units = [getattr(arg, 'unit', None) for arg in args] | |
| # If the ufunc is supported, then we call a helper function (defined | |
| # in quantity_helper.py) which returns the scale by which the inputs | |
| # should be multiplied before being passed to the ufunc, as well as | |
| # the unit the output from the ufunc will have. | |
| if function in UFUNC_HELPERS: | |
| scales, result_unit = UFUNC_HELPERS[function](function, *units) | |
| else: | |
| raise TypeError("Unknown ufunc {0}. Please raise issue on " | |
| "https://github.com/astropy/astropy" | |
| .format(function.__name__)) | |
| if any(scale == 0. for scale in scales): | |
| # for two-argument ufuncs with a quantity and a non-quantity, | |
| # the quantity normally needs to be dimensionless, *except* | |
| # if the non-quantity can have arbitrary unit, i.e., when it | |
| # is all zero, infinity or NaN. In that case, the non-quantity | |
| # can just have the unit of the quantity | |
| # (this allows, e.g., `q > 0.` independent of unit) | |
| maybe_arbitrary_arg = args[scales.index(0.)] | |
| if _can_have_arbitrary_unit(maybe_arbitrary_arg): | |
| scales = [1., 1.] | |
| else: | |
| raise UnitsError("Can only apply '{0}' function to " | |
| "dimensionless quantities when other " | |
| "argument is not a quantity (unless the " | |
| "latter is all zero/infinity/nan)" | |
| .format(function.__name__)) | |
| # In the case of np.power, the unit itself needs to be modified by an | |
| # amount that depends on one of the input values, so we need to treat | |
| # this as a special case. | |
| # TODO: find a better way to deal with this case | |
| if function is np.power and result_unit is not None: | |
| if units[1] is None: | |
| p = args[1] | |
| else: | |
| p = args[1].to(dimensionless_unscaled).value | |
| result_unit = result_unit ** validate_power(p) | |
| # We now prepare the output object | |
| if self is obj: # happens if the output object is self, which happens | |
| # for in-place operations such as q1 += q2 | |
| # In some cases, the result of a ufunc should be a plain Numpy | |
| # array, which we can't do if we are doing an in-place operation. | |
| if result_unit is None: | |
| raise TypeError("Cannot store non-quantity output from {0} " | |
| "function in Quantity object" | |
| .format(function.__name__)) | |
| /Users/adam/repos/astropy/astropy/units/quantity.py:311: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints 0.15781058025053168>, obj = array(2.315841784746324e+77), unit = Unit("rad") | |
| #screw up the units are killed by _convert_to_and_validate_length_unit | |
| obj = super(CartesianPoints, self).__array_wrap__(obj, context=context) | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:310: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = AssertionError(), args = (), f = <py._code.code.Frame object at 0x1096a2090> | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| > ??? | |
| _pytest.assertion.reinterpret:40: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| frame = <py._code.code.Frame object at 0x1096a2090>, should_fail = True | |
| > ??? | |
| _pytest.assertion.newinterpret:46: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| filename = '<unknown>', mode = 'exec' | |
| def parse(source, filename='<unknown>', mode='exec'): | |
| """ | |
| Parse the source into an AST node. | |
| Equivalent to compile(source, filename, mode, PyCF_ONLY_AST). | |
| """ | |
| > return compile(source, filename, mode, PyCF_ONLY_AST) | |
| E File "<unknown>", line 1 | |
| E .. note:: | |
| E ^ | |
| E SyntaxError: invalid syntax | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py:37: SyntaxError | |
| ______________________________________________________ test_query_region[coordinates2-5d0m0s-None-None] _______________________________________________________ | |
| patch_post = <_pytest.monkeypatch.monkeypatch instance at 0x108210e60>, coordinates = <FK4 RA=84.90759 deg, Dec=-80.89403 deg>, radius = '5d0m0s' | |
| equinox = None, epoch = None | |
| @pytest.mark.parametrize(('coordinates', 'radius', 'equinox', 'epoch'), | |
| [(ICRS_COORDS, None, None, None), | |
| (GALACTIC_COORDS, 5 * u.deg, 2000.0, 'J2000'), | |
| (FK4_COORDS, '5d0m0s', None, None), | |
| (FK5_COORDS, None, None, None) | |
| ]) | |
| def test_query_region(patch_post, coordinates, radius, equinox, epoch): | |
| result1 = simbad.core.Simbad.query_region(coordinates, radius=radius, | |
| > equinox=equinox, epoch=epoch) | |
| astroquery/simbad/tests/test_simbad.py:227: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.simbad.core.SimbadClass object at 0x107c40e50>, coordinates = <FK4 RA=84.90759 deg, Dec=-80.89403 deg>, radius = '5d0m0s', equinox = None | |
| epoch = None, verbose = False | |
| def query_region(self, coordinates, radius=None, | |
| equinox=None, epoch=None, verbose=False): | |
| """ | |
| Queries around an object or coordinates as per the specified radius and | |
| returns the results in a `~astropy.table.Table`. | |
| Parameters | |
| ---------- | |
| coordinates : str / `astropy.coordinates` | |
| the identifier or coordinates around which to query. | |
| radius : str / `~astropy.units.Quantity`, optional | |
| the radius of the region. If missing, set to default | |
| value of 20 arcmin. | |
| equinox : float, optional | |
| the equinox of the coordinates. If missing set to | |
| default 2000.0. | |
| epoch : str, optional | |
| the epoch of the input coordiantes. Must be specified as | |
| [J|B] <epoch>. If missing, set to default J2000. | |
| Returns | |
| ------- | |
| table : `~astropy.table.Table` | |
| Query results table | |
| """ | |
| # if the identifier is given rather than the coordinates, convert to | |
| # coordinates | |
| result = self.query_region_async(coordinates, radius=radius, | |
| > equinox=equinox, epoch=epoch) | |
| astroquery/simbad/core.py:439: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.simbad.core.SimbadClass object at 0x107c40e50>, coordinates = <FK4 RA=84.90759 deg, Dec=-80.89403 deg>, radius = '5d0m0s', equinox = None | |
| epoch = None | |
| def query_region_async(self, coordinates, radius=None, equinox=None, | |
| epoch=None): | |
| """ | |
| Serves the same function as `query_region`, but | |
| only collects the reponse from the Simbad server and returns. | |
| Parameters | |
| ---------- | |
| coordinates : str/`astropy.coordinates` | |
| the identifier or coordinates around which to query. | |
| radius : str/`~astropy.units.Quantity`, optional | |
| the radius of the region. If missing, set to default | |
| value of 20 arcmin. | |
| equinox : float, optional | |
| the equinox of the coordinates. If missing set to | |
| default 2000.0. | |
| epoch : str, optional | |
| the epoch of the input coordiantes. Must be specified as | |
| [J|B] <epoch>. If missing, set to default J2000. | |
| Returns | |
| ------- | |
| response : `requests.Response` | |
| Response of the query from the server. | |
| """ | |
| request_payload = self._args_to_payload(coordinates, radius=radius, | |
| equinox=equinox, epoch=epoch, | |
| > caller='query_region_async') | |
| astroquery/simbad/core.py:469: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| args = (<astroquery.simbad.core.SimbadClass object at 0x107c40e50>, <FK4 RA=84.90759 deg, Dec=-80.89403 deg>) | |
| kwargs = {'caller': 'query_region_async', 'epoch': None, 'equinox': None, 'radius': '5d0m0s'} | |
| def wrapper(*args, **kwargs): | |
| if kwargs.get('epoch'): | |
| value = kwargs['epoch'] | |
| try: | |
| p = re.compile('^[JB]\d+[.]?\d+$', re.IGNORECASE) | |
| assert p.match(value) is not None | |
| except (AssertionError, TypeError): | |
| raise ValueError("Epoch must be specified as [J|B]<epoch>.\n" | |
| "Example: epoch='J2000'") | |
| > return func(*args, **kwargs) | |
| astroquery/simbad/core.py:43: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| args = (<astroquery.simbad.core.SimbadClass object at 0x107c40e50>, <FK4 RA=84.90759 deg, Dec=-80.89403 deg>) | |
| kwargs = {'caller': 'query_region_async', 'epoch': None, 'equinox': None, 'radius': '5d0m0s'} | |
| def wrapper(*args, **kwargs): | |
| if kwargs.get('equinox'): | |
| value = kwargs['equinox'] | |
| try: | |
| float(value) | |
| except ValueError: | |
| raise ValueError("Equinox must be a number") | |
| > return func(*args, **kwargs) | |
| astroquery/simbad/core.py:59: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.simbad.core.SimbadClass object at 0x107c40e50>, args = (), kwargs = {'epoch': None, 'equinox': None, 'radius': '5d0m0s'} | |
| script = '\nvotable {main_id,coordinates}\nvotable open\nquery coo', caller = 'query_region_async', get_raw = False, command = 'query coo' | |
| votable_fields = 'main_id,coordinates', votable_def = 'votable {main_id,coordinates}', votable_open = 'votable open', votable_close = 'votable close' | |
| coordinates = <FK4 RA=84.90759 deg, Dec=-80.89403 deg> | |
| @validate_epoch | |
| @validate_equinox | |
| def _args_to_payload(self, *args, **kwargs): | |
| """ | |
| Takes the arguments from any of the query functions | |
| and returns a dictionary that can be used as the | |
| data for an HTTP POST request. | |
| """ | |
| script = "" | |
| caller = kwargs['caller'] | |
| del kwargs['caller'] | |
| get_raw = kwargs.get('get_raw', False) | |
| if get_raw: | |
| del kwargs['get_raw'] | |
| command = self._function_to_command[caller] | |
| votable_fields = ','.join(self.get_votable_fields()) | |
| # if get_raw is set then don't fetch as votable | |
| votable_def = ("votable {" + votable_fields + "}", "")[get_raw] | |
| votable_open = ("votable open", "")[get_raw] | |
| votable_close = ("votable close", "")[get_raw] | |
| if self.ROW_LIMIT > 0: | |
| script = "set limit " + str(self.ROW_LIMIT) | |
| script = "\n".join([script, votable_def, votable_open, command]) | |
| if kwargs.get('wildcard'): | |
| script += " wildcard" # necessary to have a space at the beginning | |
| del kwargs['wildcard'] | |
| # now append args and kwds as per the caller | |
| # if caller is query_region_async write coordinates as separate ra dec | |
| if caller == 'query_region_async': | |
| coordinates = args[0] | |
| args = args[1:] | |
| > ra, dec, frame = _parse_coordinates(coordinates) | |
| astroquery/simbad/core.py:635: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| coordinates = <FK4 RA=84.90759 deg, Dec=-80.89403 deg> | |
| def _parse_coordinates(coordinates): | |
| try: | |
| c = commons.parse_coordinates(coordinates) | |
| # now c has some subclass of astropy.coordinate | |
| # get ra, dec and frame | |
| > return _get_frame_coords(c) | |
| astroquery/simbad/core.py:689: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| c = <FK4 RA=84.90759 deg, Dec=-80.89403 deg> | |
| def _get_frame_coords(c): | |
| > if c.icrs == c: | |
| astroquery/simbad/core.py:695: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <FK4 RA=84.90759 deg, Dec=-80.89403 deg>, name = 'icrs' | |
| def __getattr__(self, name): | |
| """ | |
| Overrides getattr to return coordinates that this can be transformed | |
| to, based on the alias name in the master transform graph. | |
| """ | |
| from .transformations import master_transform_graph | |
| nmsys = master_transform_graph.lookup_name(name) | |
| if self.__class__ is nmsys: | |
| return self | |
| if nmsys is not None and self.is_transformable_to(nmsys): | |
| > return self.transform_to(nmsys) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:659: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <FK4 RA=84.90759 deg, Dec=-80.89403 deg>, tosys = <class 'astropy.coordinates.builtin_systems.ICRS'> | |
| def transform_to(self, tosys): | |
| """ | |
| Transform this coordinate to a new system. | |
| Parameters | |
| ---------- | |
| tosys : class | |
| The system to transform this coordinate into. | |
| Returns | |
| ------- | |
| transcoord | |
| A new object with this coordinate represented in the | |
| ``tosys`` system. | |
| Raises | |
| ------ | |
| ValueError | |
| If there is no possible transformation route. | |
| """ | |
| from .transformations import master_transform_graph | |
| from .errors import ConvertError | |
| if tosys is self.__class__: | |
| return copy.deepcopy(self) | |
| trans = master_transform_graph.get_transform(self.__class__, tosys) | |
| if trans is None: | |
| raise ConvertError('Cannot transform from {0} to ' | |
| '{1}'.format(self.__class__, tosys)) | |
| > return trans(self) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:622: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.CompositeTransform object at 0x108242790>, fromcoord = <FK4 RA=84.90759 deg, Dec=-80.89403 deg> | |
| super(CompositeTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| > coord = fromcoord | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:742: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.DynamicMatrixTransform object at 0x1067c58d0>, fromcoord = <FK4NoETerms RA=84.90701 deg, Dec=-80.89400 deg> | |
| super(DynamicMatrixTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| c = fromcoord.cartesian | |
| v = c.reshape((3, c.size // 3)) | |
| v2 = np.dot(np.asarray(self.matrix_func(fromcoord)), v) | |
| subshape = c.shape[1:] | |
| x = v2[0].reshape(subshape) | |
| y = v2[1].reshape(subshape) | |
| z = v2[2].reshape(subshape) | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:708: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x109e99368>, args = () | |
| kwargs = {'unit': None, 'x': <CartesianPoints 0.017083352278353055>, 'y': <CartesianPoints 0.15781065479713563>, 'z': <CartesianPoints -0.9873216073334123>} | |
| def __init__(self, *args, **kwargs): | |
| super(FK5, self).__init__() | |
| self._equinox = kwargs.pop('equinox', _EQUINOX_J2000) | |
| self._obstime = kwargs.pop('obstime', None) | |
| if not isinstance(self._equinox, Time): | |
| raise TypeError('specified equinox is not a Time object') | |
| if self._obstime is not None and not isinstance(self._obstime, Time): | |
| raise TypeError('specified obstime is not None or a Time object') | |
| if not self._equinox.isscalar: | |
| raise ValueError('specified equinox is not a scalar') | |
| if len(args) == 1 and len(kwargs) == 0 and isinstance(args[0], SphericalCoordinatesBase): | |
| newcoord = args[0].transform_to(self.__class__) | |
| self._latangle = newcoord._latangle | |
| self._lonangle = newcoord._lonangle | |
| self._distance = newcoord._distance | |
| else: | |
| > super(FK5, self)._initialize_latlon('ra', 'dec', args, kwargs) | |
| /Users/adam/repos/astropy/astropy/coordinates/builtin_systems.py:140: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x10ac758c0>, lonname = 'ra' | |
| latname = 'dec', initargs = (), initkwargs = {} | |
| def _initialize_latlon(self, lonname, latname, initargs, initkwargs): | |
| """ | |
| Subclasses should use this to initialize standard lat/lon-style | |
| coordinates. | |
| This recognizes both the lat/lon style and the cartesian form. | |
| Parameters | |
| ---------- | |
| lonname : str | |
| The name of the longitude-like coordinate attribute | |
| latname : str | |
| The name of the latitude-like coordinate attribute | |
| initargs : list | |
| The ``*args`` from the initializer | |
| initkwargs : dict | |
| The ``**kwargs`` from the initializer | |
| """ | |
| initkwargs = dict(initkwargs) # copy | |
| nargs = len(initargs) | |
| sclsnm = self.__class__.__name__ | |
| if nargs == 1: | |
| if isinstance(initargs[0], CartesianPoints): | |
| initkwargs['cartpoint'] = initargs[0] | |
| else: | |
| initkwargs['coordstr'] = initargs[0] | |
| if nargs > 1: | |
| if lonname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, lonname)) | |
| initkwargs[lonname] = initargs[0] | |
| if nargs >= 2: | |
| if latname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, latname)) | |
| initkwargs[latname] = initargs[1] | |
| if nargs > 2: | |
| raise TypeError('{0} takes up to 2 positional arguments ' | |
| '({1} given)'.format(sclsnm, len(initargs))) | |
| unit = initkwargs.pop('unit', None) | |
| coordstr = initkwargs.pop('coordstr', None) | |
| lonval = initkwargs.pop(lonname, None) | |
| latval = initkwargs.pop(latname, None) | |
| distval = initkwargs.pop('distance', None) | |
| cartpoint = initkwargs.pop('cartpoint', None) | |
| x = initkwargs.pop('x', None) | |
| y = initkwargs.pop('y', None) | |
| z = initkwargs.pop('z', None) | |
| if len(initkwargs) > 0: | |
| raise TypeError('{0} got unexpected keyword argument' | |
| ' {1}'.format(sclsnm, initkwargs.keys())) | |
| angleinit = ((lonval is not None and latval is not None) or | |
| coordstr is not None) | |
| cartinit = ((x is not None and y is not None and z is not None) or | |
| cartpoint is not None) | |
| if angleinit and not cartinit: | |
| # lat/lon-style initialization | |
| for v in [x, y, z, cartpoint]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| try: | |
| # this raises a TypeError if `unit` is not None or iterable | |
| units = [None, None] if unit is None else list(unit) | |
| except TypeError: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a ' | |
| 'non-sequence {1}'.format(sclsnm, unit)) | |
| if len(units) == 2: | |
| try: | |
| if units[0] is not None: | |
| units[0] = u.Unit(units[0]) | |
| if units[1] is not None: | |
| units[1] = u.Unit(units[1]) | |
| except ValueError: | |
| raise ValueError('Could not convert units to unit objects ' | |
| 'while initializing ' + sclsnm) | |
| else: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a sequence ' | |
| 'of {1}.'.format(sclsnm, len(units))) | |
| if coordstr is not None: | |
| # need to try to parse the coordinate from a single argument | |
| # populates latval and lonval variables, which then get made | |
| # into coordinates below | |
| if isinstance(coordstr, six.string_types): | |
| if "," in coordstr: | |
| lonval, latval = coordstr.split(",") | |
| else: | |
| coosplit = coordstr.split() | |
| if len(coosplit) == 6: | |
| lonval = " ".join(coosplit[0:3]) | |
| latval = " ".join(coosplit[3:]) | |
| elif len(coosplit) == 2: | |
| lonval, latval = coosplit | |
| else: | |
| msg = ("Could not parse {lonname}/{latname} values " | |
| "from the string provided: '{coordstr}'.") | |
| raise ValueError(msg.format(lonname=lonname, | |
| latname=latname, | |
| coordstr=coordstr)) | |
| else: | |
| raise ValueError("A {0} cannot be created with a single value of type " | |
| "'{1}', must be a string.".format(sclsnm, type(coordstr).__name__)) | |
| # now actually create the angle objects | |
| lonang = Longitude(lonval, unit=units[0]) | |
| latang = Latitude(latval, unit=units[1]) | |
| dist = None if distval is None else Distance(distval) # copy | |
| elif cartinit and not angleinit: | |
| # cartesian-style initialization | |
| for v in [coordstr, lonval, latval, distval]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| if cartpoint is not None: | |
| for v in [x, y, z, unit]: | |
| if v is not None: | |
| raise ValueError('Cannot give both a CartesianPoints ' | |
| 'and x/y/z/unit parameters while ' | |
| 'initializing ' + sclsnm) | |
| x = cartpoint.x | |
| y = cartpoint.y | |
| z = cartpoint.z | |
| unit = cartpoint.unit | |
| > r, latval, lonval = cartesian_to_spherical(x, y, z) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:235: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| x = <CartesianPoints 0.017083352278353055>, y = <CartesianPoints 0.15781065479713563>, z = <CartesianPoints -0.9873216073334123> | |
| x : scalar or array-like | |
| The first cartesian coordinate. | |
| y : scalar or array-like | |
| The second cartesian coordinate. | |
| z : scalar or array-like | |
| The third cartesian coordinate. | |
| Returns | |
| ------- | |
| r : float or array | |
| The radial coordinate (in the same units as the inputs). | |
| lat : float or array | |
| The latitude in radians | |
| lon : float or array | |
| The longitude in radians | |
| """ | |
| xsq = x ** 2 | |
| ysq = y ** 2 | |
| zsq = z ** 2 | |
| r = (xsq + ysq + zsq) ** 0.5 | |
| s = (xsq + ysq) ** 0.5 | |
| if np.isscalar(x) and np.isscalar(y) and np.isscalar(z): | |
| lon = math.atan2(y, x) | |
| lat = math.atan2(z, s) | |
| else: | |
| lon = np.arctan2(y, x) | |
| lat = np.arctan2(z, s) | |
| return r, lat, lon | |
| def spherical_to_cartesian(r, lat, lon): | |
| """ | |
| Converts spherical polar coordinates to rectangular cartesian | |
| coordinates. | |
| Note that the input angles should be in latitude/longitude or | |
| elevation/azimuthal form. I.e., the origin is along the equator | |
| rather than at the north pole. | |
| .. note:: | |
| This is a low-level function used internally in | |
| > `astropy.coordinates`. It is provided for users if they really | |
| want to use it, but it is recommended that you use the | |
| `astropy.coordinates` coordinate systems. | |
| Parameters | |
| ---------- | |
| r : scalar or array-like | |
| The radial coordinate (in the same units as the inputs). | |
| lat : scalar or array-like | |
| The latitude in radians | |
| lon : scalar or array-like | |
| The longitude in radians | |
| Returns | |
| ------- | |
| x : float or array | |
| The first cartesian coordinate. | |
| y : float or array | |
| The second cartesian coordinate. | |
| z : float or array | |
| The third cartesian coordinate. | |
| """ | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:441: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints 0.15781065479713563>, obj = array(2.315841784746324e+77) | |
| context = (<ufunc 'arctan2'>, (<CartesianPoints 0.15781065479713563>, <CartesianPoints 0.017083352278353055>), 0) | |
| raise TypeError("The value must be a valid Python or " | |
| "Numpy numeric type.") | |
| # by default, cast any integer, boolean, etc., to float | |
| if dtype is None and not np.can_cast(np.float32, value.dtype): | |
| value = value.astype(np.float) | |
| value = value.view(cls) | |
| value._unit = unit | |
| return value | |
| def __array_finalize__(self, obj): | |
| self._unit = getattr(obj, '_unit', None) | |
| def __array_prepare__(self, obj, context=None): | |
| # This method gets called by Numpy whenever a ufunc is called on the | |
| # array. The object passed in ``obj`` is an empty version of the | |
| # output array which we can e.g. change to an array sub-class, add | |
| # attributes to, etc. After this is called, then the ufunc is called | |
| # and the values in this empty array are set. | |
| # If no context is set, just return the input | |
| if context is None: | |
| return obj | |
| # Find out which ufunc is being used | |
| function = context[0] | |
| from .quantity_helper import UNSUPPORTED_UFUNCS, UFUNC_HELPERS | |
| # Check whether we even support this ufunc | |
| if function in UNSUPPORTED_UFUNCS: | |
| raise TypeError("Cannot use function '{0}' with quantities" | |
| .format(function.__name__)) | |
| # Now find out what arguments were passed to the ufunc, usually, this | |
| # will include at least the present object, and another, which could | |
| # be a Quantity, or a Numpy array, etc. when using two-argument ufuncs. | |
| args = context[1][:function.nin] | |
| units = [getattr(arg, 'unit', None) for arg in args] | |
| # If the ufunc is supported, then we call a helper function (defined | |
| # in quantity_helper.py) which returns the scale by which the inputs | |
| # should be multiplied before being passed to the ufunc, as well as | |
| # the unit the output from the ufunc will have. | |
| if function in UFUNC_HELPERS: | |
| scales, result_unit = UFUNC_HELPERS[function](function, *units) | |
| else: | |
| raise TypeError("Unknown ufunc {0}. Please raise issue on " | |
| "https://github.com/astropy/astropy" | |
| .format(function.__name__)) | |
| if any(scale == 0. for scale in scales): | |
| # for two-argument ufuncs with a quantity and a non-quantity, | |
| # the quantity normally needs to be dimensionless, *except* | |
| # if the non-quantity can have arbitrary unit, i.e., when it | |
| # is all zero, infinity or NaN. In that case, the non-quantity | |
| # can just have the unit of the quantity | |
| # (this allows, e.g., `q > 0.` independent of unit) | |
| maybe_arbitrary_arg = args[scales.index(0.)] | |
| if _can_have_arbitrary_unit(maybe_arbitrary_arg): | |
| scales = [1., 1.] | |
| else: | |
| raise UnitsError("Can only apply '{0}' function to " | |
| "dimensionless quantities when other " | |
| "argument is not a quantity (unless the " | |
| "latter is all zero/infinity/nan)" | |
| .format(function.__name__)) | |
| # In the case of np.power, the unit itself needs to be modified by an | |
| # amount that depends on one of the input values, so we need to treat | |
| # this as a special case. | |
| # TODO: find a better way to deal with this case | |
| if function is np.power and result_unit is not None: | |
| if units[1] is None: | |
| p = args[1] | |
| else: | |
| p = args[1].to(dimensionless_unscaled).value | |
| result_unit = result_unit ** validate_power(p) | |
| # We now prepare the output object | |
| if self is obj: # happens if the output object is self, which happens | |
| # for in-place operations such as q1 += q2 | |
| # In some cases, the result of a ufunc should be a plain Numpy | |
| # array, which we can't do if we are doing an in-place operation. | |
| if result_unit is None: | |
| raise TypeError("Cannot store non-quantity output from {0} " | |
| "function in Quantity object" | |
| .format(function.__name__)) | |
| /Users/adam/repos/astropy/astropy/units/quantity.py:311: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints 0.15781065479713563>, obj = array(2.315841784746324e+77), unit = Unit("rad") | |
| #screw up the units are killed by _convert_to_and_validate_length_unit | |
| obj = super(CartesianPoints, self).__array_wrap__(obj, context=context) | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:310: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = AssertionError(), args = (), f = <py._code.code.Frame object at 0x1096b3f50> | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| > ??? | |
| _pytest.assertion.reinterpret:40: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| frame = <py._code.code.Frame object at 0x1096b3f50>, should_fail = True | |
| > ??? | |
| _pytest.assertion.newinterpret:46: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| filename = '<unknown>', mode = 'exec' | |
| def parse(source, filename='<unknown>', mode='exec'): | |
| """ | |
| Parse the source into an AST node. | |
| Equivalent to compile(source, filename, mode, PyCF_ONLY_AST). | |
| """ | |
| > return compile(source, filename, mode, PyCF_ONLY_AST) | |
| E File "<unknown>", line 1 | |
| E .. note:: | |
| E ^ | |
| E SyntaxError: invalid syntax | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py:37: SyntaxError | |
| _______________________________________________________ test_query_region[coordinates3-None-None-None] ________________________________________________________ | |
| patch_post = <_pytest.monkeypatch.monkeypatch instance at 0x1095ae518>, coordinates = <FK5 RA=83.82207 deg, Dec=-80.86667 deg>, radius = None, equinox = None | |
| epoch = None | |
| @pytest.mark.parametrize(('coordinates', 'radius', 'equinox', 'epoch'), | |
| [(ICRS_COORDS, None, None, None), | |
| (GALACTIC_COORDS, 5 * u.deg, 2000.0, 'J2000'), | |
| (FK4_COORDS, '5d0m0s', None, None), | |
| (FK5_COORDS, None, None, None) | |
| ]) | |
| def test_query_region(patch_post, coordinates, radius, equinox, epoch): | |
| result1 = simbad.core.Simbad.query_region(coordinates, radius=radius, | |
| > equinox=equinox, epoch=epoch) | |
| astroquery/simbad/tests/test_simbad.py:227: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.simbad.core.SimbadClass object at 0x107c40e50>, coordinates = <FK5 RA=83.82207 deg, Dec=-80.86667 deg>, radius = None, equinox = None | |
| epoch = None, verbose = False | |
| def query_region(self, coordinates, radius=None, | |
| equinox=None, epoch=None, verbose=False): | |
| """ | |
| Queries around an object or coordinates as per the specified radius and | |
| returns the results in a `~astropy.table.Table`. | |
| Parameters | |
| ---------- | |
| coordinates : str / `astropy.coordinates` | |
| the identifier or coordinates around which to query. | |
| radius : str / `~astropy.units.Quantity`, optional | |
| the radius of the region. If missing, set to default | |
| value of 20 arcmin. | |
| equinox : float, optional | |
| the equinox of the coordinates. If missing set to | |
| default 2000.0. | |
| epoch : str, optional | |
| the epoch of the input coordiantes. Must be specified as | |
| [J|B] <epoch>. If missing, set to default J2000. | |
| Returns | |
| ------- | |
| table : `~astropy.table.Table` | |
| Query results table | |
| """ | |
| # if the identifier is given rather than the coordinates, convert to | |
| # coordinates | |
| result = self.query_region_async(coordinates, radius=radius, | |
| > equinox=equinox, epoch=epoch) | |
| astroquery/simbad/core.py:439: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.simbad.core.SimbadClass object at 0x107c40e50>, coordinates = <FK5 RA=83.82207 deg, Dec=-80.86667 deg>, radius = None, equinox = None | |
| epoch = None | |
| def query_region_async(self, coordinates, radius=None, equinox=None, | |
| epoch=None): | |
| """ | |
| Serves the same function as `query_region`, but | |
| only collects the reponse from the Simbad server and returns. | |
| Parameters | |
| ---------- | |
| coordinates : str/`astropy.coordinates` | |
| the identifier or coordinates around which to query. | |
| radius : str/`~astropy.units.Quantity`, optional | |
| the radius of the region. If missing, set to default | |
| value of 20 arcmin. | |
| equinox : float, optional | |
| the equinox of the coordinates. If missing set to | |
| default 2000.0. | |
| epoch : str, optional | |
| the epoch of the input coordiantes. Must be specified as | |
| [J|B] <epoch>. If missing, set to default J2000. | |
| Returns | |
| ------- | |
| response : `requests.Response` | |
| Response of the query from the server. | |
| """ | |
| request_payload = self._args_to_payload(coordinates, radius=radius, | |
| equinox=equinox, epoch=epoch, | |
| > caller='query_region_async') | |
| astroquery/simbad/core.py:469: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| args = (<astroquery.simbad.core.SimbadClass object at 0x107c40e50>, <FK5 RA=83.82207 deg, Dec=-80.86667 deg>) | |
| kwargs = {'caller': 'query_region_async', 'epoch': None, 'equinox': None, 'radius': None} | |
| def wrapper(*args, **kwargs): | |
| if kwargs.get('epoch'): | |
| value = kwargs['epoch'] | |
| try: | |
| p = re.compile('^[JB]\d+[.]?\d+$', re.IGNORECASE) | |
| assert p.match(value) is not None | |
| except (AssertionError, TypeError): | |
| raise ValueError("Epoch must be specified as [J|B]<epoch>.\n" | |
| "Example: epoch='J2000'") | |
| > return func(*args, **kwargs) | |
| astroquery/simbad/core.py:43: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| args = (<astroquery.simbad.core.SimbadClass object at 0x107c40e50>, <FK5 RA=83.82207 deg, Dec=-80.86667 deg>) | |
| kwargs = {'caller': 'query_region_async', 'epoch': None, 'equinox': None, 'radius': None} | |
| def wrapper(*args, **kwargs): | |
| if kwargs.get('equinox'): | |
| value = kwargs['equinox'] | |
| try: | |
| float(value) | |
| except ValueError: | |
| raise ValueError("Equinox must be a number") | |
| > return func(*args, **kwargs) | |
| astroquery/simbad/core.py:59: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.simbad.core.SimbadClass object at 0x107c40e50>, args = (), kwargs = {'epoch': None, 'equinox': None, 'radius': None} | |
| script = '\nvotable {main_id,coordinates}\nvotable open\nquery coo', caller = 'query_region_async', get_raw = False, command = 'query coo' | |
| votable_fields = 'main_id,coordinates', votable_def = 'votable {main_id,coordinates}', votable_open = 'votable open', votable_close = 'votable close' | |
| coordinates = <FK5 RA=83.82207 deg, Dec=-80.86667 deg> | |
| @validate_epoch | |
| @validate_equinox | |
| def _args_to_payload(self, *args, **kwargs): | |
| """ | |
| Takes the arguments from any of the query functions | |
| and returns a dictionary that can be used as the | |
| data for an HTTP POST request. | |
| """ | |
| script = "" | |
| caller = kwargs['caller'] | |
| del kwargs['caller'] | |
| get_raw = kwargs.get('get_raw', False) | |
| if get_raw: | |
| del kwargs['get_raw'] | |
| command = self._function_to_command[caller] | |
| votable_fields = ','.join(self.get_votable_fields()) | |
| # if get_raw is set then don't fetch as votable | |
| votable_def = ("votable {" + votable_fields + "}", "")[get_raw] | |
| votable_open = ("votable open", "")[get_raw] | |
| votable_close = ("votable close", "")[get_raw] | |
| if self.ROW_LIMIT > 0: | |
| script = "set limit " + str(self.ROW_LIMIT) | |
| script = "\n".join([script, votable_def, votable_open, command]) | |
| if kwargs.get('wildcard'): | |
| script += " wildcard" # necessary to have a space at the beginning | |
| del kwargs['wildcard'] | |
| # now append args and kwds as per the caller | |
| # if caller is query_region_async write coordinates as separate ra dec | |
| if caller == 'query_region_async': | |
| coordinates = args[0] | |
| args = args[1:] | |
| > ra, dec, frame = _parse_coordinates(coordinates) | |
| astroquery/simbad/core.py:635: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| coordinates = <FK5 RA=83.82207 deg, Dec=-80.86667 deg> | |
| def _parse_coordinates(coordinates): | |
| try: | |
| c = commons.parse_coordinates(coordinates) | |
| # now c has some subclass of astropy.coordinate | |
| # get ra, dec and frame | |
| > return _get_frame_coords(c) | |
| astroquery/simbad/core.py:689: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| c = <FK5 RA=83.82207 deg, Dec=-80.86667 deg> | |
| def _get_frame_coords(c): | |
| > if c.icrs == c: | |
| astroquery/simbad/core.py:695: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <FK5 RA=83.82207 deg, Dec=-80.86667 deg>, name = 'icrs' | |
| def __getattr__(self, name): | |
| """ | |
| Overrides getattr to return coordinates that this can be transformed | |
| to, based on the alias name in the master transform graph. | |
| """ | |
| from .transformations import master_transform_graph | |
| nmsys = master_transform_graph.lookup_name(name) | |
| if self.__class__ is nmsys: | |
| return self | |
| if nmsys is not None and self.is_transformable_to(nmsys): | |
| > return self.transform_to(nmsys) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:659: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <FK5 RA=83.82207 deg, Dec=-80.86667 deg>, tosys = <class 'astropy.coordinates.builtin_systems.ICRS'> | |
| def transform_to(self, tosys): | |
| """ | |
| Transform this coordinate to a new system. | |
| Parameters | |
| ---------- | |
| tosys : class | |
| The system to transform this coordinate into. | |
| Returns | |
| ------- | |
| transcoord | |
| A new object with this coordinate represented in the | |
| ``tosys`` system. | |
| Raises | |
| ------ | |
| ValueError | |
| If there is no possible transformation route. | |
| """ | |
| from .transformations import master_transform_graph | |
| from .errors import ConvertError | |
| if tosys is self.__class__: | |
| return copy.deepcopy(self) | |
| trans = master_transform_graph.get_transform(self.__class__, tosys) | |
| if trans is None: | |
| raise ConvertError('Cannot transform from {0} to ' | |
| '{1}'.format(self.__class__, tosys)) | |
| > return trans(self) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:622: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.DynamicMatrixTransform object at 0x1067c5390>, fromcoord = <FK5 RA=83.82207 deg, Dec=-80.86667 deg> | |
| super(DynamicMatrixTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| c = fromcoord.cartesian | |
| v = c.reshape((3, c.size // 3)) | |
| v2 = np.dot(np.asarray(self.matrix_func(fromcoord)), v) | |
| subshape = c.shape[1:] | |
| x = v2[0].reshape(subshape) | |
| y = v2[1].reshape(subshape) | |
| z = v2[2].reshape(subshape) | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:708: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'ICRS' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x10a106518>, args = () | |
| kwargs = {'unit': None, 'x': <CartesianPoints 0.01708218844397828>, 'y': <CartesianPoints 0.15781069037526652>, 'z': <CartesianPoints -0.9873216217835231>} | |
| def __init__(self, *args, **kwargs): | |
| super(ICRS, self).__init__() | |
| self._obstime = kwargs.pop('obstime', None) | |
| if self._obstime is not None and not isinstance(self._obstime, Time): | |
| raise TypeError('specified obstime is not None or a Time object') | |
| if len(args) == 1 and len(kwargs) == 0 and isinstance(args[0], SphericalCoordinatesBase): | |
| newcoord = args[0].transform_to(self.__class__) | |
| self._latangle = newcoord._latangle | |
| self._lonangle = newcoord._lonangle | |
| self._distance = newcoord._distance | |
| else: | |
| > super(ICRS, self)._initialize_latlon('ra', 'dec', args, kwargs) | |
| /Users/adam/repos/astropy/astropy/coordinates/builtin_systems.py:72: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'ICRS' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x1199604d0>, lonname = 'ra' | |
| latname = 'dec', initargs = (), initkwargs = {} | |
| def _initialize_latlon(self, lonname, latname, initargs, initkwargs): | |
| """ | |
| Subclasses should use this to initialize standard lat/lon-style | |
| coordinates. | |
| This recognizes both the lat/lon style and the cartesian form. | |
| Parameters | |
| ---------- | |
| lonname : str | |
| The name of the longitude-like coordinate attribute | |
| latname : str | |
| The name of the latitude-like coordinate attribute | |
| initargs : list | |
| The ``*args`` from the initializer | |
| initkwargs : dict | |
| The ``**kwargs`` from the initializer | |
| """ | |
| initkwargs = dict(initkwargs) # copy | |
| nargs = len(initargs) | |
| sclsnm = self.__class__.__name__ | |
| if nargs == 1: | |
| if isinstance(initargs[0], CartesianPoints): | |
| initkwargs['cartpoint'] = initargs[0] | |
| else: | |
| initkwargs['coordstr'] = initargs[0] | |
| if nargs > 1: | |
| if lonname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, lonname)) | |
| initkwargs[lonname] = initargs[0] | |
| if nargs >= 2: | |
| if latname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, latname)) | |
| initkwargs[latname] = initargs[1] | |
| if nargs > 2: | |
| raise TypeError('{0} takes up to 2 positional arguments ' | |
| '({1} given)'.format(sclsnm, len(initargs))) | |
| unit = initkwargs.pop('unit', None) | |
| coordstr = initkwargs.pop('coordstr', None) | |
| lonval = initkwargs.pop(lonname, None) | |
| latval = initkwargs.pop(latname, None) | |
| distval = initkwargs.pop('distance', None) | |
| cartpoint = initkwargs.pop('cartpoint', None) | |
| x = initkwargs.pop('x', None) | |
| y = initkwargs.pop('y', None) | |
| z = initkwargs.pop('z', None) | |
| if len(initkwargs) > 0: | |
| raise TypeError('{0} got unexpected keyword argument' | |
| ' {1}'.format(sclsnm, initkwargs.keys())) | |
| angleinit = ((lonval is not None and latval is not None) or | |
| coordstr is not None) | |
| cartinit = ((x is not None and y is not None and z is not None) or | |
| cartpoint is not None) | |
| if angleinit and not cartinit: | |
| # lat/lon-style initialization | |
| for v in [x, y, z, cartpoint]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| try: | |
| # this raises a TypeError if `unit` is not None or iterable | |
| units = [None, None] if unit is None else list(unit) | |
| except TypeError: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a ' | |
| 'non-sequence {1}'.format(sclsnm, unit)) | |
| if len(units) == 2: | |
| try: | |
| if units[0] is not None: | |
| units[0] = u.Unit(units[0]) | |
| if units[1] is not None: | |
| units[1] = u.Unit(units[1]) | |
| except ValueError: | |
| raise ValueError('Could not convert units to unit objects ' | |
| 'while initializing ' + sclsnm) | |
| else: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a sequence ' | |
| 'of {1}.'.format(sclsnm, len(units))) | |
| if coordstr is not None: | |
| # need to try to parse the coordinate from a single argument | |
| # populates latval and lonval variables, which then get made | |
| # into coordinates below | |
| if isinstance(coordstr, six.string_types): | |
| if "," in coordstr: | |
| lonval, latval = coordstr.split(",") | |
| else: | |
| coosplit = coordstr.split() | |
| if len(coosplit) == 6: | |
| lonval = " ".join(coosplit[0:3]) | |
| latval = " ".join(coosplit[3:]) | |
| elif len(coosplit) == 2: | |
| lonval, latval = coosplit | |
| else: | |
| msg = ("Could not parse {lonname}/{latname} values " | |
| "from the string provided: '{coordstr}'.") | |
| raise ValueError(msg.format(lonname=lonname, | |
| latname=latname, | |
| coordstr=coordstr)) | |
| else: | |
| raise ValueError("A {0} cannot be created with a single value of type " | |
| "'{1}', must be a string.".format(sclsnm, type(coordstr).__name__)) | |
| # now actually create the angle objects | |
| lonang = Longitude(lonval, unit=units[0]) | |
| latang = Latitude(latval, unit=units[1]) | |
| dist = None if distval is None else Distance(distval) # copy | |
| elif cartinit and not angleinit: | |
| # cartesian-style initialization | |
| for v in [coordstr, lonval, latval, distval]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| if cartpoint is not None: | |
| for v in [x, y, z, unit]: | |
| if v is not None: | |
| raise ValueError('Cannot give both a CartesianPoints ' | |
| 'and x/y/z/unit parameters while ' | |
| 'initializing ' + sclsnm) | |
| x = cartpoint.x | |
| y = cartpoint.y | |
| z = cartpoint.z | |
| unit = cartpoint.unit | |
| > r, latval, lonval = cartesian_to_spherical(x, y, z) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:235: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| x = <CartesianPoints 0.01708218844397828>, y = <CartesianPoints 0.15781069037526652>, z = <CartesianPoints -0.9873216217835231> | |
| x : scalar or array-like | |
| The first cartesian coordinate. | |
| y : scalar or array-like | |
| The second cartesian coordinate. | |
| z : scalar or array-like | |
| The third cartesian coordinate. | |
| Returns | |
| ------- | |
| r : float or array | |
| The radial coordinate (in the same units as the inputs). | |
| lat : float or array | |
| The latitude in radians | |
| lon : float or array | |
| The longitude in radians | |
| """ | |
| xsq = x ** 2 | |
| ysq = y ** 2 | |
| zsq = z ** 2 | |
| r = (xsq + ysq + zsq) ** 0.5 | |
| s = (xsq + ysq) ** 0.5 | |
| if np.isscalar(x) and np.isscalar(y) and np.isscalar(z): | |
| lon = math.atan2(y, x) | |
| lat = math.atan2(z, s) | |
| else: | |
| lon = np.arctan2(y, x) | |
| lat = np.arctan2(z, s) | |
| return r, lat, lon | |
| def spherical_to_cartesian(r, lat, lon): | |
| """ | |
| Converts spherical polar coordinates to rectangular cartesian | |
| coordinates. | |
| Note that the input angles should be in latitude/longitude or | |
| elevation/azimuthal form. I.e., the origin is along the equator | |
| rather than at the north pole. | |
| .. note:: | |
| This is a low-level function used internally in | |
| > `astropy.coordinates`. It is provided for users if they really | |
| want to use it, but it is recommended that you use the | |
| `astropy.coordinates` coordinate systems. | |
| Parameters | |
| ---------- | |
| r : scalar or array-like | |
| The radial coordinate (in the same units as the inputs). | |
| lat : scalar or array-like | |
| The latitude in radians | |
| lon : scalar or array-like | |
| The longitude in radians | |
| Returns | |
| ------- | |
| x : float or array | |
| The first cartesian coordinate. | |
| y : float or array | |
| The second cartesian coordinate. | |
| z : float or array | |
| The third cartesian coordinate. | |
| """ | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:441: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints 0.15781069037526652>, obj = array(2.315841784746324e+77) | |
| context = (<ufunc 'arctan2'>, (<CartesianPoints 0.15781069037526652>, <CartesianPoints 0.01708218844397828>), 0) | |
| raise TypeError("The value must be a valid Python or " | |
| "Numpy numeric type.") | |
| # by default, cast any integer, boolean, etc., to float | |
| if dtype is None and not np.can_cast(np.float32, value.dtype): | |
| value = value.astype(np.float) | |
| value = value.view(cls) | |
| value._unit = unit | |
| return value | |
| def __array_finalize__(self, obj): | |
| self._unit = getattr(obj, '_unit', None) | |
| def __array_prepare__(self, obj, context=None): | |
| # This method gets called by Numpy whenever a ufunc is called on the | |
| # array. The object passed in ``obj`` is an empty version of the | |
| # output array which we can e.g. change to an array sub-class, add | |
| # attributes to, etc. After this is called, then the ufunc is called | |
| # and the values in this empty array are set. | |
| # If no context is set, just return the input | |
| if context is None: | |
| return obj | |
| # Find out which ufunc is being used | |
| function = context[0] | |
| from .quantity_helper import UNSUPPORTED_UFUNCS, UFUNC_HELPERS | |
| # Check whether we even support this ufunc | |
| if function in UNSUPPORTED_UFUNCS: | |
| raise TypeError("Cannot use function '{0}' with quantities" | |
| .format(function.__name__)) | |
| # Now find out what arguments were passed to the ufunc, usually, this | |
| # will include at least the present object, and another, which could | |
| # be a Quantity, or a Numpy array, etc. when using two-argument ufuncs. | |
| args = context[1][:function.nin] | |
| units = [getattr(arg, 'unit', None) for arg in args] | |
| # If the ufunc is supported, then we call a helper function (defined | |
| # in quantity_helper.py) which returns the scale by which the inputs | |
| # should be multiplied before being passed to the ufunc, as well as | |
| # the unit the output from the ufunc will have. | |
| if function in UFUNC_HELPERS: | |
| scales, result_unit = UFUNC_HELPERS[function](function, *units) | |
| else: | |
| raise TypeError("Unknown ufunc {0}. Please raise issue on " | |
| "https://github.com/astropy/astropy" | |
| .format(function.__name__)) | |
| if any(scale == 0. for scale in scales): | |
| # for two-argument ufuncs with a quantity and a non-quantity, | |
| # the quantity normally needs to be dimensionless, *except* | |
| # if the non-quantity can have arbitrary unit, i.e., when it | |
| # is all zero, infinity or NaN. In that case, the non-quantity | |
| # can just have the unit of the quantity | |
| # (this allows, e.g., `q > 0.` independent of unit) | |
| maybe_arbitrary_arg = args[scales.index(0.)] | |
| if _can_have_arbitrary_unit(maybe_arbitrary_arg): | |
| scales = [1., 1.] | |
| else: | |
| raise UnitsError("Can only apply '{0}' function to " | |
| "dimensionless quantities when other " | |
| "argument is not a quantity (unless the " | |
| "latter is all zero/infinity/nan)" | |
| .format(function.__name__)) | |
| # In the case of np.power, the unit itself needs to be modified by an | |
| # amount that depends on one of the input values, so we need to treat | |
| # this as a special case. | |
| # TODO: find a better way to deal with this case | |
| if function is np.power and result_unit is not None: | |
| if units[1] is None: | |
| p = args[1] | |
| else: | |
| p = args[1].to(dimensionless_unscaled).value | |
| result_unit = result_unit ** validate_power(p) | |
| # We now prepare the output object | |
| if self is obj: # happens if the output object is self, which happens | |
| # for in-place operations such as q1 += q2 | |
| # In some cases, the result of a ufunc should be a plain Numpy | |
| # array, which we can't do if we are doing an in-place operation. | |
| if result_unit is None: | |
| raise TypeError("Cannot store non-quantity output from {0} " | |
| "function in Quantity object" | |
| .format(function.__name__)) | |
| /Users/adam/repos/astropy/astropy/units/quantity.py:311: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints 0.15781069037526652>, obj = array(2.315841784746324e+77), unit = Unit("rad") | |
| #screw up the units are killed by _convert_to_and_validate_length_unit | |
| obj = super(CartesianPoints, self).__array_wrap__(obj, context=context) | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:310: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = AssertionError(), args = (), f = <py._code.code.Frame object at 0x10a249490> | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| > ??? | |
| _pytest.assertion.reinterpret:40: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| frame = <py._code.code.Frame object at 0x10a249490>, should_fail = True | |
| > ??? | |
| _pytest.assertion.newinterpret:46: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| filename = '<unknown>', mode = 'exec' | |
| def parse(source, filename='<unknown>', mode='exec'): | |
| """ | |
| Parse the source into an AST node. | |
| Equivalent to compile(source, filename, mode, PyCF_ONLY_AST). | |
| """ | |
| > return compile(source, filename, mode, PyCF_ONLY_AST) | |
| E File "<unknown>", line 1 | |
| E .. note:: | |
| E ^ | |
| E SyntaxError: invalid syntax | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py:37: SyntaxError | |
| ______________________________________________________________________ test_query_region ______________________________________________________________________ | |
| patch_get = <_pytest.monkeypatch.monkeypatch instance at 0x11992d518>, patch_get_readable_fileobj = <_pytest.monkeypatch.monkeypatch instance at 0x11992d518> | |
| def test_query_region(patch_get, patch_get_readable_fileobj): | |
| table = ukidss.core.Ukidss.query_region(coord.Galactic | |
| (l=10.625, b=-0.38, unit=(u.deg, u.deg)), | |
| > radius=6 * u.arcsec) | |
| astroquery/ukidss/tests/test_ukidss.py:141: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.ukidss.core.UkidssClass object at 0x107cd19d0>, coordinates = <Galactic l=10.62500 deg, b=-0.38000 deg>, radius = <Quantity 6.0 arcsec> | |
| programme_id = 'GPS', database = 'UKIDSSDR7PLUS', verbose = False, get_query_payload = False, system = 'J2000' | |
| def query_region(self, coordinates, radius=1 * u.arcmin, | |
| programme_id='GPS', database='UKIDSSDR7PLUS', | |
| verbose=False, get_query_payload=False, system='J2000'): | |
| """ | |
| Used to query a region around a known identifier or given | |
| coordinates from the catalog. | |
| Parameters | |
| ---------- | |
| coordinates : str or `astropy.coordinates` object | |
| The target around which to search. It may be specified as a string | |
| in which case it is resolved using online services or as the | |
| appropriate `astropy.coordinates` object. ICRS coordinates may also | |
| be entered as strings as specified in the `astropy.coordinates` | |
| module. | |
| radius : str or `~astropy.units.Quantity` object, optional | |
| The string must be parsable by `~astropy.coordinates.Angle`. The | |
| appropriate `~astropy.units.Quantity` object from | |
| `astropy.units` may also be used. When missing defaults to 1 | |
| arcmin. Cannot exceed 90 arcmin. | |
| programme_id : str | |
| The survey or programme in which to search for. See `list_catalogs`. | |
| database : str | |
| The UKIDSS database to use. | |
| verbose : bool, optional. | |
| When set to `True` displays warnings if the returned VOTable does | |
| not conform to the standard. Defaults to `False`. | |
| get_query_payload : bool, optional | |
| If `True` then returns the dictionary sent as the HTTP request. | |
| Defaults to `False`. | |
| system : 'J2000' or 'Galactic' | |
| The system in which to perform the query. Can affect the output | |
| data columns. | |
| Returns | |
| ------- | |
| result : `~astropy.table.Table` | |
| Query result table. | |
| """ | |
| response = self.query_region_async(coordinates, radius=radius, | |
| programme_id=programme_id, | |
| database=database, | |
| get_query_payload=get_query_payload, | |
| > system=system) | |
| astroquery/ukidss/core.py:450: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.ukidss.core.UkidssClass object at 0x107cd19d0>, coordinates = <Galactic l=10.62500 deg, b=-0.38000 deg>, radius = <Quantity 6.0 arcsec> | |
| programme_id = 'GPS', database = 'UKIDSSDR7PLUS', get_query_payload = False, system = 'J2000' | |
| def query_region_async(self, coordinates, radius=1 * u.arcmin, | |
| programme_id='GPS', | |
| database='UKIDSSDR7PLUS', get_query_payload=False, | |
| system='J2000'): | |
| """ | |
| Serves the same purpose as `query_region`. But | |
| returns the raw HTTP response rather than the parsed result. | |
| Parameters | |
| ---------- | |
| coordinates : str or `astropy.coordinates` object | |
| The target around which to search. It may be specified as a | |
| string in which case it is resolved using online services or as | |
| the appropriate `astropy.coordinates` object. ICRS coordinates | |
| may also be entered as strings as specified in the | |
| `astropy.coordinates` module. | |
| radius : str or `~astropy.units.Quantity` object, optional | |
| The string must be parsable by `~astropy.coordinates.Angle`. The | |
| appropriate `~astropy.units.Quantity` object from | |
| `astropy.units` may also be used. When missing defaults to 1 | |
| arcmin. Cannot exceed 90 arcmin. | |
| programme_id : str | |
| The survey or programme in which to search for. See `list_catalogs`. | |
| database : str | |
| The UKIDSS database to use. | |
| get_query_payload : bool, optional | |
| If `True` then returns the dictionary sent as the HTTP request. | |
| Defaults to `False`. | |
| Returns | |
| ------- | |
| response : `requests.Response` | |
| The HTTP response returned from the service. | |
| """ | |
| request_payload = self._args_to_payload(coordinates, | |
| programme_id=programme_id, | |
| database=database, | |
| system=system, | |
| > query_type='catalog') | |
| astroquery/ukidss/core.py:496: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.ukidss.core.UkidssClass object at 0x107cd19d0>, args = (<Galactic l=10.62500 deg, b=-0.38000 deg>,) | |
| kwargs = {'database': 'UKIDSSDR7PLUS', 'programme_id': 'GPS', 'query_type': 'catalog', 'system': 'J2000'} | |
| request_payload = {'database': 'UKIDSSDR7PLUS', 'programmeID': 102, 'sys': 'J'}, programme_id = 'GPS', sys = 'J' | |
| def _args_to_payload(self, *args, **kwargs): | |
| request_payload = {} | |
| request_payload['database'] = kwargs['database'] if 'database' in kwargs else self.database | |
| programme_id = kwargs['programme_id'] if 'programme_id' in kwargs else self.programme_id | |
| request_payload['programmeID'] = verify_programme_id(programme_id, query_type=kwargs['query_type']) | |
| sys = self._parse_system(kwargs.get('system')) | |
| request_payload['sys'] = sys | |
| if sys == 'J': | |
| > request_payload['ra'] = commons.parse_coordinates(args[0]).icrs.ra.degree | |
| astroquery/ukidss/core.py:138: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <Galactic l=10.62500 deg, b=-0.38000 deg>, name = 'icrs' | |
| def __getattr__(self, name): | |
| """ | |
| Overrides getattr to return coordinates that this can be transformed | |
| to, based on the alias name in the master transform graph. | |
| """ | |
| from .transformations import master_transform_graph | |
| nmsys = master_transform_graph.lookup_name(name) | |
| if self.__class__ is nmsys: | |
| return self | |
| if nmsys is not None and self.is_transformable_to(nmsys): | |
| > return self.transform_to(nmsys) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:659: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <Galactic l=10.62500 deg, b=-0.38000 deg>, tosys = <class 'astropy.coordinates.builtin_systems.ICRS'> | |
| def transform_to(self, tosys): | |
| """ | |
| Transform this coordinate to a new system. | |
| Parameters | |
| ---------- | |
| tosys : class | |
| The system to transform this coordinate into. | |
| Returns | |
| ------- | |
| transcoord | |
| A new object with this coordinate represented in the | |
| ``tosys`` system. | |
| Raises | |
| ------ | |
| ValueError | |
| If there is no possible transformation route. | |
| """ | |
| from .transformations import master_transform_graph | |
| from .errors import ConvertError | |
| if tosys is self.__class__: | |
| return copy.deepcopy(self) | |
| trans = master_transform_graph.get_transform(self.__class__, tosys) | |
| if trans is None: | |
| raise ConvertError('Cannot transform from {0} to ' | |
| '{1}'.format(self.__class__, tosys)) | |
| > return trans(self) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:622: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.CompositeTransform object at 0x1094f1210>, fromcoord = <Galactic l=10.62500 deg, b=-0.38000 deg> | |
| super(CompositeTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| > coord = fromcoord | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:742: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.DynamicMatrixTransform object at 0x1067c5990>, fromcoord = <Galactic l=10.62500 deg, b=-0.38000 deg> | |
| super(DynamicMatrixTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| c = fromcoord.cartesian | |
| v = c.reshape((3, c.size // 3)) | |
| v2 = np.dot(np.asarray(self.matrix_func(fromcoord)), v) | |
| subshape = c.shape[1:] | |
| x = v2[0].reshape(subshape) | |
| y = v2[1].reshape(subshape) | |
| z = v2[2].reshape(subshape) | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:708: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x10a12fab8>, args = () | |
| kwargs = {'unit': None, 'x': <CartesianPoints 0.042922274488051144>, 'y': <CartesianPoints -0.9391451292955936>, 'z': <CartesianPoints -0.34082855583582683>} | |
| def __init__(self, *args, **kwargs): | |
| super(FK5, self).__init__() | |
| self._equinox = kwargs.pop('equinox', _EQUINOX_J2000) | |
| self._obstime = kwargs.pop('obstime', None) | |
| if not isinstance(self._equinox, Time): | |
| raise TypeError('specified equinox is not a Time object') | |
| if self._obstime is not None and not isinstance(self._obstime, Time): | |
| raise TypeError('specified obstime is not None or a Time object') | |
| if not self._equinox.isscalar: | |
| raise ValueError('specified equinox is not a scalar') | |
| if len(args) == 1 and len(kwargs) == 0 and isinstance(args[0], SphericalCoordinatesBase): | |
| newcoord = args[0].transform_to(self.__class__) | |
| self._latangle = newcoord._latangle | |
| self._lonangle = newcoord._lonangle | |
| self._distance = newcoord._distance | |
| else: | |
| > super(FK5, self)._initialize_latlon('ra', 'dec', args, kwargs) | |
| /Users/adam/repos/astropy/astropy/coordinates/builtin_systems.py:140: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x1083a4b48>, lonname = 'ra' | |
| latname = 'dec', initargs = (), initkwargs = {} | |
| def _initialize_latlon(self, lonname, latname, initargs, initkwargs): | |
| """ | |
| Subclasses should use this to initialize standard lat/lon-style | |
| coordinates. | |
| This recognizes both the lat/lon style and the cartesian form. | |
| Parameters | |
| ---------- | |
| lonname : str | |
| The name of the longitude-like coordinate attribute | |
| latname : str | |
| The name of the latitude-like coordinate attribute | |
| initargs : list | |
| The ``*args`` from the initializer | |
| initkwargs : dict | |
| The ``**kwargs`` from the initializer | |
| """ | |
| initkwargs = dict(initkwargs) # copy | |
| nargs = len(initargs) | |
| sclsnm = self.__class__.__name__ | |
| if nargs == 1: | |
| if isinstance(initargs[0], CartesianPoints): | |
| initkwargs['cartpoint'] = initargs[0] | |
| else: | |
| initkwargs['coordstr'] = initargs[0] | |
| if nargs > 1: | |
| if lonname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, lonname)) | |
| initkwargs[lonname] = initargs[0] | |
| if nargs >= 2: | |
| if latname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, latname)) | |
| initkwargs[latname] = initargs[1] | |
| if nargs > 2: | |
| raise TypeError('{0} takes up to 2 positional arguments ' | |
| '({1} given)'.format(sclsnm, len(initargs))) | |
| unit = initkwargs.pop('unit', None) | |
| coordstr = initkwargs.pop('coordstr', None) | |
| lonval = initkwargs.pop(lonname, None) | |
| latval = initkwargs.pop(latname, None) | |
| distval = initkwargs.pop('distance', None) | |
| cartpoint = initkwargs.pop('cartpoint', None) | |
| x = initkwargs.pop('x', None) | |
| y = initkwargs.pop('y', None) | |
| z = initkwargs.pop('z', None) | |
| if len(initkwargs) > 0: | |
| raise TypeError('{0} got unexpected keyword argument' | |
| ' {1}'.format(sclsnm, initkwargs.keys())) | |
| angleinit = ((lonval is not None and latval is not None) or | |
| coordstr is not None) | |
| cartinit = ((x is not None and y is not None and z is not None) or | |
| cartpoint is not None) | |
| if angleinit and not cartinit: | |
| # lat/lon-style initialization | |
| for v in [x, y, z, cartpoint]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| try: | |
| # this raises a TypeError if `unit` is not None or iterable | |
| units = [None, None] if unit is None else list(unit) | |
| except TypeError: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a ' | |
| 'non-sequence {1}'.format(sclsnm, unit)) | |
| if len(units) == 2: | |
| try: | |
| if units[0] is not None: | |
| units[0] = u.Unit(units[0]) | |
| if units[1] is not None: | |
| units[1] = u.Unit(units[1]) | |
| except ValueError: | |
| raise ValueError('Could not convert units to unit objects ' | |
| 'while initializing ' + sclsnm) | |
| else: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a sequence ' | |
| 'of {1}.'.format(sclsnm, len(units))) | |
| if coordstr is not None: | |
| # need to try to parse the coordinate from a single argument | |
| # populates latval and lonval variables, which then get made | |
| # into coordinates below | |
| if isinstance(coordstr, six.string_types): | |
| if "," in coordstr: | |
| lonval, latval = coordstr.split(",") | |
| else: | |
| coosplit = coordstr.split() | |
| if len(coosplit) == 6: | |
| lonval = " ".join(coosplit[0:3]) | |
| latval = " ".join(coosplit[3:]) | |
| elif len(coosplit) == 2: | |
| lonval, latval = coosplit | |
| else: | |
| msg = ("Could not parse {lonname}/{latname} values " | |
| "from the string provided: '{coordstr}'.") | |
| raise ValueError(msg.format(lonname=lonname, | |
| latname=latname, | |
| coordstr=coordstr)) | |
| else: | |
| raise ValueError("A {0} cannot be created with a single value of type " | |
| "'{1}', must be a string.".format(sclsnm, type(coordstr).__name__)) | |
| # now actually create the angle objects | |
| lonang = Longitude(lonval, unit=units[0]) | |
| latang = Latitude(latval, unit=units[1]) | |
| dist = None if distval is None else Distance(distval) # copy | |
| elif cartinit and not angleinit: | |
| # cartesian-style initialization | |
| for v in [coordstr, lonval, latval, distval]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| if cartpoint is not None: | |
| for v in [x, y, z, unit]: | |
| if v is not None: | |
| raise ValueError('Cannot give both a CartesianPoints ' | |
| 'and x/y/z/unit parameters while ' | |
| 'initializing ' + sclsnm) | |
| x = cartpoint.x | |
| y = cartpoint.y | |
| z = cartpoint.z | |
| unit = cartpoint.unit | |
| > r, latval, lonval = cartesian_to_spherical(x, y, z) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:235: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| x = <CartesianPoints 0.042922274488051144>, y = <CartesianPoints -0.9391451292955936>, z = <CartesianPoints -0.34082855583582683> | |
| x : scalar or array-like | |
| The first cartesian coordinate. | |
| y : scalar or array-like | |
| The second cartesian coordinate. | |
| z : scalar or array-like | |
| The third cartesian coordinate. | |
| Returns | |
| ------- | |
| r : float or array | |
| The radial coordinate (in the same units as the inputs). | |
| lat : float or array | |
| The latitude in radians | |
| lon : float or array | |
| The longitude in radians | |
| """ | |
| xsq = x ** 2 | |
| ysq = y ** 2 | |
| zsq = z ** 2 | |
| r = (xsq + ysq + zsq) ** 0.5 | |
| s = (xsq + ysq) ** 0.5 | |
| if np.isscalar(x) and np.isscalar(y) and np.isscalar(z): | |
| lon = math.atan2(y, x) | |
| lat = math.atan2(z, s) | |
| else: | |
| lon = np.arctan2(y, x) | |
| lat = np.arctan2(z, s) | |
| return r, lat, lon | |
| def spherical_to_cartesian(r, lat, lon): | |
| """ | |
| Converts spherical polar coordinates to rectangular cartesian | |
| coordinates. | |
| Note that the input angles should be in latitude/longitude or | |
| elevation/azimuthal form. I.e., the origin is along the equator | |
| rather than at the north pole. | |
| .. note:: | |
| This is a low-level function used internally in | |
| > `astropy.coordinates`. It is provided for users if they really | |
| want to use it, but it is recommended that you use the | |
| `astropy.coordinates` coordinate systems. | |
| Parameters | |
| ---------- | |
| r : scalar or array-like | |
| The radial coordinate (in the same units as the inputs). | |
| lat : scalar or array-like | |
| The latitude in radians | |
| lon : scalar or array-like | |
| The longitude in radians | |
| Returns | |
| ------- | |
| x : float or array | |
| The first cartesian coordinate. | |
| y : float or array | |
| The second cartesian coordinate. | |
| z : float or array | |
| The third cartesian coordinate. | |
| """ | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:441: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints -0.9391451292955936>, obj = array(2.315841784746324e+77) | |
| context = (<ufunc 'arctan2'>, (<CartesianPoints -0.9391451292955936>, <CartesianPoints 0.042922274488051144>), 0) | |
| raise TypeError("The value must be a valid Python or " | |
| "Numpy numeric type.") | |
| # by default, cast any integer, boolean, etc., to float | |
| if dtype is None and not np.can_cast(np.float32, value.dtype): | |
| value = value.astype(np.float) | |
| value = value.view(cls) | |
| value._unit = unit | |
| return value | |
| def __array_finalize__(self, obj): | |
| self._unit = getattr(obj, '_unit', None) | |
| def __array_prepare__(self, obj, context=None): | |
| # This method gets called by Numpy whenever a ufunc is called on the | |
| # array. The object passed in ``obj`` is an empty version of the | |
| # output array which we can e.g. change to an array sub-class, add | |
| # attributes to, etc. After this is called, then the ufunc is called | |
| # and the values in this empty array are set. | |
| # If no context is set, just return the input | |
| if context is None: | |
| return obj | |
| # Find out which ufunc is being used | |
| function = context[0] | |
| from .quantity_helper import UNSUPPORTED_UFUNCS, UFUNC_HELPERS | |
| # Check whether we even support this ufunc | |
| if function in UNSUPPORTED_UFUNCS: | |
| raise TypeError("Cannot use function '{0}' with quantities" | |
| .format(function.__name__)) | |
| # Now find out what arguments were passed to the ufunc, usually, this | |
| # will include at least the present object, and another, which could | |
| # be a Quantity, or a Numpy array, etc. when using two-argument ufuncs. | |
| args = context[1][:function.nin] | |
| units = [getattr(arg, 'unit', None) for arg in args] | |
| # If the ufunc is supported, then we call a helper function (defined | |
| # in quantity_helper.py) which returns the scale by which the inputs | |
| # should be multiplied before being passed to the ufunc, as well as | |
| # the unit the output from the ufunc will have. | |
| if function in UFUNC_HELPERS: | |
| scales, result_unit = UFUNC_HELPERS[function](function, *units) | |
| else: | |
| raise TypeError("Unknown ufunc {0}. Please raise issue on " | |
| "https://github.com/astropy/astropy" | |
| .format(function.__name__)) | |
| if any(scale == 0. for scale in scales): | |
| # for two-argument ufuncs with a quantity and a non-quantity, | |
| # the quantity normally needs to be dimensionless, *except* | |
| # if the non-quantity can have arbitrary unit, i.e., when it | |
| # is all zero, infinity or NaN. In that case, the non-quantity | |
| # can just have the unit of the quantity | |
| # (this allows, e.g., `q > 0.` independent of unit) | |
| maybe_arbitrary_arg = args[scales.index(0.)] | |
| if _can_have_arbitrary_unit(maybe_arbitrary_arg): | |
| scales = [1., 1.] | |
| else: | |
| raise UnitsError("Can only apply '{0}' function to " | |
| "dimensionless quantities when other " | |
| "argument is not a quantity (unless the " | |
| "latter is all zero/infinity/nan)" | |
| .format(function.__name__)) | |
| # In the case of np.power, the unit itself needs to be modified by an | |
| # amount that depends on one of the input values, so we need to treat | |
| # this as a special case. | |
| # TODO: find a better way to deal with this case | |
| if function is np.power and result_unit is not None: | |
| if units[1] is None: | |
| p = args[1] | |
| else: | |
| p = args[1].to(dimensionless_unscaled).value | |
| result_unit = result_unit ** validate_power(p) | |
| # We now prepare the output object | |
| if self is obj: # happens if the output object is self, which happens | |
| # for in-place operations such as q1 += q2 | |
| # In some cases, the result of a ufunc should be a plain Numpy | |
| # array, which we can't do if we are doing an in-place operation. | |
| if result_unit is None: | |
| raise TypeError("Cannot store non-quantity output from {0} " | |
| "function in Quantity object" | |
| .format(function.__name__)) | |
| /Users/adam/repos/astropy/astropy/units/quantity.py:311: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints -0.9391451292955936>, obj = array(2.315841784746324e+77), unit = Unit("rad") | |
| #screw up the units are killed by _convert_to_and_validate_length_unit | |
| obj = super(CartesianPoints, self).__array_wrap__(obj, context=context) | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:310: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = AssertionError(), args = (), f = <py._code.code.Frame object at 0x1094f1750> | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| > ??? | |
| _pytest.assertion.reinterpret:40: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| frame = <py._code.code.Frame object at 0x1094f1750>, should_fail = True | |
| > ??? | |
| _pytest.assertion.newinterpret:46: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| filename = '<unknown>', mode = 'exec' | |
| def parse(source, filename='<unknown>', mode='exec'): | |
| """ | |
| Parse the source into an AST node. | |
| Equivalent to compile(source, filename, mode, PyCF_ONLY_AST). | |
| """ | |
| > return compile(source, filename, mode, PyCF_ONLY_AST) | |
| E File "<unknown>", line 1 | |
| E .. note:: | |
| E ^ | |
| E SyntaxError: invalid syntax | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py:37: SyntaxError | |
| ___________________________________________________________________ test_query_region_async ___________________________________________________________________ | |
| patch_get = <_pytest.monkeypatch.monkeypatch instance at 0x10830b368> | |
| def test_query_region_async(patch_get): | |
| response = ukidss.core.Ukidss.query_region_async(coord.Galactic | |
| (l=10.625, b=-0.38, unit=(u.deg, u.deg)), | |
| radius=6 * u.arcsec, | |
| > get_query_payload=True) | |
| astroquery/ukidss/tests/test_ukidss.py:150: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.ukidss.core.UkidssClass object at 0x107cd19d0>, coordinates = <Galactic l=10.62500 deg, b=-0.38000 deg>, radius = <Quantity 6.0 arcsec> | |
| programme_id = 'GPS', database = 'UKIDSSDR7PLUS', get_query_payload = True, system = 'J2000' | |
| def query_region_async(self, coordinates, radius=1 * u.arcmin, | |
| programme_id='GPS', | |
| database='UKIDSSDR7PLUS', get_query_payload=False, | |
| system='J2000'): | |
| """ | |
| Serves the same purpose as `query_region`. But | |
| returns the raw HTTP response rather than the parsed result. | |
| Parameters | |
| ---------- | |
| coordinates : str or `astropy.coordinates` object | |
| The target around which to search. It may be specified as a | |
| string in which case it is resolved using online services or as | |
| the appropriate `astropy.coordinates` object. ICRS coordinates | |
| may also be entered as strings as specified in the | |
| `astropy.coordinates` module. | |
| radius : str or `~astropy.units.Quantity` object, optional | |
| The string must be parsable by `~astropy.coordinates.Angle`. The | |
| appropriate `~astropy.units.Quantity` object from | |
| `astropy.units` may also be used. When missing defaults to 1 | |
| arcmin. Cannot exceed 90 arcmin. | |
| programme_id : str | |
| The survey or programme in which to search for. See `list_catalogs`. | |
| database : str | |
| The UKIDSS database to use. | |
| get_query_payload : bool, optional | |
| If `True` then returns the dictionary sent as the HTTP request. | |
| Defaults to `False`. | |
| Returns | |
| ------- | |
| response : `requests.Response` | |
| The HTTP response returned from the service. | |
| """ | |
| request_payload = self._args_to_payload(coordinates, | |
| programme_id=programme_id, | |
| database=database, | |
| system=system, | |
| > query_type='catalog') | |
| astroquery/ukidss/core.py:496: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.ukidss.core.UkidssClass object at 0x107cd19d0>, args = (<Galactic l=10.62500 deg, b=-0.38000 deg>,) | |
| kwargs = {'database': 'UKIDSSDR7PLUS', 'programme_id': 'GPS', 'query_type': 'catalog', 'system': 'J2000'} | |
| request_payload = {'database': 'UKIDSSDR7PLUS', 'programmeID': 102, 'sys': 'J'}, programme_id = 'GPS', sys = 'J' | |
| def _args_to_payload(self, *args, **kwargs): | |
| request_payload = {} | |
| request_payload['database'] = kwargs['database'] if 'database' in kwargs else self.database | |
| programme_id = kwargs['programme_id'] if 'programme_id' in kwargs else self.programme_id | |
| request_payload['programmeID'] = verify_programme_id(programme_id, query_type=kwargs['query_type']) | |
| sys = self._parse_system(kwargs.get('system')) | |
| request_payload['sys'] = sys | |
| if sys == 'J': | |
| > request_payload['ra'] = commons.parse_coordinates(args[0]).icrs.ra.degree | |
| astroquery/ukidss/core.py:138: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <Galactic l=10.62500 deg, b=-0.38000 deg>, name = 'icrs' | |
| def __getattr__(self, name): | |
| """ | |
| Overrides getattr to return coordinates that this can be transformed | |
| to, based on the alias name in the master transform graph. | |
| """ | |
| from .transformations import master_transform_graph | |
| nmsys = master_transform_graph.lookup_name(name) | |
| if self.__class__ is nmsys: | |
| return self | |
| if nmsys is not None and self.is_transformable_to(nmsys): | |
| > return self.transform_to(nmsys) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:659: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <Galactic l=10.62500 deg, b=-0.38000 deg>, tosys = <class 'astropy.coordinates.builtin_systems.ICRS'> | |
| def transform_to(self, tosys): | |
| """ | |
| Transform this coordinate to a new system. | |
| Parameters | |
| ---------- | |
| tosys : class | |
| The system to transform this coordinate into. | |
| Returns | |
| ------- | |
| transcoord | |
| A new object with this coordinate represented in the | |
| ``tosys`` system. | |
| Raises | |
| ------ | |
| ValueError | |
| If there is no possible transformation route. | |
| """ | |
| from .transformations import master_transform_graph | |
| from .errors import ConvertError | |
| if tosys is self.__class__: | |
| return copy.deepcopy(self) | |
| trans = master_transform_graph.get_transform(self.__class__, tosys) | |
| if trans is None: | |
| raise ConvertError('Cannot transform from {0} to ' | |
| '{1}'.format(self.__class__, tosys)) | |
| > return trans(self) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:622: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.CompositeTransform object at 0x119973d10>, fromcoord = <Galactic l=10.62500 deg, b=-0.38000 deg> | |
| super(CompositeTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| > coord = fromcoord | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:742: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.DynamicMatrixTransform object at 0x1067c5990>, fromcoord = <Galactic l=10.62500 deg, b=-0.38000 deg> | |
| super(DynamicMatrixTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| c = fromcoord.cartesian | |
| v = c.reshape((3, c.size // 3)) | |
| v2 = np.dot(np.asarray(self.matrix_func(fromcoord)), v) | |
| subshape = c.shape[1:] | |
| x = v2[0].reshape(subshape) | |
| y = v2[1].reshape(subshape) | |
| z = v2[2].reshape(subshape) | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:708: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x10a0fa200>, args = () | |
| kwargs = {'unit': None, 'x': <CartesianPoints 0.042922274488051144>, 'y': <CartesianPoints -0.9391451292955936>, 'z': <CartesianPoints -0.34082855583582683>} | |
| def __init__(self, *args, **kwargs): | |
| super(FK5, self).__init__() | |
| self._equinox = kwargs.pop('equinox', _EQUINOX_J2000) | |
| self._obstime = kwargs.pop('obstime', None) | |
| if not isinstance(self._equinox, Time): | |
| raise TypeError('specified equinox is not a Time object') | |
| if self._obstime is not None and not isinstance(self._obstime, Time): | |
| raise TypeError('specified obstime is not None or a Time object') | |
| if not self._equinox.isscalar: | |
| raise ValueError('specified equinox is not a scalar') | |
| if len(args) == 1 and len(kwargs) == 0 and isinstance(args[0], SphericalCoordinatesBase): | |
| newcoord = args[0].transform_to(self.__class__) | |
| self._latangle = newcoord._latangle | |
| self._lonangle = newcoord._lonangle | |
| self._distance = newcoord._distance | |
| else: | |
| > super(FK5, self)._initialize_latlon('ra', 'dec', args, kwargs) | |
| /Users/adam/repos/astropy/astropy/coordinates/builtin_systems.py:140: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x1096b03b0>, lonname = 'ra' | |
| latname = 'dec', initargs = (), initkwargs = {} | |
| def _initialize_latlon(self, lonname, latname, initargs, initkwargs): | |
| """ | |
| Subclasses should use this to initialize standard lat/lon-style | |
| coordinates. | |
| This recognizes both the lat/lon style and the cartesian form. | |
| Parameters | |
| ---------- | |
| lonname : str | |
| The name of the longitude-like coordinate attribute | |
| latname : str | |
| The name of the latitude-like coordinate attribute | |
| initargs : list | |
| The ``*args`` from the initializer | |
| initkwargs : dict | |
| The ``**kwargs`` from the initializer | |
| """ | |
| initkwargs = dict(initkwargs) # copy | |
| nargs = len(initargs) | |
| sclsnm = self.__class__.__name__ | |
| if nargs == 1: | |
| if isinstance(initargs[0], CartesianPoints): | |
| initkwargs['cartpoint'] = initargs[0] | |
| else: | |
| initkwargs['coordstr'] = initargs[0] | |
| if nargs > 1: | |
| if lonname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, lonname)) | |
| initkwargs[lonname] = initargs[0] | |
| if nargs >= 2: | |
| if latname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, latname)) | |
| initkwargs[latname] = initargs[1] | |
| if nargs > 2: | |
| raise TypeError('{0} takes up to 2 positional arguments ' | |
| '({1} given)'.format(sclsnm, len(initargs))) | |
| unit = initkwargs.pop('unit', None) | |
| coordstr = initkwargs.pop('coordstr', None) | |
| lonval = initkwargs.pop(lonname, None) | |
| latval = initkwargs.pop(latname, None) | |
| distval = initkwargs.pop('distance', None) | |
| cartpoint = initkwargs.pop('cartpoint', None) | |
| x = initkwargs.pop('x', None) | |
| y = initkwargs.pop('y', None) | |
| z = initkwargs.pop('z', None) | |
| if len(initkwargs) > 0: | |
| raise TypeError('{0} got unexpected keyword argument' | |
| ' {1}'.format(sclsnm, initkwargs.keys())) | |
| angleinit = ((lonval is not None and latval is not None) or | |
| coordstr is not None) | |
| cartinit = ((x is not None and y is not None and z is not None) or | |
| cartpoint is not None) | |
| if angleinit and not cartinit: | |
| # lat/lon-style initialization | |
| for v in [x, y, z, cartpoint]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| try: | |
| # this raises a TypeError if `unit` is not None or iterable | |
| units = [None, None] if unit is None else list(unit) | |
| except TypeError: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a ' | |
| 'non-sequence {1}'.format(sclsnm, unit)) | |
| if len(units) == 2: | |
| try: | |
| if units[0] is not None: | |
| units[0] = u.Unit(units[0]) | |
| if units[1] is not None: | |
| units[1] = u.Unit(units[1]) | |
| except ValueError: | |
| raise ValueError('Could not convert units to unit objects ' | |
| 'while initializing ' + sclsnm) | |
| else: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a sequence ' | |
| 'of {1}.'.format(sclsnm, len(units))) | |
| if coordstr is not None: | |
| # need to try to parse the coordinate from a single argument | |
| # populates latval and lonval variables, which then get made | |
| # into coordinates below | |
| if isinstance(coordstr, six.string_types): | |
| if "," in coordstr: | |
| lonval, latval = coordstr.split(",") | |
| else: | |
| coosplit = coordstr.split() | |
| if len(coosplit) == 6: | |
| lonval = " ".join(coosplit[0:3]) | |
| latval = " ".join(coosplit[3:]) | |
| elif len(coosplit) == 2: | |
| lonval, latval = coosplit | |
| else: | |
| msg = ("Could not parse {lonname}/{latname} values " | |
| "from the string provided: '{coordstr}'.") | |
| raise ValueError(msg.format(lonname=lonname, | |
| latname=latname, | |
| coordstr=coordstr)) | |
| else: | |
| raise ValueError("A {0} cannot be created with a single value of type " | |
| "'{1}', must be a string.".format(sclsnm, type(coordstr).__name__)) | |
| # now actually create the angle objects | |
| lonang = Longitude(lonval, unit=units[0]) | |
| latang = Latitude(latval, unit=units[1]) | |
| dist = None if distval is None else Distance(distval) # copy | |
| elif cartinit and not angleinit: | |
| # cartesian-style initialization | |
| for v in [coordstr, lonval, latval, distval]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| if cartpoint is not None: | |
| for v in [x, y, z, unit]: | |
| if v is not None: | |
| raise ValueError('Cannot give both a CartesianPoints ' | |
| 'and x/y/z/unit parameters while ' | |
| 'initializing ' + sclsnm) | |
| x = cartpoint.x | |
| y = cartpoint.y | |
| z = cartpoint.z | |
| unit = cartpoint.unit | |
| > r, latval, lonval = cartesian_to_spherical(x, y, z) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:235: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| x = <CartesianPoints 0.042922274488051144>, y = <CartesianPoints -0.9391451292955936>, z = <CartesianPoints -0.34082855583582683> | |
| x : scalar or array-like | |
| The first cartesian coordinate. | |
| y : scalar or array-like | |
| The second cartesian coordinate. | |
| z : scalar or array-like | |
| The third cartesian coordinate. | |
| Returns | |
| ------- | |
| r : float or array | |
| The radial coordinate (in the same units as the inputs). | |
| lat : float or array | |
| The latitude in radians | |
| lon : float or array | |
| The longitude in radians | |
| """ | |
| xsq = x ** 2 | |
| ysq = y ** 2 | |
| zsq = z ** 2 | |
| r = (xsq + ysq + zsq) ** 0.5 | |
| s = (xsq + ysq) ** 0.5 | |
| if np.isscalar(x) and np.isscalar(y) and np.isscalar(z): | |
| lon = math.atan2(y, x) | |
| lat = math.atan2(z, s) | |
| else: | |
| lon = np.arctan2(y, x) | |
| lat = np.arctan2(z, s) | |
| return r, lat, lon | |
| def spherical_to_cartesian(r, lat, lon): | |
| """ | |
| Converts spherical polar coordinates to rectangular cartesian | |
| coordinates. | |
| Note that the input angles should be in latitude/longitude or | |
| elevation/azimuthal form. I.e., the origin is along the equator | |
| rather than at the north pole. | |
| .. note:: | |
| This is a low-level function used internally in | |
| > `astropy.coordinates`. It is provided for users if they really | |
| want to use it, but it is recommended that you use the | |
| `astropy.coordinates` coordinate systems. | |
| Parameters | |
| ---------- | |
| r : scalar or array-like | |
| The radial coordinate (in the same units as the inputs). | |
| lat : scalar or array-like | |
| The latitude in radians | |
| lon : scalar or array-like | |
| The longitude in radians | |
| Returns | |
| ------- | |
| x : float or array | |
| The first cartesian coordinate. | |
| y : float or array | |
| The second cartesian coordinate. | |
| z : float or array | |
| The third cartesian coordinate. | |
| """ | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:441: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints -0.9391451292955936>, obj = array(2.315841784746324e+77) | |
| context = (<ufunc 'arctan2'>, (<CartesianPoints -0.9391451292955936>, <CartesianPoints 0.042922274488051144>), 0) | |
| raise TypeError("The value must be a valid Python or " | |
| "Numpy numeric type.") | |
| # by default, cast any integer, boolean, etc., to float | |
| if dtype is None and not np.can_cast(np.float32, value.dtype): | |
| value = value.astype(np.float) | |
| value = value.view(cls) | |
| value._unit = unit | |
| return value | |
| def __array_finalize__(self, obj): | |
| self._unit = getattr(obj, '_unit', None) | |
| def __array_prepare__(self, obj, context=None): | |
| # This method gets called by Numpy whenever a ufunc is called on the | |
| # array. The object passed in ``obj`` is an empty version of the | |
| # output array which we can e.g. change to an array sub-class, add | |
| # attributes to, etc. After this is called, then the ufunc is called | |
| # and the values in this empty array are set. | |
| # If no context is set, just return the input | |
| if context is None: | |
| return obj | |
| # Find out which ufunc is being used | |
| function = context[0] | |
| from .quantity_helper import UNSUPPORTED_UFUNCS, UFUNC_HELPERS | |
| # Check whether we even support this ufunc | |
| if function in UNSUPPORTED_UFUNCS: | |
| raise TypeError("Cannot use function '{0}' with quantities" | |
| .format(function.__name__)) | |
| # Now find out what arguments were passed to the ufunc, usually, this | |
| # will include at least the present object, and another, which could | |
| # be a Quantity, or a Numpy array, etc. when using two-argument ufuncs. | |
| args = context[1][:function.nin] | |
| units = [getattr(arg, 'unit', None) for arg in args] | |
| # If the ufunc is supported, then we call a helper function (defined | |
| # in quantity_helper.py) which returns the scale by which the inputs | |
| # should be multiplied before being passed to the ufunc, as well as | |
| # the unit the output from the ufunc will have. | |
| if function in UFUNC_HELPERS: | |
| scales, result_unit = UFUNC_HELPERS[function](function, *units) | |
| else: | |
| raise TypeError("Unknown ufunc {0}. Please raise issue on " | |
| "https://github.com/astropy/astropy" | |
| .format(function.__name__)) | |
| if any(scale == 0. for scale in scales): | |
| # for two-argument ufuncs with a quantity and a non-quantity, | |
| # the quantity normally needs to be dimensionless, *except* | |
| # if the non-quantity can have arbitrary unit, i.e., when it | |
| # is all zero, infinity or NaN. In that case, the non-quantity | |
| # can just have the unit of the quantity | |
| # (this allows, e.g., `q > 0.` independent of unit) | |
| maybe_arbitrary_arg = args[scales.index(0.)] | |
| if _can_have_arbitrary_unit(maybe_arbitrary_arg): | |
| scales = [1., 1.] | |
| else: | |
| raise UnitsError("Can only apply '{0}' function to " | |
| "dimensionless quantities when other " | |
| "argument is not a quantity (unless the " | |
| "latter is all zero/infinity/nan)" | |
| .format(function.__name__)) | |
| # In the case of np.power, the unit itself needs to be modified by an | |
| # amount that depends on one of the input values, so we need to treat | |
| # this as a special case. | |
| # TODO: find a better way to deal with this case | |
| if function is np.power and result_unit is not None: | |
| if units[1] is None: | |
| p = args[1] | |
| else: | |
| p = args[1].to(dimensionless_unscaled).value | |
| result_unit = result_unit ** validate_power(p) | |
| # We now prepare the output object | |
| if self is obj: # happens if the output object is self, which happens | |
| # for in-place operations such as q1 += q2 | |
| # In some cases, the result of a ufunc should be a plain Numpy | |
| # array, which we can't do if we are doing an in-place operation. | |
| if result_unit is None: | |
| raise TypeError("Cannot store non-quantity output from {0} " | |
| "function in Quantity object" | |
| .format(function.__name__)) | |
| /Users/adam/repos/astropy/astropy/units/quantity.py:311: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints -0.9391451292955936>, obj = array(2.315841784746324e+77), unit = Unit("rad") | |
| #screw up the units are killed by _convert_to_and_validate_length_unit | |
| obj = super(CartesianPoints, self).__array_wrap__(obj, context=context) | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:310: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = AssertionError(), args = (), f = <py._code.code.Frame object at 0x10968e790> | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| > ??? | |
| _pytest.assertion.reinterpret:40: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| frame = <py._code.code.Frame object at 0x10968e790>, should_fail = True | |
| > ??? | |
| _pytest.assertion.newinterpret:46: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| filename = '<unknown>', mode = 'exec' | |
| def parse(source, filename='<unknown>', mode='exec'): | |
| """ | |
| Parse the source into an AST node. | |
| Equivalent to compile(source, filename, mode, PyCF_ONLY_AST). | |
| """ | |
| > return compile(source, filename, mode, PyCF_ONLY_AST) | |
| E File "<unknown>", line 1 | |
| E .. note:: | |
| E ^ | |
| E SyntaxError: invalid syntax | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py:37: SyntaxError | |
| ________________________________________________________________ TestUkidss.test_get_images_2 _________________________________________________________________ | |
| self = <astroquery.ukidss.tests.test_ukidss_remote.TestUkidss instance at 0x10ac75d40> | |
| def test_get_images_2(self): | |
| images = ukidss.core.Ukidss.get_images(coord.Galactic | |
| (l=49.489, b=-0.27, unit=(u.deg, u.deg)), | |
| > image_width=5 * u.arcmin) | |
| astroquery/ukidss/tests/test_ukidss_remote.py:26: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.ukidss.core.UkidssClass object at 0x107cd19d0>, coordinates = <Galactic l=49.48900 deg, b=-0.27000 deg>, waveband = 'all' | |
| frame_type = 'stack', image_width = <Quantity 5.0 arcmin>, image_height = None, radius = None, database = 'UKIDSSDR7PLUS', programme_id = 'all', verbose = True | |
| get_query_payload = False | |
| def get_images(self, coordinates, waveband='all', frame_type='stack', | |
| image_width=1 * u.arcmin, image_height=None, radius=None, | |
| database='UKIDSSDR7PLUS', programme_id='all', | |
| verbose=True, get_query_payload=False): | |
| """ | |
| Get an image around a target/ coordinates from UKIDSS catalog. | |
| Parameters | |
| ---------- | |
| coordinates : str or `astropy.coordinates` object | |
| The target around which to search. It may be specified as a | |
| string in which case it is resolved using online services or as | |
| the appropriate `astropy.coordinates` object. ICRS coordinates | |
| may also be entered as strings as specified in the | |
| `astropy.coordinates` module. | |
| waveband : str | |
| The color filter to download. Must be one of ``'all'``, ``'J'``, | |
| ``'H'``, ``'K'``, ``'H2'``, ``'Z'``, ``'Y'``, ``'Br'``]. | |
| frame_type : str | |
| The type of image. Must be one of ``'stack'``, ``'normal'``, | |
| ``'interleave'``, ``'deep_stack'``, ``'confidence'``, | |
| ``'difference'``, ``'leavstack'``, ``'all'``] | |
| image_width : str or `~astropy.units.Quantity` object, optional | |
| The image size (along X). Cannot exceed 15 arcmin. If missing, | |
| defaults to 1 arcmin. | |
| image_height : str or `~astropy.units.Quantity` object, optional | |
| The image size (along Y). Cannot exceed 90 arcmin. If missing, | |
| same as image_width. | |
| radius : str or `~astropy.units.Quantity` object, optional | |
| The string must be parsable by `~astropy.coordinates.Angle`. The | |
| appropriate `~astropy.units.Quantity` object from `astropy.units` | |
| may also be used. When missing only image around the given position | |
| rather than multi-frames are retrieved. | |
| programme_id : str | |
| The survey or programme in which to search for. | |
| database : str | |
| The UKIDSS database to use. | |
| verbose : bool | |
| Defaults to `True`. When `True` prints additional messages. | |
| get_query_payload : bool, optional | |
| If `True` then returns the dictionary sent as the HTTP request. | |
| Defaults to `False`. | |
| Returns | |
| ------- | |
| list : A list of `~astropy.io.fits.HDUList` objects. | |
| """ | |
| readable_objs = self.get_images_async(coordinates, waveband=waveband, | |
| frame_type=frame_type, | |
| image_width=image_width, | |
| image_height=image_height, | |
| database=database, | |
| programme_id=programme_id, | |
| radius=radius, verbose=verbose, | |
| > get_query_payload=get_query_payload) | |
| astroquery/ukidss/core.py:207: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.ukidss.core.UkidssClass object at 0x107cd19d0>, coordinates = <Galactic l=49.48900 deg, b=-0.27000 deg>, waveband = 'all' | |
| frame_type = 'stack', image_width = <Quantity 5.0 arcmin>, image_height = None, radius = None, database = 'UKIDSSDR7PLUS', programme_id = 'all', verbose = True | |
| get_query_payload = False | |
| def get_images_async(self, coordinates, waveband='all', frame_type='stack', | |
| image_width=1 * u.arcmin, image_height=None, radius=None, | |
| database='UKIDSSDR7PLUS', programme_id='all', | |
| verbose=True, get_query_payload=False): | |
| """ | |
| Serves the same purpose as `get_images` but | |
| returns a list of file handlers to remote files. | |
| Parameters | |
| ---------- | |
| coordinates : str or `astropy.coordinates` object | |
| The target around which to search. It may be specified as a | |
| string in which case it is resolved using online services or as | |
| the appropriate `astropy.coordinates` object. ICRS coordinates | |
| may also be entered as strings as specified in the | |
| `astropy.coordinates` module. | |
| waveband : str | |
| The color filter to download. Must be one of ``'all'``, ``'J'``, | |
| ``'H'``, ``'K'``, ``'H2'``, ``'Z'``, ``'Y'``, ``'Br'``]. | |
| frame_type : str | |
| The type of image. Must be one of ``'stack'``, ``'normal'``, | |
| ``'interleave'``, ``'deep_stack'``, ``'confidence'``, | |
| ``'difference'``, ``'leavstack'``, ``'all'``] | |
| image_width : str or `~astropy.units.Quantity` object, optional | |
| The image size (along X). Cannot exceed 15 arcmin. If missing, | |
| defaults to 1 arcmin. | |
| image_height : str or `~astropy.units.Quantity` object, optional | |
| The image size (along Y). Cannot exceed 90 arcmin. If missing, | |
| same as image_width. | |
| radius : str or `~astropy.units.Quantity` object, optional | |
| The string must be parsable by `~astropy.coordinates.Angle`. The | |
| appropriate `~astropy.units.Quantity` object from `astropy.units` | |
| may also be used. When missing only image around the given position | |
| rather than multi-frames are retrieved. | |
| programme_id : str | |
| The survey or programme in which to search for. See `list_catalogs`. | |
| database : str | |
| The UKIDSS database to use. | |
| verbose : bool | |
| Defaults to `True`. When `True` prints additional messages. | |
| get_query_payload : bool, optional | |
| If `True` then returns the dictionary sent as the HTTP request. | |
| Defaults to `False`. | |
| Returns | |
| ------- | |
| list : A list of context-managers that yield readable file-like objects. | |
| """ | |
| image_urls = self.get_image_list(coordinates, waveband=waveband, | |
| frame_type=frame_type, | |
| image_width=image_width, | |
| image_height=image_height, | |
| database=database, radius=radius, | |
| programme_id=programme_id, | |
| > get_query_payload=get_query_payload) | |
| astroquery/ukidss/core.py:267: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| args = (<astroquery.ukidss.core.UkidssClass object at 0x107cd19d0>, <Galactic l=49.48900 deg, b=-0.27000 deg>) | |
| kwargs = {'database': 'UKIDSSDR7PLUS', 'frame_type': 'stack', 'get_query_payload': False, 'image_height': None, ...}, frame_type = 'stack' | |
| def wrapper(*args, **kwargs): | |
| frame_type = kwargs.get('frame_type') | |
| if frame_type not in UkidssClass.frame_types: | |
| raise ValueError("Invalid frame type. Valid frame types are: {!s}" | |
| .format(UkidssClass.frame_types)) | |
| > return func(*args, **kwargs) | |
| astroquery/ukidss/core.py:30: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| args = (<astroquery.ukidss.core.UkidssClass object at 0x107cd19d0>, <Galactic l=49.48900 deg, b=-0.27000 deg>) | |
| kwargs = {'database': 'UKIDSSDR7PLUS', 'frame_type': 'stack', 'get_query_payload': False, 'image_height': None, ...}, waveband = 'all' | |
| def wrapper(*args, **kwargs): | |
| waveband = kwargs.get('waveband') | |
| if waveband not in UkidssClass.filters: | |
| raise ValueError("Invalid waveband. Valid wavebands are: {!s}" | |
| .format(UkidssClass.filters.keys())) | |
| > return func(*args, **kwargs) | |
| astroquery/ukidss/core.py:40: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.ukidss.core.UkidssClass object at 0x107cd19d0>, coordinates = <Galactic l=49.48900 deg, b=-0.27000 deg>, waveband = 'all' | |
| frame_type = 'stack', image_width = <Quantity 5.0 arcmin>, image_height = None, radius = None, database = 'UKIDSSDR7PLUS', programme_id = 'all' | |
| get_query_payload = False | |
| @validate_frame | |
| @validate_filter | |
| def get_image_list(self, coordinates, waveband='all', frame_type='stack', | |
| image_width=1 * u.arcmin, image_height=None, radius=None, | |
| database='UKIDSSDR7PLUS', programme_id='all', | |
| get_query_payload=False): | |
| """ | |
| Function that returns a list of urls from which to download the FITS | |
| images. | |
| Parameters | |
| ---------- | |
| coordinates : str or `astropy.coordinates` object | |
| The target around which to search. It may be specified as a | |
| string in which case it is resolved using online services or as | |
| the appropriate `astropy.coordinates` object. ICRS coordinates | |
| may also be entered as strings as specified in the | |
| `astropy.coordinates` module. | |
| waveband : str | |
| The color filter to download. Must be one of ``'all'``, ``'J'``, | |
| ``'H'``, ``'K'``, ``'H2'``, ``'Z'``, ``'Y'``, ``'Br'``]. | |
| frame_type : str | |
| The type of image. Must be one of ``'stack'``, ``'normal'``, | |
| ``'interleave'``, ``'deep_stack'``, ``'confidence'``, | |
| ``'difference'``, ``'leavstack'``, ``'all'``] | |
| image_width : str or `~astropy.units.Quantity` object, optional | |
| The image size (along X). Cannot exceed 15 arcmin. If missing, | |
| defaults to 1 arcmin. | |
| image_height : str or `~astropy.units.Quantity` object, optional | |
| The image size (along Y). Cannot exceed 90 arcmin. If missing, | |
| same as image_width. | |
| radius : str or `~astropy.units.Quantity` object, optional | |
| The string must be parsable by `~astropy.coordinates.Angle`. The | |
| appropriate `~astropy.units.Quantity` object from | |
| `astropy.units` may also be used. When missing only image around | |
| the given position rather than multi-frames are retrieved. | |
| programme_id : str | |
| The survey or programme in which to search for. See `list_catalogs`. | |
| database : str | |
| The UKIDSS database to use. | |
| verbose : bool | |
| Defaults to `True`. When `True` prints additional messages. | |
| get_query_payload : bool, optional | |
| If `True` then returns the dictionary sent as the HTTP request. | |
| Defaults to `False`. | |
| Returns | |
| ------- | |
| url_list : list of image urls | |
| """ | |
| request_payload = self._args_to_payload(coordinates, database=database, | |
| programme_id=programme_id, | |
| > query_type='image') | |
| astroquery/ukidss/core.py:330: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.ukidss.core.UkidssClass object at 0x107cd19d0>, args = (<Galactic l=49.48900 deg, b=-0.27000 deg>,) | |
| kwargs = {'database': 'UKIDSSDR7PLUS', 'programme_id': 'all', 'query_type': 'image'} | |
| request_payload = {'database': 'UKIDSSDR7PLUS', 'programmeID': 'all', 'sys': 'J'}, programme_id = 'all', sys = 'J' | |
| def _args_to_payload(self, *args, **kwargs): | |
| request_payload = {} | |
| request_payload['database'] = kwargs['database'] if 'database' in kwargs else self.database | |
| programme_id = kwargs['programme_id'] if 'programme_id' in kwargs else self.programme_id | |
| request_payload['programmeID'] = verify_programme_id(programme_id, query_type=kwargs['query_type']) | |
| sys = self._parse_system(kwargs.get('system')) | |
| request_payload['sys'] = sys | |
| if sys == 'J': | |
| > request_payload['ra'] = commons.parse_coordinates(args[0]).icrs.ra.degree | |
| astroquery/ukidss/core.py:138: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <Galactic l=49.48900 deg, b=-0.27000 deg>, name = 'icrs' | |
| def __getattr__(self, name): | |
| """ | |
| Overrides getattr to return coordinates that this can be transformed | |
| to, based on the alias name in the master transform graph. | |
| """ | |
| from .transformations import master_transform_graph | |
| nmsys = master_transform_graph.lookup_name(name) | |
| if self.__class__ is nmsys: | |
| return self | |
| if nmsys is not None and self.is_transformable_to(nmsys): | |
| > return self.transform_to(nmsys) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:659: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <Galactic l=49.48900 deg, b=-0.27000 deg>, tosys = <class 'astropy.coordinates.builtin_systems.ICRS'> | |
| def transform_to(self, tosys): | |
| """ | |
| Transform this coordinate to a new system. | |
| Parameters | |
| ---------- | |
| tosys : class | |
| The system to transform this coordinate into. | |
| Returns | |
| ------- | |
| transcoord | |
| A new object with this coordinate represented in the | |
| ``tosys`` system. | |
| Raises | |
| ------ | |
| ValueError | |
| If there is no possible transformation route. | |
| """ | |
| from .transformations import master_transform_graph | |
| from .errors import ConvertError | |
| if tosys is self.__class__: | |
| return copy.deepcopy(self) | |
| trans = master_transform_graph.get_transform(self.__class__, tosys) | |
| if trans is None: | |
| raise ConvertError('Cannot transform from {0} to ' | |
| '{1}'.format(self.__class__, tosys)) | |
| > return trans(self) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:622: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.CompositeTransform object at 0x10a249f10>, fromcoord = <Galactic l=49.48900 deg, b=-0.27000 deg> | |
| super(CompositeTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| > coord = fromcoord | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:742: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.DynamicMatrixTransform object at 0x1067c5990>, fromcoord = <Galactic l=49.48900 deg, b=-0.27000 deg> | |
| super(DynamicMatrixTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| c = fromcoord.cartesian | |
| v = c.reshape((3, c.size // 3)) | |
| v2 = np.dot(np.asarray(self.matrix_func(fromcoord)), v) | |
| subshape = c.shape[1:] | |
| x = v2[0].reshape(subshape) | |
| y = v2[1].reshape(subshape) | |
| z = v2[2].reshape(subshape) | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:708: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x109672f38>, args = () | |
| kwargs = {'unit': None, 'x': <CartesianPoints 0.34410059916096>, 'y': <CartesianPoints -0.9046319556956074>, 'z': <CartesianPoints 0.25146729885098157>} | |
| def __init__(self, *args, **kwargs): | |
| super(FK5, self).__init__() | |
| self._equinox = kwargs.pop('equinox', _EQUINOX_J2000) | |
| self._obstime = kwargs.pop('obstime', None) | |
| if not isinstance(self._equinox, Time): | |
| raise TypeError('specified equinox is not a Time object') | |
| if self._obstime is not None and not isinstance(self._obstime, Time): | |
| raise TypeError('specified obstime is not None or a Time object') | |
| if not self._equinox.isscalar: | |
| raise ValueError('specified equinox is not a scalar') | |
| if len(args) == 1 and len(kwargs) == 0 and isinstance(args[0], SphericalCoordinatesBase): | |
| newcoord = args[0].transform_to(self.__class__) | |
| self._latangle = newcoord._latangle | |
| self._lonangle = newcoord._lonangle | |
| self._distance = newcoord._distance | |
| else: | |
| > super(FK5, self)._initialize_latlon('ra', 'dec', args, kwargs) | |
| /Users/adam/repos/astropy/astropy/coordinates/builtin_systems.py:140: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x107e81e18>, lonname = 'ra' | |
| latname = 'dec', initargs = (), initkwargs = {} | |
| def _initialize_latlon(self, lonname, latname, initargs, initkwargs): | |
| """ | |
| Subclasses should use this to initialize standard lat/lon-style | |
| coordinates. | |
| This recognizes both the lat/lon style and the cartesian form. | |
| Parameters | |
| ---------- | |
| lonname : str | |
| The name of the longitude-like coordinate attribute | |
| latname : str | |
| The name of the latitude-like coordinate attribute | |
| initargs : list | |
| The ``*args`` from the initializer | |
| initkwargs : dict | |
| The ``**kwargs`` from the initializer | |
| """ | |
| initkwargs = dict(initkwargs) # copy | |
| nargs = len(initargs) | |
| sclsnm = self.__class__.__name__ | |
| if nargs == 1: | |
| if isinstance(initargs[0], CartesianPoints): | |
| initkwargs['cartpoint'] = initargs[0] | |
| else: | |
| initkwargs['coordstr'] = initargs[0] | |
| if nargs > 1: | |
| if lonname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, lonname)) | |
| initkwargs[lonname] = initargs[0] | |
| if nargs >= 2: | |
| if latname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, latname)) | |
| initkwargs[latname] = initargs[1] | |
| if nargs > 2: | |
| raise TypeError('{0} takes up to 2 positional arguments ' | |
| '({1} given)'.format(sclsnm, len(initargs))) | |
| unit = initkwargs.pop('unit', None) | |
| coordstr = initkwargs.pop('coordstr', None) | |
| lonval = initkwargs.pop(lonname, None) | |
| latval = initkwargs.pop(latname, None) | |
| distval = initkwargs.pop('distance', None) | |
| cartpoint = initkwargs.pop('cartpoint', None) | |
| x = initkwargs.pop('x', None) | |
| y = initkwargs.pop('y', None) | |
| z = initkwargs.pop('z', None) | |
| if len(initkwargs) > 0: | |
| raise TypeError('{0} got unexpected keyword argument' | |
| ' {1}'.format(sclsnm, initkwargs.keys())) | |
| angleinit = ((lonval is not None and latval is not None) or | |
| coordstr is not None) | |
| cartinit = ((x is not None and y is not None and z is not None) or | |
| cartpoint is not None) | |
| if angleinit and not cartinit: | |
| # lat/lon-style initialization | |
| for v in [x, y, z, cartpoint]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| try: | |
| # this raises a TypeError if `unit` is not None or iterable | |
| units = [None, None] if unit is None else list(unit) | |
| except TypeError: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a ' | |
| 'non-sequence {1}'.format(sclsnm, unit)) | |
| if len(units) == 2: | |
| try: | |
| if units[0] is not None: | |
| units[0] = u.Unit(units[0]) | |
| if units[1] is not None: | |
| units[1] = u.Unit(units[1]) | |
| except ValueError: | |
| raise ValueError('Could not convert units to unit objects ' | |
| 'while initializing ' + sclsnm) | |
| else: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a sequence ' | |
| 'of {1}.'.format(sclsnm, len(units))) | |
| if coordstr is not None: | |
| # need to try to parse the coordinate from a single argument | |
| # populates latval and lonval variables, which then get made | |
| # into coordinates below | |
| if isinstance(coordstr, six.string_types): | |
| if "," in coordstr: | |
| lonval, latval = coordstr.split(",") | |
| else: | |
| coosplit = coordstr.split() | |
| if len(coosplit) == 6: | |
| lonval = " ".join(coosplit[0:3]) | |
| latval = " ".join(coosplit[3:]) | |
| elif len(coosplit) == 2: | |
| lonval, latval = coosplit | |
| else: | |
| msg = ("Could not parse {lonname}/{latname} values " | |
| "from the string provided: '{coordstr}'.") | |
| raise ValueError(msg.format(lonname=lonname, | |
| latname=latname, | |
| coordstr=coordstr)) | |
| else: | |
| raise ValueError("A {0} cannot be created with a single value of type " | |
| "'{1}', must be a string.".format(sclsnm, type(coordstr).__name__)) | |
| # now actually create the angle objects | |
| lonang = Longitude(lonval, unit=units[0]) | |
| latang = Latitude(latval, unit=units[1]) | |
| dist = None if distval is None else Distance(distval) # copy | |
| elif cartinit and not angleinit: | |
| # cartesian-style initialization | |
| for v in [coordstr, lonval, latval, distval]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| if cartpoint is not None: | |
| for v in [x, y, z, unit]: | |
| if v is not None: | |
| raise ValueError('Cannot give both a CartesianPoints ' | |
| 'and x/y/z/unit parameters while ' | |
| 'initializing ' + sclsnm) | |
| x = cartpoint.x | |
| y = cartpoint.y | |
| z = cartpoint.z | |
| unit = cartpoint.unit | |
| > r, latval, lonval = cartesian_to_spherical(x, y, z) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:235: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| x = <CartesianPoints 0.34410059916096>, y = <CartesianPoints -0.9046319556956074>, z = <CartesianPoints 0.25146729885098157> | |
| x : scalar or array-like | |
| The first cartesian coordinate. | |
| y : scalar or array-like | |
| The second cartesian coordinate. | |
| z : scalar or array-like | |
| The third cartesian coordinate. | |
| Returns | |
| ------- | |
| r : float or array | |
| The radial coordinate (in the same units as the inputs). | |
| lat : float or array | |
| The latitude in radians | |
| lon : float or array | |
| The longitude in radians | |
| """ | |
| xsq = x ** 2 | |
| ysq = y ** 2 | |
| zsq = z ** 2 | |
| r = (xsq + ysq + zsq) ** 0.5 | |
| s = (xsq + ysq) ** 0.5 | |
| if np.isscalar(x) and np.isscalar(y) and np.isscalar(z): | |
| lon = math.atan2(y, x) | |
| lat = math.atan2(z, s) | |
| else: | |
| lon = np.arctan2(y, x) | |
| lat = np.arctan2(z, s) | |
| return r, lat, lon | |
| def spherical_to_cartesian(r, lat, lon): | |
| """ | |
| Converts spherical polar coordinates to rectangular cartesian | |
| coordinates. | |
| Note that the input angles should be in latitude/longitude or | |
| elevation/azimuthal form. I.e., the origin is along the equator | |
| rather than at the north pole. | |
| .. note:: | |
| This is a low-level function used internally in | |
| > `astropy.coordinates`. It is provided for users if they really | |
| want to use it, but it is recommended that you use the | |
| `astropy.coordinates` coordinate systems. | |
| Parameters | |
| ---------- | |
| r : scalar or array-like | |
| The radial coordinate (in the same units as the inputs). | |
| lat : scalar or array-like | |
| The latitude in radians | |
| lon : scalar or array-like | |
| The longitude in radians | |
| Returns | |
| ------- | |
| x : float or array | |
| The first cartesian coordinate. | |
| y : float or array | |
| The second cartesian coordinate. | |
| z : float or array | |
| The third cartesian coordinate. | |
| """ | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:441: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints -0.9046319556956074>, obj = array(2.315841784746324e+77) | |
| context = (<ufunc 'arctan2'>, (<CartesianPoints -0.9046319556956074>, <CartesianPoints 0.34410059916096>), 0) | |
| raise TypeError("The value must be a valid Python or " | |
| "Numpy numeric type.") | |
| # by default, cast any integer, boolean, etc., to float | |
| if dtype is None and not np.can_cast(np.float32, value.dtype): | |
| value = value.astype(np.float) | |
| value = value.view(cls) | |
| value._unit = unit | |
| return value | |
| def __array_finalize__(self, obj): | |
| self._unit = getattr(obj, '_unit', None) | |
| def __array_prepare__(self, obj, context=None): | |
| # This method gets called by Numpy whenever a ufunc is called on the | |
| # array. The object passed in ``obj`` is an empty version of the | |
| # output array which we can e.g. change to an array sub-class, add | |
| # attributes to, etc. After this is called, then the ufunc is called | |
| # and the values in this empty array are set. | |
| # If no context is set, just return the input | |
| if context is None: | |
| return obj | |
| # Find out which ufunc is being used | |
| function = context[0] | |
| from .quantity_helper import UNSUPPORTED_UFUNCS, UFUNC_HELPERS | |
| # Check whether we even support this ufunc | |
| if function in UNSUPPORTED_UFUNCS: | |
| raise TypeError("Cannot use function '{0}' with quantities" | |
| .format(function.__name__)) | |
| # Now find out what arguments were passed to the ufunc, usually, this | |
| # will include at least the present object, and another, which could | |
| # be a Quantity, or a Numpy array, etc. when using two-argument ufuncs. | |
| args = context[1][:function.nin] | |
| units = [getattr(arg, 'unit', None) for arg in args] | |
| # If the ufunc is supported, then we call a helper function (defined | |
| # in quantity_helper.py) which returns the scale by which the inputs | |
| # should be multiplied before being passed to the ufunc, as well as | |
| # the unit the output from the ufunc will have. | |
| if function in UFUNC_HELPERS: | |
| scales, result_unit = UFUNC_HELPERS[function](function, *units) | |
| else: | |
| raise TypeError("Unknown ufunc {0}. Please raise issue on " | |
| "https://github.com/astropy/astropy" | |
| .format(function.__name__)) | |
| if any(scale == 0. for scale in scales): | |
| # for two-argument ufuncs with a quantity and a non-quantity, | |
| # the quantity normally needs to be dimensionless, *except* | |
| # if the non-quantity can have arbitrary unit, i.e., when it | |
| # is all zero, infinity or NaN. In that case, the non-quantity | |
| # can just have the unit of the quantity | |
| # (this allows, e.g., `q > 0.` independent of unit) | |
| maybe_arbitrary_arg = args[scales.index(0.)] | |
| if _can_have_arbitrary_unit(maybe_arbitrary_arg): | |
| scales = [1., 1.] | |
| else: | |
| raise UnitsError("Can only apply '{0}' function to " | |
| "dimensionless quantities when other " | |
| "argument is not a quantity (unless the " | |
| "latter is all zero/infinity/nan)" | |
| .format(function.__name__)) | |
| # In the case of np.power, the unit itself needs to be modified by an | |
| # amount that depends on one of the input values, so we need to treat | |
| # this as a special case. | |
| # TODO: find a better way to deal with this case | |
| if function is np.power and result_unit is not None: | |
| if units[1] is None: | |
| p = args[1] | |
| else: | |
| p = args[1].to(dimensionless_unscaled).value | |
| result_unit = result_unit ** validate_power(p) | |
| # We now prepare the output object | |
| if self is obj: # happens if the output object is self, which happens | |
| # for in-place operations such as q1 += q2 | |
| # In some cases, the result of a ufunc should be a plain Numpy | |
| # array, which we can't do if we are doing an in-place operation. | |
| if result_unit is None: | |
| raise TypeError("Cannot store non-quantity output from {0} " | |
| "function in Quantity object" | |
| .format(function.__name__)) | |
| /Users/adam/repos/astropy/astropy/units/quantity.py:311: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints -0.9046319556956074>, obj = array(2.315841784746324e+77), unit = Unit("rad") | |
| #screw up the units are killed by _convert_to_and_validate_length_unit | |
| obj = super(CartesianPoints, self).__array_wrap__(obj, context=context) | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:310: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = AssertionError(), args = (), f = <py._code.code.Frame object at 0x108242210> | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| > ??? | |
| _pytest.assertion.reinterpret:40: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| frame = <py._code.code.Frame object at 0x108242210>, should_fail = True | |
| > ??? | |
| _pytest.assertion.newinterpret:46: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| filename = '<unknown>', mode = 'exec' | |
| def parse(source, filename='<unknown>', mode='exec'): | |
| """ | |
| Parse the source into an AST node. | |
| Equivalent to compile(source, filename, mode, PyCF_ONLY_AST). | |
| """ | |
| > return compile(source, filename, mode, PyCF_ONLY_AST) | |
| E File "<unknown>", line 1 | |
| E .. note:: | |
| E ^ | |
| E SyntaxError: invalid syntax | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py:37: SyntaxError | |
| _____________________________________________________________ TestUkidss.test_query_region_async ______________________________________________________________ | |
| self = <astroquery.ukidss.tests.test_ukidss_remote.TestUkidss instance at 0x107ce3908> | |
| def test_query_region_async(self): | |
| response = ukidss.core.Ukidss.query_region_async(coord.Galactic | |
| (l=10.625, b=-0.38, unit=(u.deg, u.deg)), | |
| > radius=6 * u.arcsec) | |
| astroquery/ukidss/tests/test_ukidss_remote.py:42: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.ukidss.core.UkidssClass object at 0x107cd19d0>, coordinates = <Galactic l=10.62500 deg, b=-0.38000 deg>, radius = <Quantity 6.0 arcsec> | |
| programme_id = 'GPS', database = 'UKIDSSDR7PLUS', get_query_payload = False, system = 'J2000' | |
| def query_region_async(self, coordinates, radius=1 * u.arcmin, | |
| programme_id='GPS', | |
| database='UKIDSSDR7PLUS', get_query_payload=False, | |
| system='J2000'): | |
| """ | |
| Serves the same purpose as `query_region`. But | |
| returns the raw HTTP response rather than the parsed result. | |
| Parameters | |
| ---------- | |
| coordinates : str or `astropy.coordinates` object | |
| The target around which to search. It may be specified as a | |
| string in which case it is resolved using online services or as | |
| the appropriate `astropy.coordinates` object. ICRS coordinates | |
| may also be entered as strings as specified in the | |
| `astropy.coordinates` module. | |
| radius : str or `~astropy.units.Quantity` object, optional | |
| The string must be parsable by `~astropy.coordinates.Angle`. The | |
| appropriate `~astropy.units.Quantity` object from | |
| `astropy.units` may also be used. When missing defaults to 1 | |
| arcmin. Cannot exceed 90 arcmin. | |
| programme_id : str | |
| The survey or programme in which to search for. See `list_catalogs`. | |
| database : str | |
| The UKIDSS database to use. | |
| get_query_payload : bool, optional | |
| If `True` then returns the dictionary sent as the HTTP request. | |
| Defaults to `False`. | |
| Returns | |
| ------- | |
| response : `requests.Response` | |
| The HTTP response returned from the service. | |
| """ | |
| request_payload = self._args_to_payload(coordinates, | |
| programme_id=programme_id, | |
| database=database, | |
| system=system, | |
| > query_type='catalog') | |
| astroquery/ukidss/core.py:496: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.ukidss.core.UkidssClass object at 0x107cd19d0>, args = (<Galactic l=10.62500 deg, b=-0.38000 deg>,) | |
| kwargs = {'database': 'UKIDSSDR7PLUS', 'programme_id': 'GPS', 'query_type': 'catalog', 'system': 'J2000'} | |
| request_payload = {'database': 'UKIDSSDR7PLUS', 'programmeID': 102, 'sys': 'J'}, programme_id = 'GPS', sys = 'J' | |
| def _args_to_payload(self, *args, **kwargs): | |
| request_payload = {} | |
| request_payload['database'] = kwargs['database'] if 'database' in kwargs else self.database | |
| programme_id = kwargs['programme_id'] if 'programme_id' in kwargs else self.programme_id | |
| request_payload['programmeID'] = verify_programme_id(programme_id, query_type=kwargs['query_type']) | |
| sys = self._parse_system(kwargs.get('system')) | |
| request_payload['sys'] = sys | |
| if sys == 'J': | |
| > request_payload['ra'] = commons.parse_coordinates(args[0]).icrs.ra.degree | |
| astroquery/ukidss/core.py:138: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <Galactic l=10.62500 deg, b=-0.38000 deg>, name = 'icrs' | |
| def __getattr__(self, name): | |
| """ | |
| Overrides getattr to return coordinates that this can be transformed | |
| to, based on the alias name in the master transform graph. | |
| """ | |
| from .transformations import master_transform_graph | |
| nmsys = master_transform_graph.lookup_name(name) | |
| if self.__class__ is nmsys: | |
| return self | |
| if nmsys is not None and self.is_transformable_to(nmsys): | |
| > return self.transform_to(nmsys) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:659: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <Galactic l=10.62500 deg, b=-0.38000 deg>, tosys = <class 'astropy.coordinates.builtin_systems.ICRS'> | |
| def transform_to(self, tosys): | |
| """ | |
| Transform this coordinate to a new system. | |
| Parameters | |
| ---------- | |
| tosys : class | |
| The system to transform this coordinate into. | |
| Returns | |
| ------- | |
| transcoord | |
| A new object with this coordinate represented in the | |
| ``tosys`` system. | |
| Raises | |
| ------ | |
| ValueError | |
| If there is no possible transformation route. | |
| """ | |
| from .transformations import master_transform_graph | |
| from .errors import ConvertError | |
| if tosys is self.__class__: | |
| return copy.deepcopy(self) | |
| trans = master_transform_graph.get_transform(self.__class__, tosys) | |
| if trans is None: | |
| raise ConvertError('Cannot transform from {0} to ' | |
| '{1}'.format(self.__class__, tosys)) | |
| > return trans(self) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:622: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.CompositeTransform object at 0x1022aa3d0>, fromcoord = <Galactic l=10.62500 deg, b=-0.38000 deg> | |
| super(CompositeTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| > coord = fromcoord | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:742: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.DynamicMatrixTransform object at 0x1067c5990>, fromcoord = <Galactic l=10.62500 deg, b=-0.38000 deg> | |
| super(DynamicMatrixTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| c = fromcoord.cartesian | |
| v = c.reshape((3, c.size // 3)) | |
| v2 = np.dot(np.asarray(self.matrix_func(fromcoord)), v) | |
| subshape = c.shape[1:] | |
| x = v2[0].reshape(subshape) | |
| y = v2[1].reshape(subshape) | |
| z = v2[2].reshape(subshape) | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:708: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x10830b5a8>, args = () | |
| kwargs = {'unit': None, 'x': <CartesianPoints 0.042922274488051144>, 'y': <CartesianPoints -0.9391451292955936>, 'z': <CartesianPoints -0.34082855583582683>} | |
| def __init__(self, *args, **kwargs): | |
| super(FK5, self).__init__() | |
| self._equinox = kwargs.pop('equinox', _EQUINOX_J2000) | |
| self._obstime = kwargs.pop('obstime', None) | |
| if not isinstance(self._equinox, Time): | |
| raise TypeError('specified equinox is not a Time object') | |
| if self._obstime is not None and not isinstance(self._obstime, Time): | |
| raise TypeError('specified obstime is not None or a Time object') | |
| if not self._equinox.isscalar: | |
| raise ValueError('specified equinox is not a scalar') | |
| if len(args) == 1 and len(kwargs) == 0 and isinstance(args[0], SphericalCoordinatesBase): | |
| newcoord = args[0].transform_to(self.__class__) | |
| self._latangle = newcoord._latangle | |
| self._lonangle = newcoord._lonangle | |
| self._distance = newcoord._distance | |
| else: | |
| > super(FK5, self)._initialize_latlon('ra', 'dec', args, kwargs) | |
| /Users/adam/repos/astropy/astropy/coordinates/builtin_systems.py:140: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x10ac62878>, lonname = 'ra' | |
| latname = 'dec', initargs = (), initkwargs = {} | |
| def _initialize_latlon(self, lonname, latname, initargs, initkwargs): | |
| """ | |
| Subclasses should use this to initialize standard lat/lon-style | |
| coordinates. | |
| This recognizes both the lat/lon style and the cartesian form. | |
| Parameters | |
| ---------- | |
| lonname : str | |
| The name of the longitude-like coordinate attribute | |
| latname : str | |
| The name of the latitude-like coordinate attribute | |
| initargs : list | |
| The ``*args`` from the initializer | |
| initkwargs : dict | |
| The ``**kwargs`` from the initializer | |
| """ | |
| initkwargs = dict(initkwargs) # copy | |
| nargs = len(initargs) | |
| sclsnm = self.__class__.__name__ | |
| if nargs == 1: | |
| if isinstance(initargs[0], CartesianPoints): | |
| initkwargs['cartpoint'] = initargs[0] | |
| else: | |
| initkwargs['coordstr'] = initargs[0] | |
| if nargs > 1: | |
| if lonname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, lonname)) | |
| initkwargs[lonname] = initargs[0] | |
| if nargs >= 2: | |
| if latname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, latname)) | |
| initkwargs[latname] = initargs[1] | |
| if nargs > 2: | |
| raise TypeError('{0} takes up to 2 positional arguments ' | |
| '({1} given)'.format(sclsnm, len(initargs))) | |
| unit = initkwargs.pop('unit', None) | |
| coordstr = initkwargs.pop('coordstr', None) | |
| lonval = initkwargs.pop(lonname, None) | |
| latval = initkwargs.pop(latname, None) | |
| distval = initkwargs.pop('distance', None) | |
| cartpoint = initkwargs.pop('cartpoint', None) | |
| x = initkwargs.pop('x', None) | |
| y = initkwargs.pop('y', None) | |
| z = initkwargs.pop('z', None) | |
| if len(initkwargs) > 0: | |
| raise TypeError('{0} got unexpected keyword argument' | |
| ' {1}'.format(sclsnm, initkwargs.keys())) | |
| angleinit = ((lonval is not None and latval is not None) or | |
| coordstr is not None) | |
| cartinit = ((x is not None and y is not None and z is not None) or | |
| cartpoint is not None) | |
| if angleinit and not cartinit: | |
| # lat/lon-style initialization | |
| for v in [x, y, z, cartpoint]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| try: | |
| # this raises a TypeError if `unit` is not None or iterable | |
| units = [None, None] if unit is None else list(unit) | |
| except TypeError: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a ' | |
| 'non-sequence {1}'.format(sclsnm, unit)) | |
| if len(units) == 2: | |
| try: | |
| if units[0] is not None: | |
| units[0] = u.Unit(units[0]) | |
| if units[1] is not None: | |
| units[1] = u.Unit(units[1]) | |
| except ValueError: | |
| raise ValueError('Could not convert units to unit objects ' | |
| 'while initializing ' + sclsnm) | |
| else: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a sequence ' | |
| 'of {1}.'.format(sclsnm, len(units))) | |
| if coordstr is not None: | |
| # need to try to parse the coordinate from a single argument | |
| # populates latval and lonval variables, which then get made | |
| # into coordinates below | |
| if isinstance(coordstr, six.string_types): | |
| if "," in coordstr: | |
| lonval, latval = coordstr.split(",") | |
| else: | |
| coosplit = coordstr.split() | |
| if len(coosplit) == 6: | |
| lonval = " ".join(coosplit[0:3]) | |
| latval = " ".join(coosplit[3:]) | |
| elif len(coosplit) == 2: | |
| lonval, latval = coosplit | |
| else: | |
| msg = ("Could not parse {lonname}/{latname} values " | |
| "from the string provided: '{coordstr}'.") | |
| raise ValueError(msg.format(lonname=lonname, | |
| latname=latname, | |
| coordstr=coordstr)) | |
| else: | |
| raise ValueError("A {0} cannot be created with a single value of type " | |
| "'{1}', must be a string.".format(sclsnm, type(coordstr).__name__)) | |
| # now actually create the angle objects | |
| lonang = Longitude(lonval, unit=units[0]) | |
| latang = Latitude(latval, unit=units[1]) | |
| dist = None if distval is None else Distance(distval) # copy | |
| elif cartinit and not angleinit: | |
| # cartesian-style initialization | |
| for v in [coordstr, lonval, latval, distval]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| if cartpoint is not None: | |
| for v in [x, y, z, unit]: | |
| if v is not None: | |
| raise ValueError('Cannot give both a CartesianPoints ' | |
| 'and x/y/z/unit parameters while ' | |
| 'initializing ' + sclsnm) | |
| x = cartpoint.x | |
| y = cartpoint.y | |
| z = cartpoint.z | |
| unit = cartpoint.unit | |
| > r, latval, lonval = cartesian_to_spherical(x, y, z) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:235: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| x = <CartesianPoints 0.042922274488051144>, y = <CartesianPoints -0.9391451292955936>, z = <CartesianPoints -0.34082855583582683> | |
| x : scalar or array-like | |
| The first cartesian coordinate. | |
| y : scalar or array-like | |
| The second cartesian coordinate. | |
| z : scalar or array-like | |
| The third cartesian coordinate. | |
| Returns | |
| ------- | |
| r : float or array | |
| The radial coordinate (in the same units as the inputs). | |
| lat : float or array | |
| The latitude in radians | |
| lon : float or array | |
| The longitude in radians | |
| """ | |
| xsq = x ** 2 | |
| ysq = y ** 2 | |
| zsq = z ** 2 | |
| r = (xsq + ysq + zsq) ** 0.5 | |
| s = (xsq + ysq) ** 0.5 | |
| if np.isscalar(x) and np.isscalar(y) and np.isscalar(z): | |
| lon = math.atan2(y, x) | |
| lat = math.atan2(z, s) | |
| else: | |
| lon = np.arctan2(y, x) | |
| lat = np.arctan2(z, s) | |
| return r, lat, lon | |
| def spherical_to_cartesian(r, lat, lon): | |
| """ | |
| Converts spherical polar coordinates to rectangular cartesian | |
| coordinates. | |
| Note that the input angles should be in latitude/longitude or | |
| elevation/azimuthal form. I.e., the origin is along the equator | |
| rather than at the north pole. | |
| .. note:: | |
| This is a low-level function used internally in | |
| > `astropy.coordinates`. It is provided for users if they really | |
| want to use it, but it is recommended that you use the | |
| `astropy.coordinates` coordinate systems. | |
| Parameters | |
| ---------- | |
| r : scalar or array-like | |
| The radial coordinate (in the same units as the inputs). | |
| lat : scalar or array-like | |
| The latitude in radians | |
| lon : scalar or array-like | |
| The longitude in radians | |
| Returns | |
| ------- | |
| x : float or array | |
| The first cartesian coordinate. | |
| y : float or array | |
| The second cartesian coordinate. | |
| z : float or array | |
| The third cartesian coordinate. | |
| """ | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:441: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints -0.9391451292955936>, obj = array(2.315841784746324e+77) | |
| context = (<ufunc 'arctan2'>, (<CartesianPoints -0.9391451292955936>, <CartesianPoints 0.042922274488051144>), 0) | |
| raise TypeError("The value must be a valid Python or " | |
| "Numpy numeric type.") | |
| # by default, cast any integer, boolean, etc., to float | |
| if dtype is None and not np.can_cast(np.float32, value.dtype): | |
| value = value.astype(np.float) | |
| value = value.view(cls) | |
| value._unit = unit | |
| return value | |
| def __array_finalize__(self, obj): | |
| self._unit = getattr(obj, '_unit', None) | |
| def __array_prepare__(self, obj, context=None): | |
| # This method gets called by Numpy whenever a ufunc is called on the | |
| # array. The object passed in ``obj`` is an empty version of the | |
| # output array which we can e.g. change to an array sub-class, add | |
| # attributes to, etc. After this is called, then the ufunc is called | |
| # and the values in this empty array are set. | |
| # If no context is set, just return the input | |
| if context is None: | |
| return obj | |
| # Find out which ufunc is being used | |
| function = context[0] | |
| from .quantity_helper import UNSUPPORTED_UFUNCS, UFUNC_HELPERS | |
| # Check whether we even support this ufunc | |
| if function in UNSUPPORTED_UFUNCS: | |
| raise TypeError("Cannot use function '{0}' with quantities" | |
| .format(function.__name__)) | |
| # Now find out what arguments were passed to the ufunc, usually, this | |
| # will include at least the present object, and another, which could | |
| # be a Quantity, or a Numpy array, etc. when using two-argument ufuncs. | |
| args = context[1][:function.nin] | |
| units = [getattr(arg, 'unit', None) for arg in args] | |
| # If the ufunc is supported, then we call a helper function (defined | |
| # in quantity_helper.py) which returns the scale by which the inputs | |
| # should be multiplied before being passed to the ufunc, as well as | |
| # the unit the output from the ufunc will have. | |
| if function in UFUNC_HELPERS: | |
| scales, result_unit = UFUNC_HELPERS[function](function, *units) | |
| else: | |
| raise TypeError("Unknown ufunc {0}. Please raise issue on " | |
| "https://github.com/astropy/astropy" | |
| .format(function.__name__)) | |
| if any(scale == 0. for scale in scales): | |
| # for two-argument ufuncs with a quantity and a non-quantity, | |
| # the quantity normally needs to be dimensionless, *except* | |
| # if the non-quantity can have arbitrary unit, i.e., when it | |
| # is all zero, infinity or NaN. In that case, the non-quantity | |
| # can just have the unit of the quantity | |
| # (this allows, e.g., `q > 0.` independent of unit) | |
| maybe_arbitrary_arg = args[scales.index(0.)] | |
| if _can_have_arbitrary_unit(maybe_arbitrary_arg): | |
| scales = [1., 1.] | |
| else: | |
| raise UnitsError("Can only apply '{0}' function to " | |
| "dimensionless quantities when other " | |
| "argument is not a quantity (unless the " | |
| "latter is all zero/infinity/nan)" | |
| .format(function.__name__)) | |
| # In the case of np.power, the unit itself needs to be modified by an | |
| # amount that depends on one of the input values, so we need to treat | |
| # this as a special case. | |
| # TODO: find a better way to deal with this case | |
| if function is np.power and result_unit is not None: | |
| if units[1] is None: | |
| p = args[1] | |
| else: | |
| p = args[1].to(dimensionless_unscaled).value | |
| result_unit = result_unit ** validate_power(p) | |
| # We now prepare the output object | |
| if self is obj: # happens if the output object is self, which happens | |
| # for in-place operations such as q1 += q2 | |
| # In some cases, the result of a ufunc should be a plain Numpy | |
| # array, which we can't do if we are doing an in-place operation. | |
| if result_unit is None: | |
| raise TypeError("Cannot store non-quantity output from {0} " | |
| "function in Quantity object" | |
| .format(function.__name__)) | |
| /Users/adam/repos/astropy/astropy/units/quantity.py:311: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints -0.9391451292955936>, obj = array(2.315841784746324e+77), unit = Unit("rad") | |
| #screw up the units are killed by _convert_to_and_validate_length_unit | |
| obj = super(CartesianPoints, self).__array_wrap__(obj, context=context) | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:310: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = AssertionError(), args = (), f = <py._code.code.Frame object at 0x109652b90> | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| > ??? | |
| _pytest.assertion.reinterpret:40: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| frame = <py._code.code.Frame object at 0x109652b90>, should_fail = True | |
| > ??? | |
| _pytest.assertion.newinterpret:46: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| filename = '<unknown>', mode = 'exec' | |
| def parse(source, filename='<unknown>', mode='exec'): | |
| """ | |
| Parse the source into an AST node. | |
| Equivalent to compile(source, filename, mode, PyCF_ONLY_AST). | |
| """ | |
| > return compile(source, filename, mode, PyCF_ONLY_AST) | |
| E File "<unknown>", line 1 | |
| E .. note:: | |
| E ^ | |
| E SyntaxError: invalid syntax | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py:37: SyntaxError | |
| ________________________________________________________________ TestUkidss.test_query_region _________________________________________________________________ | |
| self = <astroquery.ukidss.tests.test_ukidss_remote.TestUkidss instance at 0x1082f9440> | |
| def test_query_region(self): | |
| table = ukidss.core.Ukidss.query_region(coord.Galactic | |
| (l=10.625, b=-0.38, unit=(u.deg, u.deg)), | |
| > radius=6 * u.arcsec) | |
| astroquery/ukidss/tests/test_ukidss_remote.py:48: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.ukidss.core.UkidssClass object at 0x107cd19d0>, coordinates = <Galactic l=10.62500 deg, b=-0.38000 deg>, radius = <Quantity 6.0 arcsec> | |
| programme_id = 'GPS', database = 'UKIDSSDR7PLUS', verbose = False, get_query_payload = False, system = 'J2000' | |
| def query_region(self, coordinates, radius=1 * u.arcmin, | |
| programme_id='GPS', database='UKIDSSDR7PLUS', | |
| verbose=False, get_query_payload=False, system='J2000'): | |
| """ | |
| Used to query a region around a known identifier or given | |
| coordinates from the catalog. | |
| Parameters | |
| ---------- | |
| coordinates : str or `astropy.coordinates` object | |
| The target around which to search. It may be specified as a string | |
| in which case it is resolved using online services or as the | |
| appropriate `astropy.coordinates` object. ICRS coordinates may also | |
| be entered as strings as specified in the `astropy.coordinates` | |
| module. | |
| radius : str or `~astropy.units.Quantity` object, optional | |
| The string must be parsable by `~astropy.coordinates.Angle`. The | |
| appropriate `~astropy.units.Quantity` object from | |
| `astropy.units` may also be used. When missing defaults to 1 | |
| arcmin. Cannot exceed 90 arcmin. | |
| programme_id : str | |
| The survey or programme in which to search for. See `list_catalogs`. | |
| database : str | |
| The UKIDSS database to use. | |
| verbose : bool, optional. | |
| When set to `True` displays warnings if the returned VOTable does | |
| not conform to the standard. Defaults to `False`. | |
| get_query_payload : bool, optional | |
| If `True` then returns the dictionary sent as the HTTP request. | |
| Defaults to `False`. | |
| system : 'J2000' or 'Galactic' | |
| The system in which to perform the query. Can affect the output | |
| data columns. | |
| Returns | |
| ------- | |
| result : `~astropy.table.Table` | |
| Query result table. | |
| """ | |
| response = self.query_region_async(coordinates, radius=radius, | |
| programme_id=programme_id, | |
| database=database, | |
| get_query_payload=get_query_payload, | |
| > system=system) | |
| astroquery/ukidss/core.py:450: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.ukidss.core.UkidssClass object at 0x107cd19d0>, coordinates = <Galactic l=10.62500 deg, b=-0.38000 deg>, radius = <Quantity 6.0 arcsec> | |
| programme_id = 'GPS', database = 'UKIDSSDR7PLUS', get_query_payload = False, system = 'J2000' | |
| def query_region_async(self, coordinates, radius=1 * u.arcmin, | |
| programme_id='GPS', | |
| database='UKIDSSDR7PLUS', get_query_payload=False, | |
| system='J2000'): | |
| """ | |
| Serves the same purpose as `query_region`. But | |
| returns the raw HTTP response rather than the parsed result. | |
| Parameters | |
| ---------- | |
| coordinates : str or `astropy.coordinates` object | |
| The target around which to search. It may be specified as a | |
| string in which case it is resolved using online services or as | |
| the appropriate `astropy.coordinates` object. ICRS coordinates | |
| may also be entered as strings as specified in the | |
| `astropy.coordinates` module. | |
| radius : str or `~astropy.units.Quantity` object, optional | |
| The string must be parsable by `~astropy.coordinates.Angle`. The | |
| appropriate `~astropy.units.Quantity` object from | |
| `astropy.units` may also be used. When missing defaults to 1 | |
| arcmin. Cannot exceed 90 arcmin. | |
| programme_id : str | |
| The survey or programme in which to search for. See `list_catalogs`. | |
| database : str | |
| The UKIDSS database to use. | |
| get_query_payload : bool, optional | |
| If `True` then returns the dictionary sent as the HTTP request. | |
| Defaults to `False`. | |
| Returns | |
| ------- | |
| response : `requests.Response` | |
| The HTTP response returned from the service. | |
| """ | |
| request_payload = self._args_to_payload(coordinates, | |
| programme_id=programme_id, | |
| database=database, | |
| system=system, | |
| > query_type='catalog') | |
| astroquery/ukidss/core.py:496: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.ukidss.core.UkidssClass object at 0x107cd19d0>, args = (<Galactic l=10.62500 deg, b=-0.38000 deg>,) | |
| kwargs = {'database': 'UKIDSSDR7PLUS', 'programme_id': 'GPS', 'query_type': 'catalog', 'system': 'J2000'} | |
| request_payload = {'database': 'UKIDSSDR7PLUS', 'programmeID': 102, 'sys': 'J'}, programme_id = 'GPS', sys = 'J' | |
| def _args_to_payload(self, *args, **kwargs): | |
| request_payload = {} | |
| request_payload['database'] = kwargs['database'] if 'database' in kwargs else self.database | |
| programme_id = kwargs['programme_id'] if 'programme_id' in kwargs else self.programme_id | |
| request_payload['programmeID'] = verify_programme_id(programme_id, query_type=kwargs['query_type']) | |
| sys = self._parse_system(kwargs.get('system')) | |
| request_payload['sys'] = sys | |
| if sys == 'J': | |
| > request_payload['ra'] = commons.parse_coordinates(args[0]).icrs.ra.degree | |
| astroquery/ukidss/core.py:138: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <Galactic l=10.62500 deg, b=-0.38000 deg>, name = 'icrs' | |
| def __getattr__(self, name): | |
| """ | |
| Overrides getattr to return coordinates that this can be transformed | |
| to, based on the alias name in the master transform graph. | |
| """ | |
| from .transformations import master_transform_graph | |
| nmsys = master_transform_graph.lookup_name(name) | |
| if self.__class__ is nmsys: | |
| return self | |
| if nmsys is not None and self.is_transformable_to(nmsys): | |
| > return self.transform_to(nmsys) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:659: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <Galactic l=10.62500 deg, b=-0.38000 deg>, tosys = <class 'astropy.coordinates.builtin_systems.ICRS'> | |
| def transform_to(self, tosys): | |
| """ | |
| Transform this coordinate to a new system. | |
| Parameters | |
| ---------- | |
| tosys : class | |
| The system to transform this coordinate into. | |
| Returns | |
| ------- | |
| transcoord | |
| A new object with this coordinate represented in the | |
| ``tosys`` system. | |
| Raises | |
| ------ | |
| ValueError | |
| If there is no possible transformation route. | |
| """ | |
| from .transformations import master_transform_graph | |
| from .errors import ConvertError | |
| if tosys is self.__class__: | |
| return copy.deepcopy(self) | |
| trans = master_transform_graph.get_transform(self.__class__, tosys) | |
| if trans is None: | |
| raise ConvertError('Cannot transform from {0} to ' | |
| '{1}'.format(self.__class__, tosys)) | |
| > return trans(self) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:622: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.CompositeTransform object at 0x108388550>, fromcoord = <Galactic l=10.62500 deg, b=-0.38000 deg> | |
| super(CompositeTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| > coord = fromcoord | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:742: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astropy.coordinates.transformations.DynamicMatrixTransform object at 0x1067c5990>, fromcoord = <Galactic l=10.62500 deg, b=-0.38000 deg> | |
| super(DynamicMatrixTransform, self).__init__(fromsys, tosys, register) | |
| def __call__(self, fromcoord): | |
| c = fromcoord.cartesian | |
| v = c.reshape((3, c.size // 3)) | |
| v2 = np.dot(np.asarray(self.matrix_func(fromcoord)), v) | |
| subshape = c.shape[1:] | |
| x = v2[0].reshape(subshape) | |
| y = v2[1].reshape(subshape) | |
| z = v2[2].reshape(subshape) | |
| /Users/adam/repos/astropy/astropy/coordinates/transformations.py:708: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x1082f9d88>, args = () | |
| kwargs = {'unit': None, 'x': <CartesianPoints 0.042922274488051144>, 'y': <CartesianPoints -0.9391451292955936>, 'z': <CartesianPoints -0.34082855583582683>} | |
| def __init__(self, *args, **kwargs): | |
| super(FK5, self).__init__() | |
| self._equinox = kwargs.pop('equinox', _EQUINOX_J2000) | |
| self._obstime = kwargs.pop('obstime', None) | |
| if not isinstance(self._equinox, Time): | |
| raise TypeError('specified equinox is not a Time object') | |
| if self._obstime is not None and not isinstance(self._obstime, Time): | |
| raise TypeError('specified obstime is not None or a Time object') | |
| if not self._equinox.isscalar: | |
| raise ValueError('specified equinox is not a scalar') | |
| if len(args) == 1 and len(kwargs) == 0 and isinstance(args[0], SphericalCoordinatesBase): | |
| newcoord = args[0].transform_to(self.__class__) | |
| self._latangle = newcoord._latangle | |
| self._lonangle = newcoord._lonangle | |
| self._distance = newcoord._distance | |
| else: | |
| > super(FK5, self)._initialize_latlon('ra', 'dec', args, kwargs) | |
| /Users/adam/repos/astropy/astropy/coordinates/builtin_systems.py:140: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <[AttributeError("'FK5' object has no attribute 'isscalar', nor a transform.") raised in repr()] SafeRepr object at 0x109e70bd8>, lonname = 'ra' | |
| latname = 'dec', initargs = (), initkwargs = {} | |
| def _initialize_latlon(self, lonname, latname, initargs, initkwargs): | |
| """ | |
| Subclasses should use this to initialize standard lat/lon-style | |
| coordinates. | |
| This recognizes both the lat/lon style and the cartesian form. | |
| Parameters | |
| ---------- | |
| lonname : str | |
| The name of the longitude-like coordinate attribute | |
| latname : str | |
| The name of the latitude-like coordinate attribute | |
| initargs : list | |
| The ``*args`` from the initializer | |
| initkwargs : dict | |
| The ``**kwargs`` from the initializer | |
| """ | |
| initkwargs = dict(initkwargs) # copy | |
| nargs = len(initargs) | |
| sclsnm = self.__class__.__name__ | |
| if nargs == 1: | |
| if isinstance(initargs[0], CartesianPoints): | |
| initkwargs['cartpoint'] = initargs[0] | |
| else: | |
| initkwargs['coordstr'] = initargs[0] | |
| if nargs > 1: | |
| if lonname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, lonname)) | |
| initkwargs[lonname] = initargs[0] | |
| if nargs >= 2: | |
| if latname in initkwargs: | |
| raise TypeError("{0} got multiple values for keyword argument " | |
| "'{1}'".format(sclsnm, latname)) | |
| initkwargs[latname] = initargs[1] | |
| if nargs > 2: | |
| raise TypeError('{0} takes up to 2 positional arguments ' | |
| '({1} given)'.format(sclsnm, len(initargs))) | |
| unit = initkwargs.pop('unit', None) | |
| coordstr = initkwargs.pop('coordstr', None) | |
| lonval = initkwargs.pop(lonname, None) | |
| latval = initkwargs.pop(latname, None) | |
| distval = initkwargs.pop('distance', None) | |
| cartpoint = initkwargs.pop('cartpoint', None) | |
| x = initkwargs.pop('x', None) | |
| y = initkwargs.pop('y', None) | |
| z = initkwargs.pop('z', None) | |
| if len(initkwargs) > 0: | |
| raise TypeError('{0} got unexpected keyword argument' | |
| ' {1}'.format(sclsnm, initkwargs.keys())) | |
| angleinit = ((lonval is not None and latval is not None) or | |
| coordstr is not None) | |
| cartinit = ((x is not None and y is not None and z is not None) or | |
| cartpoint is not None) | |
| if angleinit and not cartinit: | |
| # lat/lon-style initialization | |
| for v in [x, y, z, cartpoint]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| try: | |
| # this raises a TypeError if `unit` is not None or iterable | |
| units = [None, None] if unit is None else list(unit) | |
| except TypeError: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a ' | |
| 'non-sequence {1}'.format(sclsnm, unit)) | |
| if len(units) == 2: | |
| try: | |
| if units[0] is not None: | |
| units[0] = u.Unit(units[0]) | |
| if units[1] is not None: | |
| units[1] = u.Unit(units[1]) | |
| except ValueError: | |
| raise ValueError('Could not convert units to unit objects ' | |
| 'while initializing ' + sclsnm) | |
| else: | |
| raise ValueError('Must give a sequence of 2 units or None ' | |
| 'while initializing {0}. Instead got a sequence ' | |
| 'of {1}.'.format(sclsnm, len(units))) | |
| if coordstr is not None: | |
| # need to try to parse the coordinate from a single argument | |
| # populates latval and lonval variables, which then get made | |
| # into coordinates below | |
| if isinstance(coordstr, six.string_types): | |
| if "," in coordstr: | |
| lonval, latval = coordstr.split(",") | |
| else: | |
| coosplit = coordstr.split() | |
| if len(coosplit) == 6: | |
| lonval = " ".join(coosplit[0:3]) | |
| latval = " ".join(coosplit[3:]) | |
| elif len(coosplit) == 2: | |
| lonval, latval = coosplit | |
| else: | |
| msg = ("Could not parse {lonname}/{latname} values " | |
| "from the string provided: '{coordstr}'.") | |
| raise ValueError(msg.format(lonname=lonname, | |
| latname=latname, | |
| coordstr=coordstr)) | |
| else: | |
| raise ValueError("A {0} cannot be created with a single value of type " | |
| "'{1}', must be a string.".format(sclsnm, type(coordstr).__name__)) | |
| # now actually create the angle objects | |
| lonang = Longitude(lonval, unit=units[0]) | |
| latang = Latitude(latval, unit=units[1]) | |
| dist = None if distval is None else Distance(distval) # copy | |
| elif cartinit and not angleinit: | |
| # cartesian-style initialization | |
| for v in [coordstr, lonval, latval, distval]: | |
| if v is not None: | |
| raise ValueError('Cannot give both angular and cartesian ' | |
| 'coordinates while initializing ' + sclsnm) | |
| if cartpoint is not None: | |
| for v in [x, y, z, unit]: | |
| if v is not None: | |
| raise ValueError('Cannot give both a CartesianPoints ' | |
| 'and x/y/z/unit parameters while ' | |
| 'initializing ' + sclsnm) | |
| x = cartpoint.x | |
| y = cartpoint.y | |
| z = cartpoint.z | |
| unit = cartpoint.unit | |
| > r, latval, lonval = cartesian_to_spherical(x, y, z) | |
| /Users/adam/repos/astropy/astropy/coordinates/coordsystems.py:235: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| x = <CartesianPoints 0.042922274488051144>, y = <CartesianPoints -0.9391451292955936>, z = <CartesianPoints -0.34082855583582683> | |
| x : scalar or array-like | |
| The first cartesian coordinate. | |
| y : scalar or array-like | |
| The second cartesian coordinate. | |
| z : scalar or array-like | |
| The third cartesian coordinate. | |
| Returns | |
| ------- | |
| r : float or array | |
| The radial coordinate (in the same units as the inputs). | |
| lat : float or array | |
| The latitude in radians | |
| lon : float or array | |
| The longitude in radians | |
| """ | |
| xsq = x ** 2 | |
| ysq = y ** 2 | |
| zsq = z ** 2 | |
| r = (xsq + ysq + zsq) ** 0.5 | |
| s = (xsq + ysq) ** 0.5 | |
| if np.isscalar(x) and np.isscalar(y) and np.isscalar(z): | |
| lon = math.atan2(y, x) | |
| lat = math.atan2(z, s) | |
| else: | |
| lon = np.arctan2(y, x) | |
| lat = np.arctan2(z, s) | |
| return r, lat, lon | |
| def spherical_to_cartesian(r, lat, lon): | |
| """ | |
| Converts spherical polar coordinates to rectangular cartesian | |
| coordinates. | |
| Note that the input angles should be in latitude/longitude or | |
| elevation/azimuthal form. I.e., the origin is along the equator | |
| rather than at the north pole. | |
| .. note:: | |
| This is a low-level function used internally in | |
| > `astropy.coordinates`. It is provided for users if they really | |
| want to use it, but it is recommended that you use the | |
| `astropy.coordinates` coordinate systems. | |
| Parameters | |
| ---------- | |
| r : scalar or array-like | |
| The radial coordinate (in the same units as the inputs). | |
| lat : scalar or array-like | |
| The latitude in radians | |
| lon : scalar or array-like | |
| The longitude in radians | |
| Returns | |
| ------- | |
| x : float or array | |
| The first cartesian coordinate. | |
| y : float or array | |
| The second cartesian coordinate. | |
| z : float or array | |
| The third cartesian coordinate. | |
| """ | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:441: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints -0.9391451292955936>, obj = array(2.315841784746324e+77) | |
| context = (<ufunc 'arctan2'>, (<CartesianPoints -0.9391451292955936>, <CartesianPoints 0.042922274488051144>), 0) | |
| raise TypeError("The value must be a valid Python or " | |
| "Numpy numeric type.") | |
| # by default, cast any integer, boolean, etc., to float | |
| if dtype is None and not np.can_cast(np.float32, value.dtype): | |
| value = value.astype(np.float) | |
| value = value.view(cls) | |
| value._unit = unit | |
| return value | |
| def __array_finalize__(self, obj): | |
| self._unit = getattr(obj, '_unit', None) | |
| def __array_prepare__(self, obj, context=None): | |
| # This method gets called by Numpy whenever a ufunc is called on the | |
| # array. The object passed in ``obj`` is an empty version of the | |
| # output array which we can e.g. change to an array sub-class, add | |
| # attributes to, etc. After this is called, then the ufunc is called | |
| # and the values in this empty array are set. | |
| # If no context is set, just return the input | |
| if context is None: | |
| return obj | |
| # Find out which ufunc is being used | |
| function = context[0] | |
| from .quantity_helper import UNSUPPORTED_UFUNCS, UFUNC_HELPERS | |
| # Check whether we even support this ufunc | |
| if function in UNSUPPORTED_UFUNCS: | |
| raise TypeError("Cannot use function '{0}' with quantities" | |
| .format(function.__name__)) | |
| # Now find out what arguments were passed to the ufunc, usually, this | |
| # will include at least the present object, and another, which could | |
| # be a Quantity, or a Numpy array, etc. when using two-argument ufuncs. | |
| args = context[1][:function.nin] | |
| units = [getattr(arg, 'unit', None) for arg in args] | |
| # If the ufunc is supported, then we call a helper function (defined | |
| # in quantity_helper.py) which returns the scale by which the inputs | |
| # should be multiplied before being passed to the ufunc, as well as | |
| # the unit the output from the ufunc will have. | |
| if function in UFUNC_HELPERS: | |
| scales, result_unit = UFUNC_HELPERS[function](function, *units) | |
| else: | |
| raise TypeError("Unknown ufunc {0}. Please raise issue on " | |
| "https://github.com/astropy/astropy" | |
| .format(function.__name__)) | |
| if any(scale == 0. for scale in scales): | |
| # for two-argument ufuncs with a quantity and a non-quantity, | |
| # the quantity normally needs to be dimensionless, *except* | |
| # if the non-quantity can have arbitrary unit, i.e., when it | |
| # is all zero, infinity or NaN. In that case, the non-quantity | |
| # can just have the unit of the quantity | |
| # (this allows, e.g., `q > 0.` independent of unit) | |
| maybe_arbitrary_arg = args[scales.index(0.)] | |
| if _can_have_arbitrary_unit(maybe_arbitrary_arg): | |
| scales = [1., 1.] | |
| else: | |
| raise UnitsError("Can only apply '{0}' function to " | |
| "dimensionless quantities when other " | |
| "argument is not a quantity (unless the " | |
| "latter is all zero/infinity/nan)" | |
| .format(function.__name__)) | |
| # In the case of np.power, the unit itself needs to be modified by an | |
| # amount that depends on one of the input values, so we need to treat | |
| # this as a special case. | |
| # TODO: find a better way to deal with this case | |
| if function is np.power and result_unit is not None: | |
| if units[1] is None: | |
| p = args[1] | |
| else: | |
| p = args[1].to(dimensionless_unscaled).value | |
| result_unit = result_unit ** validate_power(p) | |
| # We now prepare the output object | |
| if self is obj: # happens if the output object is self, which happens | |
| # for in-place operations such as q1 += q2 | |
| # In some cases, the result of a ufunc should be a plain Numpy | |
| # array, which we can't do if we are doing an in-place operation. | |
| if result_unit is None: | |
| raise TypeError("Cannot store non-quantity output from {0} " | |
| "function in Quantity object" | |
| .format(function.__name__)) | |
| /Users/adam/repos/astropy/astropy/units/quantity.py:311: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <CartesianPoints -0.9391451292955936>, obj = array(2.315841784746324e+77), unit = Unit("rad") | |
| #screw up the units are killed by _convert_to_and_validate_length_unit | |
| obj = super(CartesianPoints, self).__array_wrap__(obj, context=context) | |
| /Users/adam/repos/astropy/astropy/coordinates/distances.py:310: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = AssertionError(), args = (), f = <py._code.code.Frame object at 0x10a1792d0> | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| > ??? | |
| _pytest.assertion.reinterpret:40: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| frame = <py._code.code.Frame object at 0x10a1792d0>, should_fail = True | |
| > ??? | |
| _pytest.assertion.newinterpret:46: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| source = '.. note::\n This is a low-level function used internally in\n `astropy.coordinates`. It is provided for users ...e inputs).\nlat : float or array\n The latitude in radians\nlon : float or array\n The longitude in radians\n"""' | |
| filename = '<unknown>', mode = 'exec' | |
| def parse(source, filename='<unknown>', mode='exec'): | |
| """ | |
| Parse the source into an AST node. | |
| Equivalent to compile(source, filename, mode, PyCF_ONLY_AST). | |
| """ | |
| > return compile(source, filename, mode, PyCF_ONLY_AST) | |
| E File "<unknown>", line 1 | |
| E .. note:: | |
| E ^ | |
| E SyntaxError: invalid syntax | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py:37: SyntaxError | |
| _________________________________________________________________________ test_utils __________________________________________________________________________ | |
| @remote_data | |
| def test_utils(): | |
| > response = urllib.request.urlopen('http://www.ebay.com') | |
| astroquery/utils/tests/test_utils.py:38: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| url = 'http://www.ebay.com', data = None, timeout = <object object at 0x1002b3ac0> | |
| def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): | |
| global _opener | |
| if _opener is None: | |
| _opener = build_opener() | |
| > return _opener.open(url, data, timeout) | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py:127: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <urllib2.OpenerDirector instance at 0x107e288c0>, fullurl = 'http://www.ebay.com', data = None, timeout = <object object at 0x1002b3ac0> | |
| def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): | |
| # accept a URL or a Request object | |
| if isinstance(fullurl, basestring): | |
| req = Request(fullurl, data) | |
| else: | |
| req = fullurl | |
| if data is not None: | |
| req.add_data(data) | |
| req.timeout = timeout | |
| protocol = req.get_type() | |
| # pre-process request | |
| meth_name = protocol+"_request" | |
| for processor in self.process_request.get(protocol, []): | |
| meth = getattr(processor, meth_name) | |
| req = meth(req) | |
| response = self._open(req, data) | |
| # post-process response | |
| meth_name = protocol+"_response" | |
| for processor in self.process_response.get(protocol, []): | |
| meth = getattr(processor, meth_name) | |
| > response = meth(req, response) | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py:410: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <urllib2.HTTPErrorProcessor instance at 0x107e92710>, request = <urllib2.Request instance at 0x1082c4e60> | |
| response = <addinfourl at 4432087448 whose fp = <socket._fileobject object at 0x10825c450>> | |
| def http_response(self, request, response): | |
| code, msg, hdrs = response.code, response.msg, response.info() | |
| # According to RFC 2616, "2xx" code indicates that the client's | |
| # request was successfully received, understood, and accepted. | |
| if not (200 <= code < 300): | |
| response = self.parent.error( | |
| > 'http', request, response, code, msg, hdrs) | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py:523: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <urllib2.OpenerDirector instance at 0x107e288c0>, proto = 503 | |
| args = ({301: [<urllib2.HTTPRedirectHandler instance at 0x107e92680>], 302: [<urllib2.HTTPRedirectHandler instance at 0x107e9...t instance at 0x1082c4e60>, <addinfourl at 4432087448 whose fp = <socket._fileobject object at 0x10825c450>>, 503, ...) | |
| dict = {301: [<urllib2.HTTPRedirectHandler instance at 0x107e92680>], 302: [<urllib2.HTTPRedirectHandler instance at 0x107e92...llib2.HTTPRedirectHandler instance at 0x107e92680>], 307: [<urllib2.HTTPRedirectHandler instance at 0x107e92680>], ...} | |
| meth_name = 'http_error_503', http_err = 1 | |
| def error(self, proto, *args): | |
| if proto in ('http', 'https'): | |
| # XXX http[s] protocols are special-cased | |
| dict = self.handle_error['http'] # https is not different than http | |
| proto = args[2] # YUCK! | |
| meth_name = 'http_error_%s' % proto | |
| http_err = 1 | |
| orig_args = args | |
| else: | |
| dict = self.handle_error | |
| meth_name = proto + '_error' | |
| http_err = 0 | |
| args = (dict, proto, meth_name) + args | |
| result = self._call_chain(*args) | |
| if result: | |
| return result | |
| if http_err: | |
| args = (dict, 'default', 'http_error_default') + orig_args | |
| > return self._call_chain(*args) | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py:448: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <urllib2.OpenerDirector instance at 0x107e288c0> | |
| chain = {301: [<urllib2.HTTPRedirectHandler instance at 0x107e92680>], 302: [<urllib2.HTTPRedirectHandler instance at 0x107e92...llib2.HTTPRedirectHandler instance at 0x107e92680>], 307: [<urllib2.HTTPRedirectHandler instance at 0x107e92680>], ...} | |
| kind = 'default', meth_name = 'http_error_default' | |
| args = (<urllib2.Request instance at 0x1082c4e60>, <addinfourl at 4432087448 whose fp = <socket._fileobject object at 0x10825c450>>, 503, 'Service Unavailable', <httplib.HTTPMessage instance at 0x1082c4ef0>) | |
| handlers = [<urllib2.HTTPDefaultErrorHandler instance at 0x107e92440>], handler = <urllib2.HTTPDefaultErrorHandler instance at 0x107e92440> | |
| func = <bound method HTTPDefaultErrorHandler.http_error_default of <urllib2.HTTPDefaultErrorHandler instance at 0x107e92440>> | |
| def _call_chain(self, chain, kind, meth_name, *args): | |
| # Handlers raise an exception if no one else should try to handle | |
| # the request, or return None if they can't but another handler | |
| # could. Otherwise, they return the response. | |
| handlers = chain.get(kind, ()) | |
| for handler in handlers: | |
| func = getattr(handler, meth_name) | |
| > result = func(*args) | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py:382: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <urllib2.HTTPDefaultErrorHandler instance at 0x107e92440>, req = <urllib2.Request instance at 0x1082c4e60> | |
| fp = <addinfourl at 4432087448 whose fp = <socket._fileobject object at 0x10825c450>>, code = 503, msg = 'Service Unavailable' | |
| hdrs = <httplib.HTTPMessage instance at 0x1082c4ef0> | |
| def http_error_default(self, req, fp, code, msg, hdrs): | |
| > raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) | |
| E HTTPError: HTTP Error 503: Service Unavailable | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py:531: HTTPError | |
| ================================================ 16 failed, 424 passed, 2 xfailed, 2 xpassed in 433.10 seconds ================================================ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment