File size: 1,631 Bytes
73e0d0d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import gradio as gr
from pyorbital.orbital import Orbital
from datetime import datetime

def next_iss_pass(lat, lon, alt):
    now = datetime.utcnow()
    satellite = Orbital('ISS (ZARYA)')
    passes = satellite.get_next_passes(now, 72, lon, lat, alt, horizon=0)
    if not passes:
        return "未來72小時ISS都不會經過此地或無法預測"
    next_pass = passes[0]
    if len(next_pass) == 4:
        rise_time, set_time, max_elev_time, max_elev = next_pass
        return (
            f"升起時間(UTC): {rise_time.isoformat()}\n"
            f"落下時間(UTC): {set_time.isoformat()}\n"
            f"最高點時間(UTC): {max_elev_time.isoformat()}\n"
            f"最大仰角: {max_elev:.2f} 度"
        )
    elif len(next_pass) == 3:
        rise_time, set_time, max_elev_time = next_pass
        return (
            f"升起時間(UTC): {rise_time.isoformat()}\n"
            f"落下時間(UTC): {set_time.isoformat()}\n"
            f"最高點時間(UTC): {max_elev_time.isoformat()}\n"
            "最大仰角:資料缺失"
        )
    else:
        return "資料格式異常"

demo = gr.Interface(
    fn=next_iss_pass,
    inputs=[
        gr.Number(label="緯度 (Latitude)", value=25.0340),
        gr.Number(label="經度 (Longitude)", value=121.5645),
        gr.Number(label="海拔 (Altitude, m)", value=10)
    ],
    outputs=gr.Textbox(label="下一次ISS通過資訊"),
    title="ISS飛越地標預報",
    description="輸入經緯度與海拔,查詢國際太空站下一次經過的精確時刻。"
)

if __name__ == "__main__":
    demo.launch()