Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from pyorbital.orbital import Orbital
|
| 3 |
+
from datetime import datetime
|
| 4 |
+
|
| 5 |
+
def next_iss_pass(lat, lon, alt):
|
| 6 |
+
now = datetime.utcnow()
|
| 7 |
+
satellite = Orbital('ISS (ZARYA)')
|
| 8 |
+
passes = satellite.get_next_passes(now, 72, lon, lat, alt, horizon=0)
|
| 9 |
+
if not passes:
|
| 10 |
+
return "未來72小時ISS都不會經過此地或無法預測"
|
| 11 |
+
next_pass = passes[0]
|
| 12 |
+
if len(next_pass) == 4:
|
| 13 |
+
rise_time, set_time, max_elev_time, max_elev = next_pass
|
| 14 |
+
return (
|
| 15 |
+
f"升起時間(UTC): {rise_time.isoformat()}\n"
|
| 16 |
+
f"落下時間(UTC): {set_time.isoformat()}\n"
|
| 17 |
+
f"最高點時間(UTC): {max_elev_time.isoformat()}\n"
|
| 18 |
+
f"最大仰角: {max_elev:.2f} 度"
|
| 19 |
+
)
|
| 20 |
+
elif len(next_pass) == 3:
|
| 21 |
+
rise_time, set_time, max_elev_time = next_pass
|
| 22 |
+
return (
|
| 23 |
+
f"升起時間(UTC): {rise_time.isoformat()}\n"
|
| 24 |
+
f"落下時間(UTC): {set_time.isoformat()}\n"
|
| 25 |
+
f"最高點時間(UTC): {max_elev_time.isoformat()}\n"
|
| 26 |
+
"最大仰角:資料缺失"
|
| 27 |
+
)
|
| 28 |
+
else:
|
| 29 |
+
return "資料格式異常"
|
| 30 |
+
|
| 31 |
+
demo = gr.Interface(
|
| 32 |
+
fn=next_iss_pass,
|
| 33 |
+
inputs=[
|
| 34 |
+
gr.Number(label="緯度 (Latitude)", value=25.0340),
|
| 35 |
+
gr.Number(label="經度 (Longitude)", value=121.5645),
|
| 36 |
+
gr.Number(label="海拔 (Altitude, m)", value=10)
|
| 37 |
+
],
|
| 38 |
+
outputs=gr.Textbox(label="下一次ISS通過資訊"),
|
| 39 |
+
title="ISS飛越地標預報",
|
| 40 |
+
description="輸入經緯度與海拔,查詢國際太空站下一次經過的精確時刻。"
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
if __name__ == "__main__":
|
| 44 |
+
demo.launch()
|