天文可观测性计算器 - 支持恒星、深空天体和太阳系天体的可观测性计算,提供MCP和Web服务
Project description
StarWhisper Observatory Calculator
一个用于计算天文目标可观测性的Python包,支持恒星、深空天体和太阳系天体。提供MCP(Model Context Protocol)服务接口,可与支持MCP的AI助手集成。
🌟 主要特性
- 🔭 多目标支持: 恒星、深空天体、太阳系天体
- 📍 灵活观测站: 支持自定义观测站位置
- 🌙 月距约束: 考虑月球干扰的可观测性分析
- 📊 高度曲线: 生成24小时高度变化曲线
- 🌐 Web API: 提供RESTful API接口
- 🤖 MCP服务: 标准MCP协议,支持AI助手集成
- 📱 命令行工具: 简单易用的CLI界面
🚀 快速开始
安装
# 基本安装
pip install starwhisper-observation-calculator
# 或使用 uv
uv pip install starwhisper-observation-calculator
# 安装Web服务支持
pip install starwhisper-observation-calculator[web]
# 安装完整功能
pip install starwhisper-observation-calculator[all]
基本使用
from starwhisper_observation_calculator import ObservabilityCalculator
# 创建计算器(默认兴隆观测站)
calculator = ObservabilityCalculator(
latitude=40.393333,
longitude=117.575278,
altitude=900.0
)
# 计算Vega可观测性
result = calculator.calculate_observability("Vega")
print(result)
命令行使用
# 基本使用
observability-calculator Vega
# 指定观测站
observability-calculator moon --latitude 40.393333 --longitude 117.575278
# 自定义约束条件
observability-calculator M31 --min-altitude 20 --min-moon-separation 45
🤖 MCP服务
本包提供完整的MCP服务,可与支持MCP的AI助手(如Claude Desktop、Cursor等)集成。
启动MCP服务
方法一:使用 uvx(推荐,无需安装)
# 直接运行MCP服务
uvx starwhisper-observation-calculator
# 运行计算器
uvx starwhisper-observation-calculator --calculator Vega
# 启动Web服务
uvx starwhisper-observation-calculator --web --port 8080
方法二:本地安装后使用
# 启动MCP服务
observability-mcp
# 或直接使用python模块
python -m starwhisper_observation_calculator.mcp_server
MCP配置
方法一:使用 uvx(推荐)
{
"mcpServers": {
"starwhisper-observation": {
"command": "uvx",
"args": ["starwhisper-observation-calculator"],
"env": {}
}
}
}
方法二:本地安装后使用
{
"mcpServers": {
"starwhisper-observation": {
"command": "observability-mcp",
"args": [],
"env": {}
}
}
}
在AI助手中使用
安装并配置MCP服务后,你可以直接与AI助手对话:
用户: 请计算Vega在兴隆观测站的可观测性
AI助手: 我来为您计算Vega在兴隆观测站的可观测性...
[自动调用MCP工具: calculate_observability]
参数: latitude=40.393333, longitude=117.575278, target_name="Vega"
结果:
🌟 Vega 可观测性分析报告
📍 观测站: 40.393333°, 117.575278°, 900.0m
🌌 坐标: 18:36:56.3363, +38:47:01.280
📊 当前高度: 45.23°
✅ 可观测性: 可观测
🎯 约束条件: 高度✅ 月距✅
🌐 Web服务
启动Web服务
# 启动Web服务
observability-web
# 或指定端口
observability-web --port 8080
API接口
GET /- Web界面GET /docs- API文档POST /observability- 计算可观测性POST /observability/batch- 批量计算GET /targets/supported- 获取支持的目标GET /observatories- 获取预设观测站
使用示例
# 计算Vega可观测性
curl -X POST "http://localhost:8000/observability" \
-H "Content-Type: application/json" \
-d '{
"latitude": 40.393333,
"longitude": 117.575278,
"target_name": "Vega"
}'
📊 支持的目标
太阳系天体
- sun, moon, mercury, venus, mars, jupiter, saturn, uranus, neptune, pluto
恒星
- Vega, Sirius, Polaris, Rigel, Betelgeuse, Altair, Deneb, Arcturus, Spica, Antares
深空天体
- M31, M42, M13, M57, M27, M51, M104, M87
📍 预设观测站
- 兴隆观测站: 40.393333°, 117.575278°, 900m
- 新昌观测站: 29.501784°, 120.905740°, 0m
- 帕洛马天文台: 33.3563°, -116.8650°, 1712m
🔧 高级配置
自定义观测站
from starwhisper_observation_calculator import ObservabilityCalculator
calculator = ObservabilityCalculator(
latitude=your_latitude,
longitude=your_longitude,
altitude=your_altitude,
timezone="Asia/Shanghai"
)
约束条件
result = calculator.calculate_observability(
target_name="Vega",
min_altitude=20.0, # 最小地平高度
min_moon_separation=45.0, # 最小月距
time_range_hours=48 # 检查时间范围
)
🛠️ 开发
安装开发依赖
# 克隆项目
git clone https://github.com/wangcunshi/StarWhisper-observation-calculator.git
cd StarWhisper-observation-calculator
# 安装开发依赖
pip install -e .[dev]
# 或使用 uv
uv pip install -e .[dev]
运行测试
# 测试核心功能
python -c "from starwhisper_observation_calculator import ObservabilityCalculator; print('✅ 导入成功')"
# 测试MCP服务
observability-mcp
# 测试Web服务
observability-web
代码格式化
# 格式化代码
black src tests
isort src tests
# 类型检查
mypy src
📄 许可证
本项目采用 MIT 许可证,详见 LICENSE 文件。
🤝 贡献
欢迎提交 Issue 和 Pull Request!
- Fork 项目
- 创建功能分支 (
git checkout -b feature/amazing-feature) - 提交更改 (
git commit -m 'Add amazing feature') - 推送到分支 (
git push origin feature/amazing-feature) - 创建 Pull Request
📞 支持
- 📧 邮箱: wangcunshi@nao.cas.cn
- 🐛 Issues: GitHub Issues
- 📖 文档: GitHub README
📝 更新日志
v1.0.0
- 🎉 首次发布
- ✨ 支持恒星、深空天体和太阳系天体
- 🤖 MCP服务支持
- 🌐 Web API接口
- 📱 命令行工具
- 📊 高度曲线生成
- 🌙 月距约束检查
⭐ 如果这个项目对你有帮助,请给它一个 Star!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file starwhisper_observability_calc-1.0.1.tar.gz.
File metadata
- Download URL: starwhisper_observability_calc-1.0.1.tar.gz
- Upload date:
- Size: 1.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
185424a34651569ba517aa89f74b2d4345399d701fa62d5623b9dbc515ef1e3f
|
|
| MD5 |
2f2f3361cff8616589f6646f7819827a
|
|
| BLAKE2b-256 |
8594b682a38a7c227b95e90462ba3a35222cbc08b6e366625247a33ea7d5a27d
|
File details
Details for the file starwhisper_observability_calc-1.0.1-py3-none-any.whl.
File metadata
- Download URL: starwhisper_observability_calc-1.0.1-py3-none-any.whl
- Upload date:
- Size: 20.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb5d20eca43a12186f23d371a10c2344abdd2d68ebf739e73cf9678dbc08a389
|
|
| MD5 |
2c410a8b3ed679825a24871088802fb8
|
|
| BLAKE2b-256 |
421201a394bc4169310ca3d24f01355a7cdccf307b375d1a3166d551cadec108
|