Skip to content

Commit

Permalink
Merge pull request astropy#10305 from pllim/update-coo-doc-np-1.12
Browse files Browse the repository at this point in the history
DOC: Un-skip coordinate example for doctest
  • Loading branch information
bsipocz authored May 5, 2020
2 parents 2511c48 + be819df commit 503217d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
8 changes: 3 additions & 5 deletions docs/coordinates/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
<SkyCoord (ICRS): (ra, dec) in deg
( 1., 2.)
(1., 2.)
(radial_velocity) in km / s
( 20.,)>

.. 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.
Expand Down
25 changes: 17 additions & 8 deletions docs/coordinates/velocities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
<SkyCoord (ICRS): (ra, dec) in deg
( 1., 2.)
(1., 2.)
(radial_velocity) in km / s
( 20.,)>
(20.,)>
>>> sc.radial_velocity # doctest: +FLOAT_CMP
<Quantity 20.0 km / s>

.. 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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 503217d

Please sign in to comment.