Skip to content

Commit

Permalink
Fix broken doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
lpsinger committed Apr 17, 2021
1 parent e4af7ee commit 0fbbf36
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 53 deletions.
38 changes: 20 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,31 +161,33 @@ The following example illustrates how to use HEALPix to determine if a given
sky position is contained in any of the fields in an observing plan:

```pycon
>>> from astropy.coordinates import SkyCoord
>>> from astropy.coordinates import ICRS, SkyCoord
>>> from astropy.table import QTable
>>> from astropy_healpix import HEALPix
>>> from astropy import units as u
>>> from dorado.scheduling import skygrid
>>> from dorado.scheduling import FOV
>>> healpix = HEALPix(nside=32, frame=ICRS())
>>> target = SkyCoord(66.91436579*u.deg, -61.98378895*u.deg)
>>> target_pixel = skygrid.healpix.skycoord_to_healpix(target)
>>> target_pixel = healpix.skycoord_to_healpix(target)
>>> schedule = QTable.read('examples/6.ecsv')
>>> footprints = [skygrid.get_footprint_healpix(row['center'], row['roll'])
>>> fov = FOV.from_rectangle(7.1 * u.deg)
>>> footprints = [fov.footprint_healpix(healpix, row['center'], row['roll'])
... for row in schedule]
>>> schedule['found'] = [target_pixel in footprint for footprint in footprints]
>>> schedule
<QTable length=9>
time center roll found
deg,deg deg
object object float64 bool
----------------------- ------------------------------------- ------- -----
2012-05-02T18:28:32.699 65.25,-60.434438844952275 0.0 True
2012-05-02T18:40:32.699 51.74999999999999,-60.434438844952275 0.0 False
2012-05-02T18:51:32.699 79.28571428571429,-58.91977535280316 80.0 False
2012-05-02T19:01:32.699 91.95652173913044,-55.87335043525197 60.0 False
2012-05-02T19:11:32.699 106.07142857142857,-69.42254649458224 20.0 False
2012-05-02T19:22:32.699 146.25,-13.24801490567695 20.0 False
2012-05-02T19:33:32.699 146.25,-5.979156796301311 20.0 False
2012-05-02T19:44:32.699 115.31249999999999,18.20995686428301 20.0 False
2012-05-02T19:56:32.699 133.59375,7.180755781458282 20.0 False
<QTable length=8>
time exptime ... roll found
min ... deg
object float64 ... float64 bool
----------------------- ------- ... ------- -----
2012-05-02T18:28:32.699 10.0 ... 60.0 False
2012-05-02T18:38:32.699 10.0 ... 40.0 False
2012-05-02T18:48:32.699 10.0 ... 80.0 False
2012-05-02T18:58:32.699 10.0 ... 50.0 True
2012-05-02T19:23:32.699 10.0 ... 80.0 False
2012-05-02T19:33:32.699 10.0 ... 20.0 False
2012-05-02T19:43:32.699 10.0 ... 20.0 False
2012-05-02T19:57:32.699 10.0 ... 0.0 False
```

[Pip]: https://pip.pypa.io
Expand Down
34 changes: 20 additions & 14 deletions doc/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,33 @@ Determining if a given sky position is contained within an observing plan
The following example illustrates how to use HEALPix to determine if a given
sky position is contained in any of the fields in an observing plan::

