diff --git a/.vscode/settings.json b/.vscode/settings.json index 6d5d228..b664964 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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" - } -} \ No newline at end of file + "editor.cursorBlinking": "smooth", + "editor.cursorSmoothCaretAnimation": "on", + "editor.cursorStyle": "line", + "editor.formatOnSave": true, + "editor.rulers": [88], + "explorer.compactFolders": true, + "explorer.confirmDelete": true, +} diff --git a/src/celerity/__init__.py b/src/celerity/__init__.py index 7792b6b..fc126f6 100644 --- a/src/celerity/__init__.py +++ b/src/celerity/__init__.py @@ -1,17 +1,66 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @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", +] + +# ************************************************************************************** diff --git a/src/celerity/aberration.py b/src/celerity/aberration.py index 2ed5d46..d52ae9d 100644 --- a/src/celerity/aberration.py +++ b/src/celerity/aberration.py @@ -1,13 +1,13 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @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} + + +# ************************************************************************************** diff --git a/src/celerity/astrometry.py b/src/celerity/astrometry.py index 61a66f3..943ca96 100644 --- a/src/celerity/astrometry.py +++ b/src/celerity/astrometry.py @@ -1,10 +1,10 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @package @observerly/celerity # @license Copyright © 2021-2023 observerly -# ***************************************************************************************************************** +# ************************************************************************************** from datetime import datetime from math import acos, atan2, cos, degrees, pow, radians, sin, tan @@ -12,13 +12,13 @@ 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( ) -# ***************************************************************************************************************** +# ************************************************************************************** diff --git a/src/celerity/common.py b/src/celerity/common.py index 02fd045..ab0d97f 100644 --- a/src/celerity/common.py +++ b/src/celerity/common.py @@ -1,15 +1,15 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @package @observerly/celerity # @license Copyright © 2021-2023 observerly -# ***************************************************************************************************************** +# ************************************************************************************** from math import cos, pow, radians from typing import Any, TypedDict -# ***************************************************************************************************************** +# ************************************************************************************** class Age(TypedDict): @@ -17,7 +17,7 @@ class Age(TypedDict): A: float -# ***************************************************************************************************************** +# ************************************************************************************** class Angle(TypedDict): @@ -26,7 +26,7 @@ class Angle(TypedDict): sec: float -# ***************************************************************************************************************** +# ************************************************************************************** class HourAngle(TypedDict): @@ -35,7 +35,7 @@ class HourAngle(TypedDict): sec: float -# ***************************************************************************************************************** +# ************************************************************************************** class EquatorialCoordinate(TypedDict): @@ -43,7 +43,7 @@ class EquatorialCoordinate(TypedDict): dec: float -# ***************************************************************************************************************** +# ************************************************************************************** class GeographicCoordinate(TypedDict): @@ -51,7 +51,7 @@ class GeographicCoordinate(TypedDict): lon: float -# ***************************************************************************************************************** +# ************************************************************************************** class HorizontalCoordinate(TypedDict): @@ -59,11 +59,11 @@ class HorizontalCoordinate(TypedDict): 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)) -# ***************************************************************************************************************** +# ************************************************************************************** diff --git a/src/celerity/constants.py b/src/celerity/constants.py index ecc1644..2676184 100644 --- a/src/celerity/constants.py +++ b/src/celerity/constants.py @@ -1,10 +1,10 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @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 -# ***************************************************************************************************************** +# ************************************************************************************** diff --git a/src/celerity/coordinates.py b/src/celerity/coordinates.py index fd15f7f..016ac46 100644 --- a/src/celerity/coordinates.py +++ b/src/celerity/coordinates.py @@ -1,10 +1,10 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @package @observerly/celerity # @license Copyright © 2021-2023 observerly -# ***************************************************************************************************************** +# ************************************************************************************** from datetime import datetime from math import acos, asin, cos, degrees, radians, sin @@ -15,7 +15,7 @@ from .nutation import get_correction_to_equatorial_for_nutation from .precession import get_correction_to_equatorial_for_precession_of_equinoxes -# ***************************************************************************************************************** +# ************************************************************************************** def get_correction_to_equatorial( @@ -58,7 +58,7 @@ def get_correction_to_equatorial( return target -# ***************************************************************************************************************** +# ************************************************************************************** def convert_equatorial_to_horizontal( @@ -97,4 +97,4 @@ def convert_equatorial_to_horizontal( } -# ***************************************************************************************************************** +# ************************************************************************************** diff --git a/src/celerity/earth.py b/src/celerity/earth.py index 9f9c852..ccfecd7 100644 --- a/src/celerity/earth.py +++ b/src/celerity/earth.py @@ -1,17 +1,17 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @package @observerly/celerity # @license Copyright © 2021-2023 observerly -# ***************************************************************************************************************** +# ************************************************************************************** from datetime import datetime from math import pow from .temporal import get_julian_date -# ***************************************************************************************************************** +# ************************************************************************************** def get_eccentricity_of_orbit(date: datetime) -> float: @@ -31,4 +31,4 @@ def get_eccentricity_of_orbit(date: datetime) -> float: return 0.0167086342 - 0.000042037 * T - 0.0000001267 * pow(T, 2) % 360 -# ***************************************************************************************************************** +# ************************************************************************************** diff --git a/src/celerity/epoch.py b/src/celerity/epoch.py index 9035800..38d9157 100644 --- a/src/celerity/epoch.py +++ b/src/celerity/epoch.py @@ -1,16 +1,16 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @package @observerly/celerity # @license Copyright © 2021-2023 observerly -# ***************************************************************************************************************** +# ************************************************************************************** from datetime import datetime from .temporal import get_julian_date -# ***************************************************************************************************************** +# ************************************************************************************** def get_number_of_fractional_days_since_j2000(date: datetime) -> float: @@ -24,4 +24,4 @@ def get_number_of_fractional_days_since_j2000(date: datetime) -> float: return get_julian_date(date) - 2451545.0 -# ***************************************************************************************************************** +# ************************************************************************************** diff --git a/src/celerity/equinox.py b/src/celerity/equinox.py index 0026989..e41e3dc 100644 --- a/src/celerity/equinox.py +++ b/src/celerity/equinox.py @@ -1,14 +1,14 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @package @observerly/celerity # @license Copyright © 2021-2023 observerly -# ***************************************************************************************************************** +# ************************************************************************************** from datetime import datetime, timezone -# ***************************************************************************************************************** +# ************************************************************************************** def get_spring_equinox(year: int) -> datetime: @@ -31,7 +31,7 @@ def get_spring_equinox(year: int) -> datetime: ) -# ***************************************************************************************************************** +# ************************************************************************************** def get_autumn_equinox(year: int) -> datetime: @@ -54,4 +54,4 @@ def get_autumn_equinox(year: int) -> datetime: ) -# ***************************************************************************************************************** +# ************************************************************************************** diff --git a/src/celerity/humanize.py b/src/celerity/humanize.py index a405e9f..b92cd0c 100644 --- a/src/celerity/humanize.py +++ b/src/celerity/humanize.py @@ -1,17 +1,17 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @package @observerly/celerity # @license Copyright © 2021-2023 observerly -# ***************************************************************************************************************** +# ************************************************************************************** from math import floor from .common import Angle from .utilities import convert_degree_to_dms, convert_degree_to_hms -# ***************************************************************************************************************** +# ************************************************************************************** def format_degree_as_dms(degree: float) -> str: @@ -25,7 +25,7 @@ def format_degree_as_dms(degree: float) -> str: return f"{dms['deg']:+03d}° {dms['min']:02d}' {dms['sec']:05.2f}\"" -# ***************************************************************************************************************** +# ************************************************************************************** def format_degree_as_hms(degree: float) -> str: @@ -39,4 +39,4 @@ def format_degree_as_hms(degree: float) -> str: return f"{hms['hour']:02d}h {hms['min']:02d}m {hms['sec']:05.2f}s" -# ***************************************************************************************************************** +# ************************************************************************************** diff --git a/src/celerity/moon.py b/src/celerity/moon.py index 8e04f37..e9abd68 100644 --- a/src/celerity/moon.py +++ b/src/celerity/moon.py @@ -1,10 +1,10 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @package @observerly/celerity # @license Copyright © 2021-2023 observerly -# ***************************************************************************************************************** +# ************************************************************************************** from datetime import datetime from enum import Enum @@ -18,7 +18,7 @@ from .sun import get_mean_anomaly as get_solar_mean_anomaly from .temporal import get_julian_date -# ***************************************************************************************************************** +# ************************************************************************************** class Phase(Enum): @@ -32,7 +32,7 @@ class Phase(Enum): WaningCrescent = "Waning Crescent" -# ***************************************************************************************************************** +# ************************************************************************************** def get_annual_equation_correction(date: datetime) -> float: @@ -43,7 +43,7 @@ def get_annual_equation_correction(date: datetime) -> float: return 0.1858 * sin(M) -# ***************************************************************************************************************** +# ************************************************************************************** def get_evection_correction(date: datetime) -> float: @@ -60,7 +60,7 @@ def get_evection_correction(date: datetime) -> float: return 1.2739 * sin(2 * (λ - l) - M) -# ***************************************************************************************************************** +# ************************************************************************************** def get_mean_anomaly(date: datetime) -> float: @@ -93,7 +93,7 @@ def get_mean_anomaly(date: datetime) -> float: return M -# ***************************************************************************************************************** +# ************************************************************************************** def get_mean_anomaly_correction(date: datetime) -> float: @@ -119,7 +119,7 @@ def get_mean_anomaly_correction(date: datetime) -> float: return Ca -# ***************************************************************************************************************** +# ************************************************************************************** def get_mean_geometric_longitude(date: datetime) -> float: @@ -151,7 +151,7 @@ def get_mean_geometric_longitude(date: datetime) -> float: return l -# ***************************************************************************************************************** +# ************************************************************************************** def get_mean_ecliptic_longitude_of_the_ascending_node(date: datetime) -> float: @@ -178,7 +178,7 @@ def get_mean_ecliptic_longitude_of_the_ascending_node(date: datetime) -> float: return Ω - 0.16 * sin(M) -# ***************************************************************************************************************** +# ************************************************************************************** def get_mean_ecliptic_longitude(date: datetime) -> float: @@ -202,7 +202,7 @@ def get_mean_ecliptic_longitude(date: datetime) -> float: return λ -# ***************************************************************************************************************** +# ************************************************************************************** def get_true_anomaly(date: datetime) -> float: @@ -226,7 +226,7 @@ def get_true_anomaly(date: datetime) -> float: return ν -# ***************************************************************************************************************** +# ************************************************************************************** def get_true_ecliptic_longitude(date: datetime) -> float: @@ -271,7 +271,7 @@ def get_true_ecliptic_longitude(date: datetime) -> float: return λt -# ***************************************************************************************************************** +# ************************************************************************************** def get_corrected_ecliptic_longitude_of_the_ascending_node(date: datetime) -> float: @@ -292,7 +292,7 @@ def get_corrected_ecliptic_longitude_of_the_ascending_node(date: datetime) -> fl return Ω - 0.16 * sin(radians(M)) -# ***************************************************************************************************************** +# ************************************************************************************** def get_ecliptic_longitude(date: datetime) -> float: @@ -326,7 +326,7 @@ def get_ecliptic_longitude(date: datetime) -> float: return λ -# ***************************************************************************************************************** +# ************************************************************************************** def get_ecliptic_latitude(date: datetime) -> float: @@ -354,7 +354,7 @@ def get_ecliptic_latitude(date: datetime) -> float: return β -# ***************************************************************************************************************** +# ************************************************************************************** def get_equatorial_coordinate(date: datetime) -> EquatorialCoordinate: @@ -387,7 +387,7 @@ def get_equatorial_coordinate(date: datetime) -> EquatorialCoordinate: return {"ra": ra, "dec": dec} -# ***************************************************************************************************************** +# ************************************************************************************** def get_elongation(date: datetime): @@ -416,7 +416,7 @@ def get_elongation(date: datetime): return d -# ***************************************************************************************************************** +# ************************************************************************************** def get_angular_diameter(date: datetime) -> float: @@ -437,7 +437,7 @@ def get_angular_diameter(date: datetime) -> float: return 0.5181 * F -# ***************************************************************************************************************** +# ************************************************************************************** def get_distance(date: datetime) -> float: @@ -459,7 +459,7 @@ def get_distance(date: datetime) -> float: return 3.84400e8 / F -# ***************************************************************************************************************** +# ************************************************************************************** def get_age(date: datetime) -> Age: @@ -493,7 +493,7 @@ def get_age(date: datetime) -> Age: return {"A": A, "a": age} -# ***************************************************************************************************************** +# ************************************************************************************** def get_phase_angle(date: datetime) -> float: @@ -524,7 +524,7 @@ def get_phase_angle(date: datetime) -> float: return PA -# ***************************************************************************************************************** +# ************************************************************************************** def get_illumination(date: datetime) -> float: @@ -543,7 +543,7 @@ def get_illumination(date: datetime) -> float: return 50 * (1 + cos(radians(PA))) -# ***************************************************************************************************************** +# ************************************************************************************** def get_phase(date: datetime) -> Phase: @@ -583,4 +583,4 @@ def get_phase(date: datetime) -> Phase: return Phase.New -# ***************************************************************************************************************** +# ************************************************************************************** diff --git a/src/celerity/night.py b/src/celerity/night.py index efa7714..a5ec1d6 100644 --- a/src/celerity/night.py +++ b/src/celerity/night.py @@ -1,10 +1,10 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @package @observerly/celerity # @license Copyright © 2021-2023 observerly -# ***************************************************************************************************************** +# ************************************************************************************** from datetime import datetime, timedelta from typing import List, Optional, Tuple, TypedDict @@ -14,7 +14,7 @@ from .refraction import get_correction_to_horizontal_for_refraction from .sun import get_equatorial_coordinate -# ***************************************************************************************************************** +# ************************************************************************************** class Night(TypedDict): @@ -22,7 +22,7 @@ class Night(TypedDict): end: datetime -# ***************************************************************************************************************** +# ************************************************************************************** def get_solar_transit( @@ -85,7 +85,7 @@ def get_solar_transit( return sunrise, transit, sunset -# ***************************************************************************************************************** +# ************************************************************************************** def get_night( @@ -111,7 +111,7 @@ def get_night( return {"start": sunset, "end": sunrise} -# ***************************************************************************************************************** +# ************************************************************************************** def is_night( @@ -136,4 +136,4 @@ def is_night( return False -# ***************************************************************************************************************** +# ************************************************************************************** diff --git a/src/celerity/nutation.py b/src/celerity/nutation.py index 4b0735e..0f7eea0 100644 --- a/src/celerity/nutation.py +++ b/src/celerity/nutation.py @@ -1,10 +1,10 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @package @observerly/celerity # @license Copyright © 2021-2023 observerly -# ***************************************************************************************************************** +# ************************************************************************************** from datetime import datetime from math import cos, degrees, radians, sin, tan @@ -16,7 +16,7 @@ from .sun import get_mean_geometric_longitude as get_mean_solar_geometric_longitude from .temporal import get_julian_date -# ***************************************************************************************************************** +# ************************************************************************************** def get_correction_to_equatorial_for_nutation( @@ -77,4 +77,4 @@ def get_correction_to_equatorial_for_nutation( return {"ra": Δra, "dec": Δdec} -# ***************************************************************************************************************** +# ************************************************************************************** diff --git a/src/celerity/parallax.py b/src/celerity/parallax.py index 24fa0e6..df4312d 100644 --- a/src/celerity/parallax.py +++ b/src/celerity/parallax.py @@ -1,10 +1,10 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @package @observerly/celerity # @license Copyright © 2021-2023 observerly -# ***************************************************************************************************************** +# ************************************************************************************** def get_distance(parallax: float) -> float: @@ -17,7 +17,7 @@ def get_distance(parallax: float) -> float: return 1.0 / parallax -# ***************************************************************************************************************** +# ************************************************************************************** def convert_parallax_to_metres(parallax: float) -> float: @@ -32,4 +32,4 @@ def convert_parallax_to_metres(parallax: float) -> float: return d * 3.08567758128e16 -# ***************************************************************************************************************** +# ************************************************************************************** diff --git a/src/celerity/precession.py b/src/celerity/precession.py index a27ab25..ad331b6 100644 --- a/src/celerity/precession.py +++ b/src/celerity/precession.py @@ -1,10 +1,10 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @package @observerly/celerity # @license Copyright © 2021-2023 observerly -# ***************************************************************************************************************** +# ************************************************************************************** from datetime import datetime from math import cos, degrees, radians, sin, tan @@ -12,7 +12,7 @@ from .common import EquatorialCoordinate from .temporal import get_julian_date -# ***************************************************************************************************************** +# ************************************************************************************** def get_correction_to_equatorial_for_precession_of_equinoxes( @@ -49,4 +49,4 @@ def get_correction_to_equatorial_for_precession_of_equinoxes( return {"ra": Δra / (3600 / 15), "dec": Δdec / 3600} -# ***************************************************************************************************************** +# ************************************************************************************** diff --git a/src/celerity/refraction.py b/src/celerity/refraction.py index 3f169ea..8c970a7 100644 --- a/src/celerity/refraction.py +++ b/src/celerity/refraction.py @@ -1,16 +1,16 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @package @observerly/celerity # @license Copyright © 2021-2023 observerly -# ***************************************************************************************************************** +# ************************************************************************************** from math import radians, tan from .common import HorizontalCoordinate -# ***************************************************************************************************************** +# ************************************************************************************** def get_correction_to_horizontal_for_refraction( @@ -48,4 +48,4 @@ def get_correction_to_horizontal_for_refraction( } -# ***************************************************************************************************************** +# ************************************************************************************** diff --git a/src/celerity/seeing.py b/src/celerity/seeing.py index 5fc32f5..7efc618 100644 --- a/src/celerity/seeing.py +++ b/src/celerity/seeing.py @@ -1,14 +1,14 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @package @observerly/celerity # @license Copyright © 2021-2023 observerly -# ***************************************************************************************************************** +# ************************************************************************************** from math import pow, radians, sin -# ***************************************************************************************************************** +# ************************************************************************************** def get_airmass(altitude: float) -> float: @@ -26,7 +26,7 @@ def get_airmass(altitude: float) -> float: return get_airmass_pickering(altitude) -# ***************************************************************************************************************** +# ************************************************************************************** def get_airmass_pickering(altitude: float) -> float: @@ -44,7 +44,7 @@ def get_airmass_pickering(altitude: float) -> float: return 1 / sin(radians(altitude + 244 / (165 + (47 * pow(altitude, 1.1))))) -# ***************************************************************************************************************** +# ************************************************************************************** def get_airmass_karstenyoung(altitude: float) -> float: @@ -62,4 +62,4 @@ def get_airmass_karstenyoung(altitude: float) -> float: return 1 / (sin(radians(altitude)) + 0.50572 * pow(altitude + 6.07995, -1.6364)) -# ***************************************************************************************************************** +# ************************************************************************************** diff --git a/src/celerity/solstice.py b/src/celerity/solstice.py index 9c8b35c..a279f57 100644 --- a/src/celerity/solstice.py +++ b/src/celerity/solstice.py @@ -1,14 +1,14 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @package @observerly/celerity # @license Copyright © 2021-2023 observerly -# ***************************************************************************************************************** +# ************************************************************************************** from datetime import datetime, timezone -# ***************************************************************************************************************** +# ************************************************************************************** def get_summer_solstice(year: int) -> datetime: @@ -29,7 +29,7 @@ def get_summer_solstice(year: int) -> datetime: ) -# ***************************************************************************************************************** +# ************************************************************************************** def get_winter_solstice(year: int) -> datetime: @@ -52,4 +52,4 @@ def get_winter_solstice(year: int) -> datetime: ) -# ***************************************************************************************************************** +# ************************************************************************************** diff --git a/src/celerity/sun.py b/src/celerity/sun.py index 2b0e131..406c426 100644 --- a/src/celerity/sun.py +++ b/src/celerity/sun.py @@ -1,10 +1,10 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @package @observerly/celerity # @license Copyright © 2021-2023 observerly -# ***************************************************************************************************************** +# ************************************************************************************** from datetime import datetime from math import asin, atan2, cos, degrees, pow, radians, sin @@ -13,7 +13,7 @@ from .common import EquatorialCoordinate, get_F_orbital_parameter from .temporal import get_julian_date -# ***************************************************************************************************************** +# ************************************************************************************** def get_equation_of_center(date) -> float: @@ -43,7 +43,7 @@ def get_equation_of_center(date) -> float: return C -# ***************************************************************************************************************** +# ************************************************************************************** def get_mean_anomaly(date: datetime) -> float: @@ -70,7 +70,7 @@ def get_mean_anomaly(date: datetime) -> float: return M -# ***************************************************************************************************************** +# ************************************************************************************** def get_mean_geometric_longitude(date: datetime) -> float: @@ -97,7 +97,7 @@ def get_mean_geometric_longitude(date: datetime) -> float: return L -# ***************************************************************************************************************** +# ************************************************************************************** def get_true_anomaly(date: datetime) -> float: @@ -119,7 +119,7 @@ def get_true_anomaly(date: datetime) -> float: return (M + C) % 360 -# ***************************************************************************************************************** +# ************************************************************************************** def get_true_geometric_longitude(date: datetime) -> float: @@ -141,7 +141,7 @@ def get_true_geometric_longitude(date: datetime) -> float: return (L + C) % 360 -# ***************************************************************************************************************** +# ************************************************************************************** def get_ecliptic_longitude(date: datetime) -> float: @@ -168,7 +168,7 @@ def get_ecliptic_longitude(date: datetime) -> float: return λ -# ***************************************************************************************************************** +# ************************************************************************************** def get_equatorial_coordinate(date: datetime) -> EquatorialCoordinate: @@ -204,7 +204,7 @@ def get_equatorial_coordinate(date: datetime) -> EquatorialCoordinate: return {"ra": ra, "dec": dec} -# ***************************************************************************************************************** +# ************************************************************************************** def get_angular_diameter(date: datetime) -> float: @@ -225,7 +225,7 @@ def get_angular_diameter(date: datetime) -> float: return 0.533128 * F -# ***************************************************************************************************************** +# ************************************************************************************** def get_distance(date: datetime) -> float: @@ -247,4 +247,4 @@ def get_distance(date: datetime) -> float: return 1.495985e11 / F -# ***************************************************************************************************************** +# ************************************************************************************** diff --git a/src/celerity/temporal.py b/src/celerity/temporal.py index 0df21cb..0b7bb35 100644 --- a/src/celerity/temporal.py +++ b/src/celerity/temporal.py @@ -1,10 +1,10 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @package @observerly/celerity # @license Copyright © 2021-2023 observerly -# ***************************************************************************************************************** +# ************************************************************************************** from datetime import datetime, timezone from math import floor, pow @@ -12,7 +12,7 @@ from .common import GeographicCoordinate from .constants import J1900, J2000 -# ***************************************************************************************************************** +# ************************************************************************************** def get_julian_date(date: datetime) -> float: @@ -36,7 +36,7 @@ def get_julian_date(date: datetime) -> float: ) + 2440587.5 -# ***************************************************************************************************************** +# ************************************************************************************** def get_modified_julian_date(date: datetime) -> float: @@ -50,7 +50,7 @@ def get_modified_julian_date(date: datetime) -> float: return get_julian_date(date) - 2400000.5 -# ***************************************************************************************************************** +# ************************************************************************************** def get_greenwhich_sidereal_time(date: datetime) -> float: @@ -89,7 +89,7 @@ def get_greenwhich_sidereal_time(date: datetime) -> float: return GST + 24 if GST < 0 else GST -# ***************************************************************************************************************** +# ************************************************************************************** def get_local_sidereal_time(date: datetime, longitude: float) -> float: @@ -113,7 +113,7 @@ def get_local_sidereal_time(date: datetime, longitude: float) -> float: return 24.0 * d -# ***************************************************************************************************************** +# ************************************************************************************** def get_universal_time(date: datetime) -> float: @@ -173,7 +173,7 @@ def get_universal_time(date: datetime) -> float: return 0.99727 * A -# ***************************************************************************************************************** +# ************************************************************************************** def convert_local_sidereal_time_to_greenwhich_sidereal_time( @@ -199,7 +199,7 @@ def convert_local_sidereal_time_to_greenwhich_sidereal_time( return GST -# ***************************************************************************************************************** +# ************************************************************************************** def convert_greenwhich_sidereal_time_to_universal_coordinate_time( @@ -274,7 +274,7 @@ def convert_greenwhich_sidereal_time_to_universal_coordinate_time( ) -# ***************************************************************************************************************** +# ************************************************************************************** class Time(datetime): @@ -344,4 +344,4 @@ def __eq__(self, other: object) -> bool: ) -# ***************************************************************************************************************** +# ************************************************************************************** diff --git a/src/celerity/transit.py b/src/celerity/transit.py index 18b89fa..cbc0658 100644 --- a/src/celerity/transit.py +++ b/src/celerity/transit.py @@ -1,10 +1,10 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @package @observerly/celerity # @license Copyright © 2021-2023 observerly -# ***************************************************************************************************************** +# ************************************************************************************** from datetime import datetime, timedelta, timezone from math import acos, cos, degrees, radians, sin, tan @@ -21,11 +21,9 @@ from .temporal import ( convert_greenwhich_sidereal_time_to_universal_coordinate_time, convert_local_sidereal_time_to_greenwhich_sidereal_time, - get_greenwhich_sidereal_time, - get_local_sidereal_time, ) -# ***************************************************************************************************************** +# ************************************************************************************** class Transit(TypedDict): @@ -42,7 +40,7 @@ class Transit(TypedDict): S: float -# ***************************************************************************************************************** +# ************************************************************************************** class Rise(TypedDict): @@ -58,7 +56,7 @@ class Rise(TypedDict): az: float -# ***************************************************************************************************************** +# ************************************************************************************** class Set(TypedDict): @@ -74,7 +72,7 @@ class Set(TypedDict): az: float -# ***************************************************************************************************************** +# ************************************************************************************** class TransitParameters(TypedDict): @@ -82,7 +80,7 @@ class TransitParameters(TypedDict): H1: float -# ***************************************************************************************************************** +# ************************************************************************************** def is_object_circumpolar( @@ -109,15 +107,18 @@ def is_object_circumpolar( return dec > (90 - lat - horizon) if lat > 0 else dec < (90 - lat - horizon) -# ***************************************************************************************************************** +# ************************************************************************************** def is_object_never_visible( observer: GeographicCoordinate, target: EquatorialCoordinate, horizon: float ) -> bool: """ - An object is never visible if it is always below the observer's horizon and never rises. - This is true when the object's declination is less than the observer's latitude minus 90 degrees. + An object is never visible if it is always below the observer's horizon and never + rises. + + This is true when the object's declination is less than the observer's + latitude minus 90 degrees. :param target: The equatorial coordinate of the observed object. :param observer: The geographic coordinate of the observer. @@ -130,12 +131,13 @@ def is_object_never_visible( # We only need the latitude of the observer: lat = observer["lat"] - # If the object's declination is less than the observer's latitude minus 90 degrees, - # then the object is never visible (always below the observer's horizon and never rises). + # If the object's declination is less than the observer's latitude + # minus 90 degrees, then the object is never visible (always below the + # observer's horizon and never rises). return dec < (lat - 90 + horizon) if lat > 0 else dec > (lat - 90 + horizon) -# ***************************************************************************************************************** +# ************************************************************************************** def is_object_below_horizon( @@ -145,8 +147,11 @@ def is_object_below_horizon( horizon: float, ) -> bool: """ - An object is never visible if it is always below the observer's horizon and never rises. - This is true when the object's declination is less than the observer's latitude minus 90 degrees. + An object is never visible if it is always below the observer's horizon + and never rises. + + This is true when the object's declination is less than the observer's + latitude minus 90 degrees. :param target: The equatorial or horizontal coordinate of the observed object. :param observer: The geographic coordinate of the observer. @@ -169,7 +174,7 @@ def is_object_below_horizon( return hz["alt"] < 0 + horizon -# ***************************************************************************************************************** +# ************************************************************************************** def get_does_object_rise_or_set( @@ -202,7 +207,7 @@ def get_does_object_rise_or_set( return {"Ar": Ar, "H1": H1} -# ***************************************************************************************************************** +# ************************************************************************************** def get_transit( @@ -210,7 +215,8 @@ def get_transit( target: EquatorialCoordinate, ) -> Transit | Literal[None]: """ - Determines the local sidereal time and azimuthal angle of rise and set for an object. + Determines the local sidereal time and azimuthal angle of rise + and set for an object. :param observer: The geographic coordinate of the observer. :param target: The equatorial coordinate of the observed object. @@ -249,7 +255,7 @@ def get_transit( return {"LSTr": LSTr, "LSTs": LSTs, "R": R, "S": S} -# ***************************************************************************************************************** +# ************************************************************************************** def get_next_rise( @@ -296,7 +302,8 @@ def get_next_rise( # Convert the local sidereal time of rise to Greenwhich sidereal time: GSTr = convert_local_sidereal_time_to_greenwhich_sidereal_time(LSTr, observer) - # Convert the Greenwhich sidereal time to universal coordinate time for the date specified: + # Convert the Greenwhich sidereal time to universal coordinate time for the + # date specified: rise = convert_greenwhich_sidereal_time_to_universal_coordinate_time(date, GSTr) # If the rise is before the current time, then we know the next rise is tomorrow: @@ -316,7 +323,7 @@ def get_next_rise( } -# ***************************************************************************************************************** +# ************************************************************************************** def get_next_set( @@ -363,7 +370,8 @@ def get_next_set( # Convert the local sidereal time of rise to Greenwhich sidereal time: GSTs = convert_local_sidereal_time_to_greenwhich_sidereal_time(LSTs, observer) - # Convert the Greenwhich sidereal time to universal coordinate time for the date specified: + # Convert the Greenwhich sidereal time to universal coordinate time for + # the date specified: set = convert_greenwhich_sidereal_time_to_universal_coordinate_time(date, GSTs) # If the set is before the current time, then we know the next rise is tomorrow: @@ -383,4 +391,4 @@ def get_next_set( } -# ***************************************************************************************************************** +# ************************************************************************************** diff --git a/src/celerity/utilities.py b/src/celerity/utilities.py index 5188e47..054bd8b 100644 --- a/src/celerity/utilities.py +++ b/src/celerity/utilities.py @@ -1,16 +1,16 @@ -# ***************************************************************************************************************** +# ************************************************************************************** # @author Michael Roberts # @package @observerly/celerity # @license Copyright © 2021-2023 observerly -# ***************************************************************************************************************** +# ************************************************************************************** from math import floor from .common import Angle, HourAngle -# ***************************************************************************************************************** +# ************************************************************************************** def get_normalised_azimuthal_degree(degree: float) -> float: @@ -30,7 +30,7 @@ def get_normalised_azimuthal_degree(degree: float) -> float: return d -# ***************************************************************************************************************** +# ************************************************************************************** def get_normalised_inclination_degree(degree: float) -> float: @@ -59,7 +59,7 @@ def get_normalised_inclination_degree(degree: float) -> float: return d -# ***************************************************************************************************************** +# ************************************************************************************** def convert_degree_to_dms(degree: float) -> Angle: @@ -82,7 +82,7 @@ def convert_degree_to_dms(degree: float) -> Angle: return {"deg": deg if degree >= 0 else -deg, "min": min, "sec": sec} -# ***************************************************************************************************************** +# ************************************************************************************** def convert_degree_to_hms(degree: float) -> HourAngle: