Spaces:
Running
Running
| 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() | |