Skip to content

Commit 621e5d4

Browse files
committed
add a custom __repr__ method for inertial frame objects
1 parent d5184cf commit 621e5d4

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

skyfield/documentation/earth-satellites.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ for the satellite position, then use the frame to define an attitude vector:
532532

533533
.. testoutput::
534534

535-
Frame: <skyfield.framelib.LVLH object at 0x7fd11ab18790>
535+
Frame: <LVLH> Center (399) Pointing Local Vertical Local Horizontal reference frame.
536536
Attitude: [ 0.57745914 0.2781511 -0.76757599]
537537

538538
In this case we have set the pitch and roll to zero, so the attitude vector
@@ -541,12 +541,14 @@ anti-aligned with the position vector:
541541

542542
.. testcode::
543543

544+
from skyfield.functions import length_of
545+
544546
neg_position = -geocentric.position.au / length_of(geocentric.position.au)
545547
print(neg_position)
546548

547549
.. testoutput::
548550

549-
[0.57745914 0.2781511 -0.76757599]
551+
[ 0.57745914 0.2781511 -0.76757599]
550552

551553
Now, to find the intersection of this vector with the Earth’s surface we can
552554
use the :meth:`~skyfield.toposlib.Geoid.intersection_of()` method:

skyfield/framelib.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ def __init__(self, doc, matrix):
149149
self.__doc__ = doc
150150
self._matrix = matrix
151151

152+
def __repr__(self):
153+
return '<{0}> {1}'.format(self.__class__.__name__, self.__doc__)
154+
152155
def rotation_at(self, t):
153156
return self._matrix
154157

@@ -170,7 +173,7 @@ def __init__(self, position):
170173
matrix = mxmxm(matrix, rot_z(pi - i), rot_y(-u))
171174

172175
doc = (
173-
"Center {0} Pointing Local Vertical Local Horizontal"
176+
"Center ({0}) Pointing Local Vertical Local Horizontal"
174177
" reference frame."
175178
).format(position.center)
176179
super(LVLH, self).__init__(doc, matrix)

skyfield/toposlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def intersection_of(self, position, direction):
286286
of the Earth. The direction should be an |xyz| unit vector. Returns a
287287
`GeographicPosition` giving the geodetic ``latitude`` and ``longitude``
288288
at the point that the ray intersects the surface of the Earth.
289-
289+
290290
The main calculation implemented here is based on JPL's NAIF toolkit;
291291
https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/ellipses.html
292292
"""

0 commit comments

Comments
 (0)