Deuchnord 1 неделю назад
committed by GitHub
Родитель
Сommit
852c4390a2
Не найден GPG ключ соответствующий данной подписи Идентификатор GPG ключа: B5690EEEBB952194
2 измененных файлов: 45 добавлений и 56 удалений
  1. +0
    -12
      .gitpod.yml
  2. +45
    -44
      kosmorrolib/ephemerides.py

+ 0
- 12
.gitpod.yml Просмотреть файл

@@ -1,12 +0,0 @@
github:
prebuilds:
pullRequestsFromForks: true

vscode:
extensions:
- ms-vscode.makefile-tools
- editorconfig.editorconfig

tasks:
- before: pip install -U pip poetry
init: poetry install

+ 45
- 44
kosmorrolib/ephemerides.py Просмотреть файл

@@ -30,7 +30,6 @@ from .core import (
get_skf_objects,
get_timescale,
get_iau2000b,
deprecated,
alert_deprecation,
)
from .enum import MoonPhaseType
@@ -39,48 +38,6 @@ from .exceptions import OutOfRangeDateError
RISEN_ANGLE = -0.8333


def _get_skyfield_to_moon_phase(
times: [Time], vals: [int], now: Time, utc_offset: Union[int, float]
) -> Union[MoonPhase, None]:
tomorrow = get_timescale().utc(
now.utc_datetime().year, now.utc_datetime().month, now.utc_datetime().day + 1
)

next_phase_time = None
i = 0

# Find the current moon phase:
for i, time in enumerate(times):
if now.utc_datetime() <= time.utc_datetime():
if time.utc_datetime() >= tomorrow.utc_datetime():
i -= 1
break

current_phase = MoonPhaseType(vals[i])

if current_phase in [
MoonPhaseType.NEW_MOON,
MoonPhaseType.FIRST_QUARTER,
MoonPhaseType.FULL_MOON,
MoonPhaseType.LAST_QUARTER,
]:
current_phase_time = translate_to_utc_offset(
times[i].utc_datetime(), utc_offset
)
else:
current_phase_time = None

# Find the next moon phase
for j in range(i + 1, len(times)):
if vals[j] in [0, 2, 4, 6]:
next_phase_time = translate_to_utc_offset(
times[j].utc_datetime(), utc_offset
)
break

return MoonPhase(current_phase, current_phase_time, next_phase_time)


def get_moon_phase(
for_date: date = date.today(), utc_offset: Union[int, float] = 0, **argv
) -> MoonPhase:
@@ -116,6 +73,49 @@ def get_moon_phase(
kosmorrolib.exceptions.OutOfRangeDateError: The date must be between 1899-08-09 and 2053-09-26
"""

def _get_skyfield_to_moon_phase(
times: [Time], vals: [int], now: Time, utc_offset: Union[int, float]
):
tomorrow = get_timescale().utc(
now.utc_datetime().year,
now.utc_datetime().month,
now.utc_datetime().day + 1,
)

next_phase_time = None
i = 0

# Find the current moon phase:
for i, time in enumerate(times):
if now.utc_datetime() <= time.utc_datetime():
if time.utc_datetime() >= tomorrow.utc_datetime():
i -= 1
break

current_phase = MoonPhaseType(vals[i])

if current_phase in [
MoonPhaseType.NEW_MOON,
MoonPhaseType.FIRST_QUARTER,
MoonPhaseType.FULL_MOON,
MoonPhaseType.LAST_QUARTER,
]:
current_phase_time = translate_to_utc_offset(
times[i].utc_datetime(), utc_offset
)
else:
current_phase_time = None

# Find the next moon phase
for j in range(i + 1, len(times)):
if vals[j] in [0, 2, 4, 6]:
next_phase_time = translate_to_utc_offset(
times[j].utc_datetime(), utc_offset
)
break

return MoonPhase(current_phase, current_phase_time, next_phase_time)

if argv.get("timezone") is not None:
alert_deprecation(
"'timezone' argument of the get_moon_phase() function is deprecated. Use utc_offset instead."
@@ -275,7 +275,8 @@ def get_ephemerides(
alert_deprecation(
"'timezone' argument of the get_ephemerides() function is deprecated. Use utc_offset instead."
)
utc_offset = argv.get("timezone")

return get_ephemerides(position, for_date, argv.get("timezone"))

def get_angle(for_aster: Object):
def fun(time: Time) -> float:


Загрузка…
Отмена
Сохранить