Esempio n. 1
0
def test_frames(tmpdir):
    frames = [
        cf.CelestialFrame(reference_frame=coord.ICRS()),
        cf.CelestialFrame(reference_frame=coord.FK5(
            equinox=time.Time('2010-01-01'))),
        cf.CelestialFrame(reference_frame=coord.FK4(
            equinox=time.Time('2010-01-01'), obstime=time.Time('2015-01-01'))),
        cf.CelestialFrame(reference_frame=coord.FK4NoETerms(
            equinox=time.Time('2010-01-01'), obstime=time.Time('2015-01-01'))),
        cf.CelestialFrame(reference_frame=coord.Galactic()),
        cf.CelestialFrame(
            reference_frame=coord.Galactocentric(galcen_distance=5.0 * u.m,
                                                 galcen_ra=45 * u.deg,
                                                 galcen_dec=1 * u.rad,
                                                 z_sun=3 * u.pc,
                                                 roll=3 * u.deg)),
        cf.CelestialFrame(
            reference_frame=coord.GCRS(obstime=time.Time('2010-01-01'),
                                       obsgeoloc=[1, 3, 2000] * u.pc,
                                       obsgeovel=[2, 1, 8] * (u.m / u.s))),
        cf.CelestialFrame(reference_frame=coord.CIRS(
            obstime=time.Time('2010-01-01'))),
        cf.CelestialFrame(reference_frame=coord.ITRS(
            obstime=time.Time('2022-01-03'))),
        cf.CelestialFrame(reference_frame=coord.PrecessedGeocentric(
            obstime=time.Time('2010-01-01'),
            obsgeoloc=[1, 3, 2000] * u.pc,
            obsgeovel=[2, 1, 8] * (u.m / u.s)))
    ]

    tree = {'frames': frames}

    helpers.assert_roundtrip_tree(tree, tmpdir)
Esempio n. 2
0
def create_test_frames():
    """Creates an array of frames to be used for testing."""

    # Suppress warnings from astropy that are caused by having 'dubious' dates
    # that are too far in the future. It's not a concern for the purposes of
    # unit tests. See issue #5809 on the astropy GitHub for discussion.
    from astropy._erfa import ErfaWarning
    warnings.simplefilter("ignore", ErfaWarning)

    frames = [
        cf.CelestialFrame(reference_frame=coord.ICRS()),
        cf.CelestialFrame(reference_frame=coord.FK5(
            equinox=time.Time('2010-01-01'))),
        cf.CelestialFrame(reference_frame=coord.FK4(
            equinox=time.Time('2010-01-01'), obstime=time.Time('2015-01-01'))),
        cf.CelestialFrame(reference_frame=coord.FK4NoETerms(
            equinox=time.Time('2010-01-01'), obstime=time.Time('2015-01-01'))),
        cf.CelestialFrame(reference_frame=coord.Galactic()),
        cf.CelestialFrame(reference_frame=coord.Galactocentric(
            # A default galcen_coord is used since none is provided here
            galcen_distance=5.0 * u.m,
            z_sun=3 * u.pc,
            roll=3 * u.deg)),
        cf.CelestialFrame(
            reference_frame=coord.GCRS(obstime=time.Time('2010-01-01'),
                                       obsgeoloc=[1, 3, 2000] * u.pc,
                                       obsgeovel=[2, 1, 8] * (u.m / u.s))),
        cf.CelestialFrame(reference_frame=coord.CIRS(
            obstime=time.Time('2010-01-01'))),
        cf.CelestialFrame(reference_frame=coord.ITRS(
            obstime=time.Time('2022-01-03'))),
        cf.CelestialFrame(reference_frame=coord.PrecessedGeocentric(
            obstime=time.Time('2010-01-01'),
            obsgeoloc=[1, 3, 2000] * u.pc,
            obsgeovel=[2, 1, 8] * (u.m / u.s))),
        cf.StokesFrame(),
        cf.TemporalFrame(time.Time("2011-01-01"))
    ]

    return frames
Esempio n. 3
0
        *args, frame='icrs', **kwargs)
    GalacticCoordGenerator = lambda *args, **kwargs: coord.SkyCoord(
        *args, frame='galactic', **kwargs)
    FK5CoordGenerator = lambda *args, **kwargs: coord.SkyCoord(
        *args, frame='fk5', **kwargs)
    FK4CoordGenerator = lambda *args, **kwargs: coord.SkyCoord(
        *args, frame='fk4', **kwargs)
    ICRSCoord = coord.SkyCoord
    CoordClasses = (coord.SkyCoord, BaseCoordinateFrame)
except ImportError:
    from astropy.coordinates import SphericalCoordinatesBase as BaseCoordinateFrame
    ICRSCoordGenerator = lambda *args, **kwargs: coord.ICRS(*args, **kwargs)
    GalacticCoordGenerator = lambda *args, **kwargs: coord.Galactic(
        *args, **kwargs)
    FK5CoordGenerator = lambda *args, **kwargs: coord.FK5(*args, **kwargs)
    FK4CoordGenerator = lambda *args, **kwargs: coord.FK4(*args, **kwargs)
    ICRSCoord = coord.ICRS
    CoordClasses = (coord.SphericalCoordinatesBase, )

