mcp-stargazing

by StarGazer1995
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Utilizes NumPy for numerical calculations involved in celestial positioning and astronomical computations.

  • Implements testing framework for validating celestial calculations and time/location utilities.

mcp观星

计算地球上任何位置的天体(太阳、月亮、行星、恒星和深空天体)的高度、升起和落下时间,并可选择进行光污染分析。

特征

  • 高度/方位角计算:获取任何天体的海拔和罗盘方向。
  • 上升/下降时间:确定物体何时出现/消失在地平线以上。
  • 光污染分析:加载和分析光污染地图(GeoTIFF 格式)。
  • 支持
    • 太阳系天体(太阳、月亮、行星)
    • 星星(例如“天狼星”)
    • 深空天体(例如“仙女座”、“猎户座星云”)
  • 时区感知:使用当地时间或 UTC 时间。

安装

pip install astropy pytz numpy astroquery rasterio geopy

用法

计算高度/方位角

from src.celestial import celestial_pos from astropy.coordinates import EarthLocation import pytz from datetime import datetime # Observer location (New York) location = EarthLocation(lat=40.7128, lon=-74.0060) # Time (local timezone-aware) local_time = pytz.timezone("America/New_York").localize(datetime(2023, 10, 1, 12, 0)) altitude, azimuth = celestial_pos("sun", location, local_time) print(f"Sun Position: Altitude={altitude:.1f}°, Azimuth={azimuth:.1f}°")

计算上升/设置时间

from src.celestial import celestial_rise_set rise, set_ = celestial_rise_set("andromeda", location, local_time.date()) print(f"Andromeda: Rise={rise.iso}, Set={set_.iso}")

加载光污染地图

from src.light_pollution import load_map # Load a GeoTIFF light pollution map vriis_data, bounds, crs, transform = load_map("path/to/map.tif") print(f"Map Bounds: {bounds}")

API 参考

celestial_pos(celestial_object, observer_location, time)src/celestial.py

  • 输入
    • celestial_object :名称(例如, "sun""andromeda" )。
    • observer_locationEarthLocation对象。
    • timedatetime (时区感知)或 Astropy Time
  • 返回(altitude_degrees, azimuth_degrees)

celestial_rise_set(celestial_object, observer_location, date, horizon=0.0)src/celestial.py

  • 输入
    • date :时区感知的datetime
    • horizon :地平线高度(默认值:0°)。
  • 返回(rise_time, set_time)作为 UTC Time对象。

load_map(map_path)src/light_pollution.py

  • 输入
    • map_path :GeoTIFF 文件的路径。
  • 返回:光污染分析的元组(vriis_data, bounds, crs, transform)

测试

使用以下方式运行测试:

pytest tests/

关键测试用例( tests/test_celestial.py

def test_calculate_altitude_deepspace(): """Test deep-space object resolution.""" altitude, _ = celestial_pos("andromeda", NYC, Time.now()) assert -90 <= altitude <= 90 def test_calculate_rise_set_sun(): """Validate Sun rise/set times.""" rise, set_ = celestial_rise_set("sun", NYC, datetime(2023, 10, 1)) assert rise < set_

项目结构

. ├── src/ │ ├── celestial.py # Core celestial calculations │ ├── light_pollution.py # Light pollution map utilities │ ├── utils.py # Time/location helpers │ └── main.py # CLI entry point ├── tests/ │ ├── test_celestial.py │ └── test_utils.py └── README.md

未来工作

  • 增加对彗星/小行星的支持。
  • 优化 SIMBAD 查询以供离线使用。
  • 将光污染数据整合到能见度预测中。

重要更新:

  1. 光污染:将light_pollution.py添加到功能和 API 参考中。
  2. 依赖项:将rasteriogeopy添加到安装说明中。
  3. 项目结构:明确文件角色和测试覆盖率。
ID: av409aptwb