-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: ensure typeshed compatible mypy types are exported
chore: ensure typeshed compatible mypy types are exported
- Loading branch information
1 parent
bd17a45
commit aed5cf3
Showing
23 changed files
with
256 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,17 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"python.formatting.provider": "none", | ||
"python.formatting.blackArgs": [ | ||
"--line-length=88" | ||
], | ||
"python.linting.enabled": true, | ||
"python.linting.flake8Enabled": false, | ||
"python.linting.pylintEnabled": false, | ||
"python.linting.flake8Args": [ | ||
"--max-line-length=88" | ||
], | ||
"python.linting.mypyEnabled": true, | ||
"isort.args": [ | ||
"--profile", | ||
"black" | ||
], | ||
"[python]": { | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": true | ||
}, | ||
"editor.formatOnPaste": false, | ||
"editor.defaultFormatter": "ms-python.black-formatter" | ||
"editor.defaultFormatter": "ms-python.black-formatter", | ||
"editor.formatOnSave": true, | ||
"editor.semanticHighlighting.enabled": true | ||
}, | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": "explicit" | ||
}, | ||
"yaml.schemas": { | ||
"https://json.schemastore.org/github-workflow.json": "file:///Users/michael/Developer/observerly/perseus/.github/workflows/deploy.yml" | ||
} | ||
} | ||
"editor.cursorBlinking": "smooth", | ||
"editor.cursorSmoothCaretAnimation": "on", | ||
"editor.cursorStyle": "line", | ||
"editor.formatOnSave": true, | ||
"editor.rulers": [88], | ||
"explorer.compactFolders": true, | ||
"explorer.confirmDelete": true, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,66 @@ | ||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
# @author Michael Roberts <[email protected]> | ||
# @package @observerly/celerity | ||
# @license Copyright © 2021-2023 observerly | ||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
"""Celerity is a lightweight, zero-dependency and type-safe Python library for astronomical calculations.""" | ||
""" | ||
Celerity is a lightweight, zero-dependency and type-safe | ||
Python library for astronomical calculations. | ||
""" | ||
|
||
__version__ = "0.1.0" | ||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
from .temporal import Time | ||
from celerity import ( | ||
aberration, | ||
astrometry, | ||
common, | ||
constants, | ||
coordinates, | ||
earth, | ||
equinox, | ||
humanize, | ||
moon, | ||
night, | ||
nutation, | ||
parallax, | ||
precession, | ||
refraction, | ||
seeing, | ||
solstice, | ||
sun, | ||
temporal, | ||
transit, | ||
utilities, | ||
) | ||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
__all__ = [ | ||
"aberration", | ||
"astrometry", | ||
"common", | ||
"constants", | ||
"coordinates", | ||
"earth", | ||
"equinox", | ||
"humanize", | ||
"moon", | ||
"night", | ||
"nutation", | ||
"parallax", | ||
"precession", | ||
"refraction", | ||
"seeing", | ||
"solstice", | ||
"sun", | ||
"temporal", | ||
"transit", | ||
"utilities", | ||
] | ||
|
||
# ************************************************************************************** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
# @author Michael Roberts <[email protected]> | ||
# @package @observerly/celerity | ||
# @license Copyright © 2021-2023 observerly | ||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
from datetime import datetime | ||
from math import cos, degrees, pow, radians, sin, tan | ||
from math import cos, pow, radians, sin, tan | ||
|
||
from .astrometry import get_obliquity_of_the_ecliptic | ||
from .common import EquatorialCoordinate | ||
|
@@ -20,7 +20,7 @@ | |
from .sun import get_true_geometric_longitude as get_solar_true_geometric_longitude | ||
from .temporal import get_julian_date | ||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
|
||
def get_correction_to_equatorial_for_aberration( | ||
|
@@ -40,7 +40,8 @@ def get_correction_to_equatorial_for_aberration( | |
# Get the Julian date: | ||
JD = get_julian_date(date) | ||
|
||
# Get the difference in fractional Julian centuries between the target date and J2000.0 | ||
# Get the difference in fractional Julian centuries between the target | ||
# date and J2000.0 | ||
T = (JD - 2451545.0) / 36525 | ||
|
||
# Get the ecliptic longitude of the ascending node of the mode (in degrees): | ||
|
@@ -90,3 +91,6 @@ def get_correction_to_equatorial_for_aberration( | |
) | ||
|
||
return {"ra": Δra, "dec": Δdec} | ||
|
||
|
||
# ************************************************************************************** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
# @author Michael Roberts <[email protected]> | ||
# @package @observerly/celerity | ||
# @license Copyright © 2021-2023 observerly | ||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
from datetime import datetime | ||
from math import acos, atan2, cos, degrees, pow, radians, sin, tan | ||
|
||
from .common import EquatorialCoordinate, GeographicCoordinate | ||
from .temporal import get_julian_date, get_local_sidereal_time | ||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
|
||
def get_angular_separation(A: EquatorialCoordinate, B: EquatorialCoordinate) -> float: | ||
""" | ||
The angular separation between two objects in the sky is the angle between the two objects | ||
as seen by an observer on Earth. | ||
The angular separation between two objects in the sky is the angle between | ||
the two objects as seen by an observer on Earth. | ||
:param A: The equatorial coordinate of the observed object. | ||
:param B: The equatorial coordinate of the observed object. | ||
|
@@ -44,15 +44,16 @@ def get_angular_separation(A: EquatorialCoordinate, B: EquatorialCoordinate) -> | |
return θ | ||
|
||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
|
||
def get_hour_angle(date: datetime, ra: float, longitude: float) -> float: | ||
""" | ||
Gets the hour angle for a particular object for a particular observer at a given datetime | ||
Gets the hour angle for a particular object for a particular observer | ||
at a given datetime | ||
:param date: The datetime object to convert. | ||
:param ra: The right ascension of the observed object's equatorial coordinate in degrees. | ||
:param ra: The right ascension of the observed object's equatorial coordinate. | ||
:param longitude: The longitude of the observer in degrees. | ||
:return The hour angle in degrees. | ||
""" | ||
|
@@ -67,15 +68,15 @@ def get_hour_angle(date: datetime, ra: float, longitude: float) -> float: | |
return ha | ||
|
||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
|
||
def get_obliquity_of_the_ecliptic(date: datetime) -> float: | ||
""" | ||
Gets the obliquity of the ecliptic for a particular datetime | ||
The obliquity of the ecliptic is the angle between the ecliptic and the celestial equator, and is used to | ||
convert between ecliptic and equatorial coordinates. | ||
The obliquity of the ecliptic is the angle between the ecliptic and the celestial | ||
equator, and is used to convert between ecliptic and equatorial coordinates. | ||
:param date: The datetime object to convert. | ||
:return The obliquity of the ecliptic in degrees. | ||
|
@@ -90,7 +91,7 @@ def get_obliquity_of_the_ecliptic(date: datetime) -> float: | |
return 23.439292 - (46.845 * T + 0.00059 * pow(T, 2) + 0.001813 * pow(T, 3)) / 3600 | ||
|
||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
|
||
def get_parallactic_angle( | ||
|
@@ -99,7 +100,8 @@ def get_parallactic_angle( | |
target: EquatorialCoordinate, | ||
) -> float: | ||
""" | ||
Gets the parallactic angle for a particular object for a particular observer at a given datetime | ||
Gets the parallactic angle for a particular object for a particular observer | ||
at a given datetime | ||
:param date: The datetime object to convert. | ||
:param observer: The geographic coordinate of the observer. | ||
|
@@ -122,4 +124,4 @@ def get_parallactic_angle( | |
) | ||
|
||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
# @author Michael Roberts <[email protected]> | ||
# @package @observerly/celerity | ||
# @license Copyright © 2021-2023 observerly | ||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
from math import cos, pow, radians | ||
from typing import Any, TypedDict | ||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
|
||
class Age(TypedDict): | ||
a: float | ||
A: float | ||
|
||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
|
||
class Angle(TypedDict): | ||
|
@@ -26,7 +26,7 @@ class Angle(TypedDict): | |
sec: float | ||
|
||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
|
||
class HourAngle(TypedDict): | ||
|
@@ -35,35 +35,35 @@ class HourAngle(TypedDict): | |
sec: float | ||
|
||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
|
||
class EquatorialCoordinate(TypedDict): | ||
ra: float | ||
dec: float | ||
|
||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
|
||
class GeographicCoordinate(TypedDict): | ||
lat: float | ||
lon: float | ||
|
||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
|
||
class HorizontalCoordinate(TypedDict): | ||
alt: float | ||
az: float | ||
|
||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
|
||
def is_equatorial_coordinate(coordinate: Any) -> EquatorialCoordinate | None: | ||
if type(coordinate) is not dict: | ||
if isinstance(coordinate, dict): | ||
return None | ||
|
||
return ( | ||
|
@@ -73,11 +73,11 @@ def is_equatorial_coordinate(coordinate: Any) -> EquatorialCoordinate | None: | |
) | ||
|
||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
|
||
def is_horizontal_coordinate(coordinate: Any) -> HorizontalCoordinate | None: | ||
if type(coordinate) is not dict: | ||
if isinstance(coordinate, dict): | ||
return None | ||
|
||
return ( | ||
|
@@ -87,11 +87,11 @@ def is_horizontal_coordinate(coordinate: Any) -> HorizontalCoordinate | None: | |
) | ||
|
||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
|
||
def get_F_orbital_parameter(ν: float, e: float) -> float: | ||
return (1 + (e * cos(radians(ν)))) / (1 - pow(e, 2)) | ||
|
||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
# @author Michael Roberts <[email protected]> | ||
# @package @observerly/celerity | ||
# @license Copyright © 2021-2023 observerly | ||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
""" | ||
The previous standard epoch "J1900" was defined by international | ||
|
@@ -15,7 +15,7 @@ | |
""" | ||
J1900: float = 2415020.0 | ||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
""" | ||
The standard epoch "J1970" is defined by international agreement to be | ||
|
@@ -31,7 +31,7 @@ | |
""" | ||
J1970: float = 2440587.5 | ||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** | ||
|
||
""" | ||
The currently-used standard epoch "J2000" is defined by international | ||
|
@@ -42,4 +42,4 @@ | |
""" | ||
J2000: float = 2451545.0 | ||
|
||
# ***************************************************************************************************************** | ||
# ************************************************************************************** |
Oops, something went wrong.