from ..exceptions import TimeoutError
from .. import version

__all__ = [
    'send_request', 'parse_coordinates', 'parse_radius', 'TableList',
    'suppress_vo_warnings', 'validate_email'
]


def send_request(url,
                 data,
                 timeout,
    def test___init__(self) -> None:
        """Test method ``__init__``.

        Copying from astropy docs

        """
        # -----------
        c = icoord.InterpolatedSkyCoord(
            [10] * self.num,
            [20] * self.num,
            unit="deg",
            affine=self.affine,
        )  # defaults to ICRS frame
        self._test_isc(c)

        # -----------
        c = icoord.InterpolatedSkyCoord(
            [1, 2, 3, 4],
            [-30, 45, 8, 16],
            frame="icrs",
            unit="deg",
            affine=self.affine[:4],
        )  # 4 coords
        self._test_isc(c)

        # -----------
        coords = [
            "1:12:43.2 +31:12:43",
            "1:12:43.2 +31:12:43",
            "1:12:43.2 +31:12:43",
            "1 12 43.2 +31 12 43",
        ]
        c = icoord.InterpolatedSkyCoord(
            coords,
            frame=coord.FK4,
            unit=(u.hourangle, u.deg),
            obstime="J1992.21",
            affine=self.affine[:4],
        )
        self._test_isc(c)

        # -----------
        c = icoord.InterpolatedSkyCoord(
            ["1h12m43.2s +1d12m43s"] * self.num,
            frame=coord.Galactic,
            affine=self.affine,
        )  # Units from string
        self._test_isc(c)

        # # -----------
        c = icoord.InterpolatedSkyCoord(
            frame="galactic",
            l=["1h12m43.2s"] * self.num,
            b="+1d12m43s",  # NOT BROADCASTING THIS ONE
            affine=self.affine,
        )
        self._test_isc(c)

        # -----------
        ra = coord.Longitude([1, 2, 3, 4], unit=u.deg)  # Could also use Angle
        dec = np.array([4.5, 5.2, 6.3, 7.4]) * u.deg  # Astropy Quantity
        c = icoord.InterpolatedSkyCoord(
            ra,
            dec,
            frame="icrs",
            affine=self.affine[:4],
        )
        self._test_isc(c)

        # -----------
        c = icoord.InterpolatedSkyCoord(
            frame=coord.ICRS,
            ra=ra,
            dec=dec,
            obstime="2001-01-02T12:34:56",
            affine=self.affine[:4],
        )
        self._test_isc(c)

        # -----------
        c = coord.FK4(
            [1] * self.num * u.deg,
            2 * u.deg,
        )  # Uses defaults for obstime, equinox
        c = icoord.InterpolatedSkyCoord(
            c,
            obstime="J2010.11",
            equinox="B1965",
            affine=self.affine,
        )  # Override defaults
        self._test_isc(c)

        # -----------
        c = icoord.InterpolatedSkyCoord(
            w=[0] * self.num,
            u=1,
            v=2,
            unit="kpc",
            frame="galactic",
            representation_type="cartesian",
            affine=self.affine,
        )
        self._test_isc(c, representation_type=coord.CartesianRepresentation)

        # -----------
        c = icoord.InterpolatedSkyCoord(
            [
                coord.ICRS(ra=1 * u.deg, dec=2 * u.deg),
                coord.ICRS(ra=3 * u.deg, dec=4 * u.deg),
            ] * (self.num // 2),
            affine=self.affine,
        )
        self._test_isc(c)
Esempio n. 5
0
from astropy.tests.helper import pytest
import astropy.coordinates as coord
import astropy.units as u
from astropy.table import Table
import sys
import os
import re
import requests
from ...exceptions import TableParseError
from distutils.version import LooseVersion
is_python3 = (sys.version_info >= (3, ))

GALACTIC_COORDS = coord.Galactic(l=-67.02084, b=-29.75447, unit=(u.deg, u.deg))
ICRS_COORDS = coord.ICRS("05h35m17.3s -05h23m28s")
FK4_COORDS = coord.FK4(ra=84.90759, dec=-80.89403, unit=(u.deg, u.deg))
FK5_COORDS = coord.FK5(ra=83.82207, dec=-80.86667, unit=(u.deg, u.deg))

DATA_FILES = {
    'id': 'query_id.data',
    'coo': 'query_coo.data',
    'cat': 'query_cat.data',
    'bibobj': 'query_bibobj.data',
    'bibcode': 'query_bibcode.data',
    'error': 'query_error.data',
    'sample': 'query_sample.data',
    'region': 'query_sample_region.data',
}


class MockResponseSimbad(MockResponse):