python - 计算月牙的倾斜度

标签 python astronomy skyfield

是否可以使用 Skyfield 计算月牙的倾斜度?还是直接?我知道新月形岩石来回移动,我想正确显示它。

https://www.calsky.com/cs.cgi/Moon/15?obs=4311082095747103&c=

# https://rhodesmill.org/skyfield/toc.html 
from skyfield import api

tmsc = api.load.timescale()
planets = api.load('de421.bsp')

import datetime
import pytz

toposloc = api.Topos('50.9409116 N', '6.9576131 E') # Köln local position on earth
toposabs = planets['earth'] + toposloc # absolute position incl earth 
DTUTC = datetime.datetime.now(datetime.timezone.utc)

# calc moon
astro = toposabs.at(tmsc.utc(DTUTC.year, DTUTC.month, DTUTC.day, DTUTC.hour, DTUTC.minute, DTUTC.second)).observe(planets['moon'])
app = astro.apparent()
alt, azi, distance = app.altaz()
altazmoon=[alt.degrees, azi.degrees] # save for later
_, lonmoon, _ = app.ecliptic_latlon()

最佳答案

好的,感谢 stackoverflows 的建议,我在这里找到了这个答案,这可能就是我正在寻找的

Calculating moon face rotation as a function of Earth coordinates

我目前正在测试这个。至少今天,如果我向窗外看的话,它看起来非常准确。干得好!

[编辑:]我测试了一周并更新了下面的代码。现在一切似乎都已步入正​​轨。感谢 Stackoverflow

import math

def moontilt(altazsun, altazmoon): # mathematical angle where the sun light shines from onto the moon disc (measured from 3 o’clock anticlockwise)
    dLon = math.radians(altazsun[1]-altazmoon[1])
    radaltsun = math.radians(altazsun[0])
    radaltmoon = math.radians(altazmoon[0])
    cosaltsun = math.cos(radaltsun)
    y = math.sin(dLon) * cosaltsun
    x = math.cos(radaltmoon) * math.sin(radaltsun) - math.sin(radaltmoon) * cosaltsun * math.cos(dLon)
    brng = math.atan2(y, x)
    return 90-math.degrees(brng) 

# calc sun
astro = toposabs.at(tmsc.utc(DTUTC.year, DTUTC.month, DTUTC.day, DTUTC.hour, DTUTC.minute, DTUTC.second)).observe(planets['sun'])
app = astro.apparent()
alt, azi, distance = app.altaz()
altazsun=[alt.degrees, azi.degrees] # save for later
_, lonsun, _ = app.ecliptic_latlon()

# get moon phase
moonphase = ((lonmoon.degrees - lonsun.degrees) % 360.0) / 360 #  0: new moon, 0.5: full moon, 1: new moon

# this should be the tilt from the standard displaying symbols in degrees of the crescent I draw with PIL
tilt=-moontilt(altazsun, altazmoon) # PIL.ImageDraw.Draw.chord measures angles increasing clockwise. Thus minus
if moonphase>0.5: tilt+=180 # after full moon the light is expected to shine from the opposite side of the moon (which is already taken into account in the standard moon icons)

关于python - 计算月牙的倾斜度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59183372/

相关文章:

python - 连接 pandas 数据框的多列,包括几列中的 bool 值

python - 如何计算 JSON 数据中的项目

python - 天体单位等效 - 干涉测量基线

satellite - 从瞬时开普勒元素生成 TLE(双线元素)文件是否合法?

python - Glob按日期顺序搜索文件?

python - 如何从 Django 身份验证后端重定向

python - 使用 PyEphem 计算黎明和日落时间

javascript - SVG 月相

macos - 如何找到我的IDLE的Python,然后将pip升级应用到它使用的包?

python - Skyfield 中地球的形状似乎不对 - 我的 python 正确吗?