From be819df3719f7319e527430de6a4669f0b9952a4 Mon Sep 17 00:00:00 2001 From: Pey Lian Lim <2090236+pllim@users.noreply.github.com> Date: Mon, 4 May 2020 20:31:44 -0400 Subject: [PATCH] DOC: Unskip coordinate example --- docs/coordinates/index.rst | 8 +++----- docs/coordinates/velocities.rst | 25 +++++++++++++++++-------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/docs/coordinates/index.rst b/docs/coordinates/index.rst index cdd90c6fa0ce..8127b3f5f325 100644 --- a/docs/coordinates/index.rst +++ b/docs/coordinates/index.rst @@ -381,13 +381,11 @@ and transforming velocities. These are available both via the lower-level objects:: >>> sc = SkyCoord(1*u.deg, 2*u.deg, radial_velocity=20*u.km/u.s) - >>> sc # doctest: +SKIP + >>> sc # doctest: +FLOAT_CMP - -.. the SKIP above in the ``sc`` line is because NumPy has a subtly different output in versions < 12 - the trailing comma is missing. If a NPY_LT_1_12 comes in to being this can switch to that. But don't forget to *also* change this in the velocities.rst file. + (20.,)> For more details on velocity support (and limitations), see the :doc:`velocities` page. diff --git a/docs/coordinates/velocities.rst b/docs/coordinates/velocities.rst index be064eeb5e09..9139a5aac3ad 100644 --- a/docs/coordinates/velocities.rst +++ b/docs/coordinates/velocities.rst @@ -24,16 +24,14 @@ proper motion and distance could be created as:: >>> from astropy.coordinates import SkyCoord >>> import astropy.units as u >>> sc = SkyCoord(1*u.deg, 2*u.deg, radial_velocity=20*u.km/u.s) - >>> sc # doctest: +SKIP + >>> sc # doctest: +FLOAT_CMP + (20.,)> >>> sc.radial_velocity # doctest: +FLOAT_CMP -.. the SKIP above in the ``sc`` line is because numpy has a subtly different output in versions < 12 - the trailing comma is missing. If a NPY_LT_1_12 comes in to being this can switch to that. But don't forget to *also* change this in the coordinates/index.rst file - |skycoord| objects created in this manner follow all of the same transformation rules and will correctly update their velocities when transformed to other frames. For example, to determine proper motions in Galactic coordinates for @@ -449,14 +447,25 @@ precision is not sufficient to compute differences of order km over distances of order kiloparsecs. Hence, the straightforward finite difference method will not work for this use case with the default values. +.. testsetup:: + + >>> import numpy as np + >>> from astropy.coordinates import EarthLocation, AltAz, GCRS + >>> from astropy.time import Time + >>> time = Time('J2010') + np.linspace(-1,1,1000) * u.min + >>> location = EarthLocation(lon=0*u.deg, lat=45*u.deg) + >>> aa = AltAz(alt=[45]*1000*u.deg, az=90*u.deg, distance=100*u.kpc, + ... radial_velocity=[10]*1000*u.km/u.s, + ... location=location, obstime=time) + It is possible to override the timestep over which the finite difference occurs. For example:: >>> from astropy.coordinates import frame_transform_graph, AltAz, CIRS >>> trans = frame_transform_graph.get_transform(AltAz, CIRS).transforms[0] - >>> trans.finite_difference_dt = 1*u.year - >>> gcrs = aa.transform_to(GCRS(obstime=time)) # doctest: +SKIP - >>> trans.finite_difference_dt = 1*u.second # return to default + >>> trans.finite_difference_dt = 1 * u.year + >>> gcrs = aa.transform_to(GCRS(obstime=time)) # doctest: +REMOTE_DATA + >>> trans.finite_difference_dt = 1 * u.second # return to default But beware that this will *not* help in cases like the above, where the relevant timescales for the velocities are seconds. (The velocity of the Earth relative