mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-05-19 06:17:03 -04:00
Python: Type Hints Integration - 3
This commit is contained in:
@@ -820,7 +820,7 @@ that expresses a relative position vector function.
|
||||
#### member functions
|
||||
|
||||
<a name="PositionFunction.Position"></a>
|
||||
### PositionFunction.Position(self, time)
|
||||
### PositionFunction.Position(self, time: astronomy.Time) -> astronomy.Vector
|
||||
|
||||
**Returns a relative position vector for a given time.**
|
||||
|
||||
@@ -1308,7 +1308,7 @@ and the specified body as seen from the center of the Earth.
|
||||
---
|
||||
|
||||
<a name="BackdatePosition"></a>
|
||||
### BackdatePosition(time, observerBody, targetBody, aberration)
|
||||
### BackdatePosition(time: astronomy.Time, observerBody: astronomy.Body, targetBody: astronomy.Body, aberration: bool) -> astronomy.Vector
|
||||
|
||||
**Solve for light travel time correction of apparent position.**
|
||||
|
||||
@@ -1340,7 +1340,7 @@ body to arrive at the observer at the observation time.
|
||||
---
|
||||
|
||||
<a name="BaryState"></a>
|
||||
### BaryState(body, time)
|
||||
### BaryState(body: astronomy.Body, time: astronomy.Time) -> astronomy.StateVector
|
||||
|
||||
**Calculates barycentric position and velocity vectors for the given body.**
|
||||
|
||||
@@ -1418,7 +1418,7 @@ the converted B1875 (ra,dec) for that point.
|
||||
---
|
||||
|
||||
<a name="CorrectLightTravel"></a>
|
||||
### CorrectLightTravel(func, time)
|
||||
### CorrectLightTravel(func: astronomy.PositionFunction, time: astronomy.Time) -> astronomy.Vector
|
||||
|
||||
**Solve for light travel time of a vector function.**
|
||||
|
||||
@@ -1588,7 +1588,7 @@ information about the given celestial body at the given time:
|
||||
---
|
||||
|
||||
<a name="Equator"></a>
|
||||
### Equator(body, time, observer, ofdate, aberration)
|
||||
### Equator(body: astronomy.Body, time: astronomy.Time, observer: astronomy.Observer, ofdate: bool, aberration: bool) -> astronomy.Equatorial
|
||||
|
||||
**Calculates equatorial coordinates of a celestial body as seen by an observer on the Earth's surface.**
|
||||
|
||||
@@ -1698,7 +1698,7 @@ The Moon's position and velocity vectors in J2000 equatorial coordinates (EQJ).
|
||||
---
|
||||
|
||||
<a name="GeoVector"></a>
|
||||
### GeoVector(body, time, aberration)
|
||||
### GeoVector(body: astronomy.Body, time: astronomy.Time, aberration: bool) -> astronomy.Vector
|
||||
|
||||
**Calculates geocentric Cartesian coordinates of a body in the J2000 equatorial system.**
|
||||
|
||||
@@ -1727,7 +1727,7 @@ A geocentric position vector of the center of the given body.
|
||||
---
|
||||
|
||||
<a name="HelioDistance"></a>
|
||||
### HelioDistance(body, time)
|
||||
### HelioDistance(body: astronomy.Body, time: astronomy.Time) -> float
|
||||
|
||||
**Calculates the distance between a body and the Sun at a given time.**
|
||||
|
||||
@@ -1748,7 +1748,7 @@ The heliocentric distance in AU.
|
||||
---
|
||||
|
||||
<a name="HelioState"></a>
|
||||
### HelioState(body, time)
|
||||
### HelioState(body: astronomy.Body, time: astronomy.Time) -> astronomy.StateVector
|
||||
|
||||
**Calculates heliocentric position and velocity vectors for the given body.**
|
||||
|
||||
@@ -1773,7 +1773,7 @@ An object that contains heliocentric position and velocity vectors.
|
||||
---
|
||||
|
||||
<a name="HelioVector"></a>
|
||||
### HelioVector(body, time)
|
||||
### HelioVector(body: astronomy.Body, time: astronomy.Time) -> astronomy.Vector
|
||||
|
||||
**Calculates heliocentric Cartesian coordinates of a body in the J2000 equatorial system.**
|
||||
|
||||
@@ -1975,7 +1975,7 @@ The inverse rotation matrix.
|
||||
---
|
||||
|
||||
<a name="JupiterMoons"></a>
|
||||
### JupiterMoons(time)
|
||||
### JupiterMoons(time: astronomy.Time) -> astronomy.JupiterMoonsInfo
|
||||
|
||||
**Calculates jovicentric positions and velocities of Jupiter's largest 4 moons.**
|
||||
|
||||
@@ -2293,7 +2293,7 @@ Keep calling this function as many times as you want to keep finding more transi
|
||||
---
|
||||
|
||||
<a name="ObserverGravity"></a>
|
||||
### ObserverGravity(latitude, height)
|
||||
### ObserverGravity(latitude: float, height: float) -> float
|
||||
|
||||
**Calculates the gravitational acceleration experienced by an observer on the Earth.**
|
||||
|
||||
@@ -2317,7 +2317,7 @@ The effective gravitational acceleration expressed in meters per second squared
|
||||
---
|
||||
|
||||
<a name="ObserverState"></a>
|
||||
### ObserverState(time, observer, ofdate)
|
||||
### ObserverState(time: astronomy.Time, observer: astronomy.Observer, ofdate: bool) -> astronomy.StateVector
|
||||
|
||||
**Calculates geocentric equatorial position and velocity of an observer on the surface of the Earth.**
|
||||
|
||||
@@ -2344,7 +2344,7 @@ An equatorial position vector and velocity vector relative to the center of the
|
||||
---
|
||||
|
||||
<a name="ObserverVector"></a>
|
||||
### ObserverVector(time, observer, ofdate)
|
||||
### ObserverVector(time: astronomy.Time, observer: astronomy.Observer, ofdate: bool) -> astronomy.Vector
|
||||
|
||||
**Calculates geocentric equatorial coordinates of an observer on the surface of the Earth.**
|
||||
|
||||
@@ -2873,7 +2873,7 @@ A rotation matrix that converts HOR to EQJ at `time` and for `observer`.
|
||||
---
|
||||
|
||||
<a name="Search"></a>
|
||||
### Search(func, context, t1, t2, dt_tolerance_seconds)
|
||||
### Search(func: Callable[[object, astronomy.Time], float], context: object, t1: astronomy.Time, t2: astronomy.Time, dt_tolerance_seconds: float) -> Optional[astronomy.Time]
|
||||
|
||||
**Searches for a time at which a function's value increases through zero.**
|
||||
|
||||
@@ -3501,7 +3501,7 @@ The vector form of the supplied spherical coordinates.
|
||||
---
|
||||
|
||||
<a name="VectorObserver"></a>
|
||||
### VectorObserver(vector, ofdate)
|
||||
### VectorObserver(vector: astronomy.Vector, ofdate: bool) -> astronomy.Observer
|
||||
|
||||
**Calculates the geographic location corresponding to an equatorial vector.**
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ import datetime
|
||||
import enum
|
||||
import re
|
||||
import abc
|
||||
from typing import List, Optional, Union
|
||||
from typing import List, Optional, Union, Callable
|
||||
|
||||
def _cbrt(x):
|
||||
if x < 0.0:
|
||||
@@ -3694,13 +3694,13 @@ class JupiterMoonsInfo:
|
||||
callisto : StateVector
|
||||
The position and velocity of Jupiter's moon Callisto.
|
||||
"""
|
||||
def __init__(self, moon):
|
||||
def __init__(self, moon: List[StateVector]) -> None:
|
||||
self.io = moon[0]
|
||||
self.europa = moon[1]
|
||||
self.ganymede = moon[2]
|
||||
self.callisto = moon[3]
|
||||
|
||||
def __repr__(self):
|
||||
def __repr__(self) -> str:
|
||||
return 'JupiterMoonsInfo(io={}, europa={}, ganymede={}, callisto={})'.format(
|
||||
repr(self.io),
|
||||
repr(self.europa),
|
||||
@@ -3786,7 +3786,7 @@ def _CalcJupiterMoon(time, mu, al0, al1, a, l, z, zeta):
|
||||
return RotateState(_Rotation_JUP_EQJ, state)
|
||||
|
||||
|
||||
def JupiterMoons(time):
|
||||
def JupiterMoons(time: Time) -> JupiterMoonsInfo:
|
||||
"""Calculates jovicentric positions and velocities of Jupiter's largest 4 moons.
|
||||
|
||||
Calculates position and velocity vectors for Jupiter's moons
|
||||
@@ -3856,7 +3856,7 @@ def _QuadInterp(tm, dt, fa, fm, fb):
|
||||
df_dt = (2*Q*x + R) / dt
|
||||
return (t, df_dt)
|
||||
|
||||
def Search(func, context, t1, t2, dt_tolerance_seconds):
|
||||
def Search(func: Callable[[object, Time], float], context: object, t1: Time, t2: Time, dt_tolerance_seconds: float) -> Optional[Time]:
|
||||
"""Searches for a time at which a function's value increases through zero.
|
||||
|
||||
Certain astronomy calculations involve finding a time when an event occurs.
|
||||
@@ -4004,7 +4004,7 @@ def Search(func, context, t1, t2, dt_tolerance_seconds):
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
def HelioVector(body, time):
|
||||
def HelioVector(body: Body, time: Time) -> Vector:
|
||||
"""Calculates heliocentric Cartesian coordinates of a body in the J2000 equatorial system.
|
||||
|
||||
This function calculates the position of the given celestial body as a vector,
|
||||
@@ -4063,7 +4063,7 @@ def HelioVector(body, time):
|
||||
raise InvalidBodyError(body)
|
||||
|
||||
|
||||
def HelioDistance(body, time):
|
||||
def HelioDistance(body: Body, time: Time) -> float:
|
||||
"""Calculates the distance between a body and the Sun at a given time.
|
||||
|
||||
Given a date and time, this function calculates the distance between
|
||||
@@ -4112,11 +4112,11 @@ class PositionFunction(abc.ABC):
|
||||
specified time. It is passed an instance of `PositionFunction`
|
||||
that expresses a relative position vector function.
|
||||
"""
|
||||
def __init__(self):
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def Position(self, time):
|
||||
def Position(self, time: Time) -> Vector:
|
||||
"""Returns a relative position vector for a given time.
|
||||
|
||||
Parameters
|
||||
@@ -4129,7 +4129,7 @@ class PositionFunction(abc.ABC):
|
||||
Vector
|
||||
"""
|
||||
|
||||
def CorrectLightTravel(func, time):
|
||||
def CorrectLightTravel(func: PositionFunction, time: Time) -> Vector:
|
||||
"""Solve for light travel time of a vector function.
|
||||
|
||||
When observing a distant object, for example Jupiter as seen from Earth,
|
||||
@@ -4180,14 +4180,14 @@ def CorrectLightTravel(func, time):
|
||||
|
||||
|
||||
class _BodyPosition(PositionFunction):
|
||||
def __init__(self, observerBody, targetBody, aberration, observerPos):
|
||||
def __init__(self, observerBody: Body, targetBody: Body, aberration: bool, observerPos) -> None:
|
||||
super().__init__()
|
||||
self.observerBody = observerBody
|
||||
self.targetBody = targetBody
|
||||
self.aberration = aberration
|
||||
self.observerPos = observerPos
|
||||
|
||||
def Position(self, time):
|
||||
def Position(self, time: Time) -> Vector:
|
||||
if self.aberration:
|
||||
# The following discussion is worded with the observer body being the Earth,
|
||||
# which is often the case. However, the same reasoning applies to any observer body
|
||||
@@ -4213,7 +4213,7 @@ class _BodyPosition(PositionFunction):
|
||||
return HelioVector(self.targetBody, time) - observerPos
|
||||
|
||||
|
||||
def BackdatePosition(time, observerBody, targetBody, aberration):
|
||||
def BackdatePosition(time: Time, observerBody: Body, targetBody: Body, aberration: bool) -> Vector:
|
||||
"""Solve for light travel time correction of apparent position.
|
||||
|
||||
When observing a distant object, for example Jupiter as seen from Earth,
|
||||
@@ -4281,7 +4281,7 @@ def BackdatePosition(time, observerBody, targetBody, aberration):
|
||||
return CorrectLightTravel(func, time)
|
||||
|
||||
|
||||
def GeoVector(body, time, aberration):
|
||||
def GeoVector(body: Body, time: Time, aberration: bool) -> Vector:
|
||||
"""Calculates geocentric Cartesian coordinates of a body in the J2000 equatorial system.
|
||||
|
||||
This function calculates the position of the given celestial body as a vector,
|
||||
@@ -4328,7 +4328,7 @@ def GeoVector(body, time, aberration):
|
||||
return vec
|
||||
|
||||
|
||||
def _ExportState(terse, time):
|
||||
def _ExportState(terse, time: Time) -> StateVector:
|
||||
return StateVector(
|
||||
terse.r.x, terse.r.y, terse.r.z,
|
||||
terse.v.x, terse.v.y, terse.v.z,
|
||||
@@ -4336,7 +4336,7 @@ def _ExportState(terse, time):
|
||||
)
|
||||
|
||||
|
||||
def BaryState(body, time):
|
||||
def BaryState(body: Body, time: Time) -> StateVector:
|
||||
"""Calculates barycentric position and velocity vectors for the given body.
|
||||
|
||||
Given a body and a time, calculates the barycentric position and velocity
|
||||
@@ -4414,7 +4414,7 @@ def BaryState(body, time):
|
||||
raise InvalidBodyError(body)
|
||||
|
||||
|
||||
def HelioState(body, time):
|
||||
def HelioState(body: Body, time: Time) -> StateVector:
|
||||
"""Calculates heliocentric position and velocity vectors for the given body.
|
||||
|
||||
Given a body and a time, calculates the position and velocity
|
||||
@@ -4488,7 +4488,7 @@ def HelioState(body, time):
|
||||
raise InvalidBodyError(body)
|
||||
|
||||
|
||||
def Equator(body, time, observer, ofdate, aberration):
|
||||
def Equator(body: Body, time: Time, observer: Observer, ofdate: bool, aberration: bool) -> Equatorial:
|
||||
"""Calculates equatorial coordinates of a celestial body as seen by an observer on the Earth's surface.
|
||||
|
||||
Calculates topocentric equatorial coordinates in one of two different systems:
|
||||
@@ -4541,7 +4541,7 @@ def Equator(body, time, observer, ofdate, aberration):
|
||||
return _vector2radec(datevect, time)
|
||||
|
||||
|
||||
def ObserverVector(time, observer, ofdate):
|
||||
def ObserverVector(time: Time, observer: Observer, ofdate: bool) -> Vector:
|
||||
"""Calculates geocentric equatorial coordinates of an observer on the surface of the Earth.
|
||||
|
||||
This function calculates a vector from the center of the Earth to
|
||||
@@ -4585,7 +4585,7 @@ def ObserverVector(time, observer, ofdate):
|
||||
ovec = _precession(ovec, time, _PrecessDir.Into2000)
|
||||
return Vector(ovec[0], ovec[1], ovec[2], time)
|
||||
|
||||
def ObserverState(time, observer, ofdate):
|
||||
def ObserverState(time: Time, observer: Observer, ofdate: bool) -> StateVector:
|
||||
"""Calculates geocentric equatorial position and velocity of an observer on the surface of the Earth.
|
||||
|
||||
This function calculates position and velocity vectors of an observer
|
||||
@@ -4632,7 +4632,7 @@ def ObserverState(time, observer, ofdate):
|
||||
state = _precession_posvel(state, time, _PrecessDir.Into2000)
|
||||
return state
|
||||
|
||||
def VectorObserver(vector, ofdate):
|
||||
def VectorObserver(vector: Vector, ofdate: bool) -> Observer:
|
||||
"""Calculates the geographic location corresponding to an equatorial vector.
|
||||
|
||||
This is the inverse function of #ObserverVector.
|
||||
@@ -4665,7 +4665,7 @@ def VectorObserver(vector, ofdate):
|
||||
ovec = _nutation(ovec, vector.t, _PrecessDir.From2000)
|
||||
return _inverse_terra(ovec, gast)
|
||||
|
||||
def ObserverGravity(latitude, height):
|
||||
def ObserverGravity(latitude: float, height: float) -> float:
|
||||
"""Calculates the gravitational acceleration experienced by an observer on the Earth.
|
||||
|
||||
This function implements the WGS 84 Ellipsoidal Gravity Formula.
|
||||
|
||||
Reference in New Issue
Block a user