Python: Type Hints Integration - 6

This commit is contained in:
ris-tlp
2023-02-18 03:58:01 -05:00
parent e7f8f2b8e2
commit 43be952eb2
4 changed files with 72 additions and 72 deletions

View File

@@ -487,7 +487,7 @@ time steps.
#### member functions
<a name="GravitySimulator.__init__"></a>
### GravitySimulator.__init__(self, originBody, time, bodyStates)
### GravitySimulator.__init__(self, originBody: astronomy.Body, time: 'Time', bodyStates: List[astronomy.StateVector]) -&gt; None
**Creates a gravity simulation object.**
@@ -498,14 +498,14 @@ time steps.
| [`StateVector`](#StateVector)`[]` | `bodyStates` | An array of zero or more initial state vectors (positions and velocities) of the small bodies to be simulated. The caller must know the positions and velocities of the small bodies at an initial moment in time. Their positions and velocities are expressed with respect to `originBody`, using J2000 mean equator orientation (EQJ). Positions are expressed in astronomical units (AU). Velocities are expressed in AU/day. All the times embedded within the state vectors must exactly match `time`, or this constructor will throw an exception. |
<a name="GravitySimulator.OriginBody"></a>
### GravitySimulator.OriginBody(self)
### GravitySimulator.OriginBody(self) -&gt; astronomy.Body
**The origin of the reference frame. See constructor for more info.**
**Returns**: [`Body`](#Body)
<a name="GravitySimulator.SolarSystemBodyState"></a>
### GravitySimulator.SolarSystemBodyState(self, body)
### GravitySimulator.SolarSystemBodyState(self, body: astronomy.Body) -&gt; astronomy.StateVector
**Get the position and velocity of a Solar System body included in the simulation.**
@@ -526,7 +526,7 @@ of the `originBody` parameter that was passed to this object's constructor.
The state vector of the requested Solar System body.
<a name="GravitySimulator.Swap"></a>
### GravitySimulator.Swap(self)
### GravitySimulator.Swap(self) -&gt; None
**Exchange the current time step with the previous time step.**
@@ -556,7 +556,7 @@ that has not yet been updated by a call to [`GravitySimulator.Update`](#GravityS
**Returns**: [`Time`](#Time)
<a name="GravitySimulator.Update"></a>
### GravitySimulator.Update(self, time)
### GravitySimulator.Update(self, time) -&gt; List[astronomy.StateVector]
**Advances the gravity simulation by a small time step.**
@@ -2000,7 +2000,7 @@ The positions and velocities of Jupiter's 4 largest moons.
---
<a name="LagrangePoint"></a>
### LagrangePoint(point, time, major_body, minor_body)
### LagrangePoint(point: int, time: astronomy.Time, major_body: astronomy.Body, minor_body: astronomy.Body) -&gt; astronomy.StateVector
**Calculates one of the 5 Lagrange points for a pair of co-orbiting bodies.**
@@ -2039,7 +2039,7 @@ The position and velocity of the selected Lagrange point with respect to the maj
---
<a name="LagrangePointFast"></a>
### LagrangePointFast(point, major_state, major_mass, minor_state, minor_mass)
### LagrangePointFast(point: int, major_state: astronomy.StateVector, major_mass: float, minor_state: astronomy.StateVector, minor_mass: float) -&gt; astronomy.StateVector
**Calculates one of the 5 Lagrange points from body masses and state vectors.**
@@ -2077,7 +2077,7 @@ The position and velocity of the selected Lagrange point with respect to the maj
---
<a name="Libration"></a>
### Libration(time)
### Libration(time: astronomy.Time) -&gt; astronomy.LibrationInfo
**Calculates the Moon's libration angles at a given moment in time.**
@@ -2222,7 +2222,7 @@ See [`SearchLunarApsis`](#SearchLunarApsis) for more details.
---
<a name="NextMoonNode"></a>
### NextMoonNode(prevNode)
### NextMoonNode(prevNode: astronomy.NodeEventInfo) -&gt; astronomy.NodeEventInfo
**Searches for the next time when the Moon's center crosses through the ecliptic plane.**
@@ -2275,7 +2275,7 @@ See [`SearchPlanetApsis`](#SearchPlanetApsis) for more details.
---
<a name="NextTransit"></a>
### NextTransit(body, prevTransitTime)
### NextTransit(body: astronomy.Body, prevTransitTime: astronomy.Time) -&gt; astronomy.TransitInfo
**Searches for another transit of Mercury or Venus.**
@@ -2500,7 +2500,7 @@ A vector in the orientation specified by `rotation`.
---
<a name="RotationAxis"></a>
### RotationAxis(body, time)
### RotationAxis(body: astronomy.Body, time: astronomy.Time) -&gt; astronomy.AxisInfo
**Calculates information about a body's rotation axis at a given time.**
@@ -3119,7 +3119,7 @@ observed in the morning or evening. See [`ElongationEvent`](#ElongationEvent) fo
---
<a name="SearchMoonNode"></a>
### SearchMoonNode(startTime)
### SearchMoonNode(startTime: astronomy.Time) -&gt; astronomy.NodeEventInfo
**Searches for a time when the Moon's center crosses through the ecliptic plane.**

View File

@@ -1519,7 +1519,7 @@ def _CalcMoon(time):
I += 1
#
# AddSol(13.902000, 14.060000, -0.001000, 0.260700, 0.000000, 0.000000, 0.000000, 4.000000)
z = ex[4][4]
@@ -9274,7 +9274,7 @@ def SearchTransit(body: Body, startTime: Time) -> TransitInfo:
search_time = conj.AddDays(10.0)
def NextTransit(body, prevTransitTime):
def NextTransit(body: Body, prevTransitTime: Time) -> TransitInfo:
"""Searches for another transit of Mercury or Venus.
After calling #SearchTransit to find a transit of Mercury or Venus,
@@ -9323,11 +9323,11 @@ class NodeEventInfo:
time : Time
The time when the body passes through the ecliptic plane.
"""
def __init__(self, kind, time):
def __init__(self, kind: NodeEventKind, time: Time) -> None:
self.kind = kind
self.time = time
def __repr__(self):
def __repr__(self) -> str:
return 'NodeEventInfo({}, {})'.format(self.kind, repr(self.time))
_MoonNodeStepDays = +10.0 # a safe number of days to step without missing a Moon node
@@ -9335,7 +9335,7 @@ _MoonNodeStepDays = +10.0 # a safe number of days to step without missing a Mo
def _MoonNodeSearchFunc(direction, time):
return direction * EclipticGeoMoon(time).lat
def SearchMoonNode(startTime):
def SearchMoonNode(startTime: Time) -> NodeEventInfo:
"""Searches for a time when the Moon's center crosses through the ecliptic plane.
Searches for the first ascending or descending node of the Moon after `startTime`.
@@ -9375,7 +9375,7 @@ def SearchMoonNode(startTime):
eclip1 = eclip2
def NextMoonNode(prevNode):
def NextMoonNode(prevNode: NodeEventInfo) -> NodeEventInfo:
"""Searches for the next time when the Moon's center crosses through the ecliptic plane.
Call #SearchMoonNode to find the first of a series of nodes.
@@ -9424,7 +9424,7 @@ class LibrationInfo:
diam_deg : float
The apparent angular diameter of the Moon as seen from the center of the Earth.
"""
def __init__(self, elat, elon, mlat, mlon, dist_km, diam_deg):
def __init__(self, elat: float, elon: float, mlat: float, mlon: float, dist_km: float, diam_deg: float) -> None:
self.elat = elat
self.elon = elon
self.mlat = mlat
@@ -9432,7 +9432,7 @@ class LibrationInfo:
self.dist_km = dist_km
self.diam_deg = diam_deg
def __repr__(self):
def __repr__(self) -> str:
return 'LibrationInfo(elat={}, elon={}, mlat={}, mlon={}, dist_km={}, diam_deg={})'.format(
self.elat,
self.elon,
@@ -9443,7 +9443,7 @@ class LibrationInfo:
)
def Libration(time):
def Libration(time: Time) -> LibrationInfo:
"""Calculates the Moon's libration angles at a given moment in time.
Libration is an observed back-and-forth wobble of the portion of the
@@ -9603,13 +9603,13 @@ class AxisInfo:
north : Vector
A J2000 dimensionless unit vector pointing in the direction of the body's north pole.
"""
def __init__(self, ra, dec, spin, north):
def __init__(self, ra: float, dec: float, spin: float, north: Vector) -> None:
self.ra = ra
self.dec = dec
self.spin = spin
self.north = north
def __repr__(self):
def __repr__(self) -> str:
return 'AxisInfo(ra={}, dec={}, spin={}, north={})'.format(
self.ra,
self.dec,
@@ -9639,7 +9639,7 @@ def _EarthRotationAxis(time):
return AxisInfo(equ.ra, equ.dec, spin, north)
def RotationAxis(body, time):
def RotationAxis(body: Body, time: Time) -> AxisInfo:
"""Calculates information about a body's rotation axis at a given time.
Calculates the orientation of a body's rotation axis, along with
@@ -9840,7 +9840,7 @@ def RotationAxis(body, time):
return AxisInfo(ra/15.0, dec, w, north)
def LagrangePoint(point, time, major_body, minor_body):
def LagrangePoint(point: int, time: Time, major_body: Body, minor_body: Body) -> StateVector:
"""Calculates one of the 5 Lagrange points for a pair of co-orbiting bodies.
Given a more massive "major" body and a much less massive "minor" body,
@@ -9906,7 +9906,7 @@ def LagrangePoint(point, time, major_body, minor_body):
)
def LagrangePointFast(point, major_state, major_mass, minor_state, minor_mass):
def LagrangePointFast(point: int, major_state: StateVector, major_mass: float, minor_state: StateVector, minor_mass: float) -> StateVector:
"""Calculates one of the 5 Lagrange points from body masses and state vectors.
Given a more massive "major" body and a much less massive "minor" body,
@@ -10094,7 +10094,7 @@ class GravitySimulator:
time steps.
"""
def __init__(self, originBody, time, bodyStates):
def __init__(self, originBody: Body, time: "Time", bodyStates: List[StateVector]) -> None:
"""Creates a gravity simulation object.
Parameters
@@ -10133,7 +10133,7 @@ class GravitySimulator:
# Create a stub list of small body states that we will append to later.
# We just need the stub to put into `self.curr`
smallBodyList = []
smallBodyList: List = []
# Calculate the states of the Sun and planets at the initial time.
largeBodyDict = _CalcSolarSystem(time)
@@ -10164,7 +10164,7 @@ class GravitySimulator:
"""
return self.curr.time
def OriginBody(self):
def OriginBody(self) -> Body:
"""The origin of the reference frame. See constructor for more info.
Returns
@@ -10173,7 +10173,7 @@ class GravitySimulator:
"""
return self._originBody
def Update(self, time):
def Update(self, time) -> List[StateVector]:
"""Advances the gravity simulation by a small time step.
Updates the simulation of the user-supplied small bodies
@@ -10273,7 +10273,7 @@ class GravitySimulator:
return bodyStates
def Swap(self):
def Swap(self) -> None:
"""Exchange the current time step with the previous time step.
Sometimes it is helpful to "explore" various times near a given
@@ -10299,7 +10299,7 @@ class GravitySimulator:
"""
(self.curr, self.prev) = (self.prev, self.curr)
def SolarSystemBodyState(self, body):
def SolarSystemBodyState(self, body: Body) -> StateVector:
"""Get the position and velocity of a Solar System body included in the simulation.
In order to simulate the movement of small bodies through the Solar System,