>>> from astropy.coordinates import SkyCoord
>>> from astropy.coordinates import ICRS, SkyCoord
>>> from astropy.table import QTable
>>> from astropy_healpix import HEALPix
>>> from astropy import units as u
>>> from dorado.scheduling import skygrid
>>> from dorado.scheduling import FOV
>>> healpix = HEALPix(nside=32, frame=ICRS())
>>> target = SkyCoord(66.91436579*u.deg, -61.98378895*u.deg)
>>> target_pixel = skygrid.healpix.skycoord_to_healpix(target)
>>> target_pixel = healpix.skycoord_to_healpix(target)
>>> schedule = QTable.read('examples/6.ecsv')
>>> footprints = [skygrid.get_footprint_healpix(row['center'], row['roll'])
>>> fov = FOV.from_rectangle(7.1 * u.deg)
>>> footprints = [fov.footprint_healpix(healpix, row['center'], row['roll'])
... for row in schedule]
>>> schedule['found'] = [target_pixel in footprint for footprint in footprints]
>>> schedule
<QTable length=5>
time center roll found
deg,deg deg
object object float64 bool
----------------------- ------------------------------------ ------- -----
2012-05-02T18:29:32.699 54.47368421052631,-61.94383702315671 80.0 False
2012-05-02T18:44:32.699 69.75,-60.434438844952275 50.0 True
2012-05-02T19:32:32.699 147.65625,-7.180755781458282 70.0 False
2012-05-02T19:42:32.699 115.31249999999999,18.20995686428301 20.0 False
2012-05-02T19:56:32.699 133.59375,7.180755781458282 20.0 False
<QTable length=8>
time exptime ... roll found
min ... deg
object float64 ... float64 bool
----------------------- ------- ... ------- -----
2012-05-02T18:28:32.699 10.0 ... 60.0 False
2012-05-02T18:38:32.699 10.0 ... 40.0 False
2012-05-02T18:48:32.699 10.0 ... 80.0 False
2012-05-02T18:58:32.699 10.0 ... 50.0 True
2012-05-02T19:23:32.699 10.0 ... 80.0 False
2012-05-02T19:33:32.699 10.0 ... 20.0 False
2012-05-02T19:43:32.699 10.0 ... 20.0 False
2012-05-02T19:57:32.699 10.0 ... 0.0 False

.. _`Pip`: https://pip.pypa.io
.. _`mixed integer programming`: https://en.wikipedia.org/wiki/Integer_programming
Expand Down
18 changes: 10 additions & 8 deletions dorado/scheduling/fov.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,16 @@ def footprint(self, center=SkyCoord(0*u.deg, 0*u.deg), roll=0*u.deg):
Get the footprint for a spcific pointing:
>>> fov.footprint(SkyCoord(0*u.deg, 20*u.deg, roll=15*u.deg)).icrs
>>> fov.footprint(SkyCoord(0*u.deg, 20*u.deg), 15*u.deg).icrs
<SkyCoord (ICRS): (ra, dec) in deg
[( 31.40720463, 42.69257989), ( 22.68313548, -6.6727307 ),
(337.31686452, -6.6727307 ), (328.59279537, 42.69257989)]>
[( 35.73851095, 34.84634609), ( 15.41057822, -11.29269295),
(331.35544934, -0.54495686), (336.46564791, 49.26075815)]>
Get a footprint as HEALPix coordinates.
>>> hpx = HEALPix(nside=4, frame=ICRS())
>>> fov.footprint_healpix(hpx, SkyCoord(0*u.deg, 20*u.deg), 15*u.deg)
array([ 24, 39, 40, 41, 55, 56, 71, 72, 73, 87, 88, 103])
Get the footprint for a grid of pointings:
Expand All @@ -100,11 +106,7 @@ def footprint(self, center=SkyCoord(0*u.deg, 0*u.deg), roll=0*u.deg):
>>> footprints.shape
(8, 5, 6, 4)
Get the footprints as HEALPix coordinates.
>>> hpx = HEALPix(nside=32, frame=ICRS())
>>> fov.footprint_healpix(hpx, center[..., np.newaxis], roll)
"""
""" # noqa: E501
frame = center.skyoffset_frame(roll)[..., np.newaxis]
representation = self._representation

Expand Down
18 changes: 5 additions & 13 deletions dorado/scheduling/orbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,36 +33,28 @@ class Orbit:
>>> from astropy import units as u
>>> from dorado.scheduling import Orbit
>>> from astropy.utils.data import get_pkg_data_filename
>>> with resources.path('dorado.scheduling.data', 'orbits.txt') as path:
>>> with resources.path('dorado.scheduling.data',
... 'dorado-625km-sunsync.tle') as path:
... orbit = Orbit(path)
Get the orbital period:
>>> orbit.period
<Quantity 98.82566607 min>
<Quantity 97.20725153 min>
Evaluate the position and velocity of the satellite at one specific time:
>>> time = Time('2021-04-16 15:27')
>>> orbit(time)
<SkyCoord (ITRS: obstime=2021-04-16 15:27:00.000): (x, y, z) in km
(4976.75920356, -3275.77173105, 3822.71352292)
(3902.59776726, -5209.69991116, 2582.69921222)
(v_x, v_y, v_z) in km / s
(-4.28131812, 0.77514995, 6.2200722)>
(-2.9282713, 1.25697383, 6.93396922)>
Or evaluate at an array of times:
>>> times = time + np.linspace(0 * u.min, 2 * u.min, 3)
>>> orbit(times)
<SkyCoord (ITRS: obstime=['2021-04-16 15:27:00.000' '2021-04-16 15:28:00.000'
'2021-04-16 15:29:00.000']): (x, y, z) in km
[(4976.75920356, -3275.77173105, 3822.71352292),
(4710.26989911, -3221.55488875, 4187.9218208 ),
(4425.37931006, -3151.96969293, 4536.16324051)]
(v_x, v_y, v_z) in km / s
[(-4.28131812, 0.77514995, 6.2200722 ),
(-4.59829403, 1.0319373 , 5.94941852),
(-4.89448943, 1.28722498, 5.65470357)]>
""" # noqa: E501

Expand Down

0 comments on commit 0fbbf36

Please sign in to comment.