GNU General Public License v3.0

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

termtrack 技术分析

项目背景与痛点

我们常常以为卫星的跟踪需要复杂的硬件配置,但实际上,一项激动人心的项目 trehn/termtrack 正在打破这些传统观念。这个轻量级的终端应用提供了一种直观的方式来追踪卫星,极大地方便了天文学爱好者和专业的卫星运营者。用户无需深入了解复杂的卫星追踪算法,也不必依赖昂贵的专业设备。只需简单地运行 termtrack,就能在屏幕上实时看到卫星的当前位置和轨迹。

termtrack 可以帮助用户追踪特定卫星的运行轨迹,并在此过程中极大降低所需的复杂性,让任何人都能透过几行简单的命令文本在终端上享受卫星追踪的乐趣。这对于那些对卫星运作和观测感兴趣的用户来说,无疑是一个高端且易用的工具。

核心技术揭秘

termtrack 核心实现方式采用 TLE (Two-Line Element) 数据,它是 SatNOGS 网络中卫星位置和轨道数据的重要来源。这些数据被 termtrack 用于计算卫星的当前位置,并实时地在终端上展现出来。正如下图所示,Termtrack 的数据流依赖 TLE 文件,按照相应时间段进行数据的更新。在图中,TLEFetcher 负责下载最新数据,SatelliteTracker 处理 TLE 并计算卫星位置,TerminalRenderer 将位置数据转换为终端展示格式。

graph TD A[用户请求] --> B[TLEFetcher] B --> C[SatelliteTracker] C --> D[TerminalRenderer]

除了数据层面,termtrack 的设计还利用了 Go 语言的并发特性和操作简便的终端库 (如 gocui) 来实现实时更新和用户交互。其组件间如何分工协作、数据如何流动,合理地依靠轻量级的文件系统管理来保持数据同步,这些安排都体现了软件架构上的高效和简洁。

功能亮点与差异

termtrack 相比市面上的其他卫星追踪工具,其强大之处在于它对轻量级可交互性的追求。不仅可以实时刷新数据,并拥有轻量级中间件特质,使维护工作几乎可以忽略不计。此外,它将交互逻辑封装在终端渲染器中,使所有交互逻辑都对用户透明,这使得用户可以无缝体验其操作简便和界面友好的特性。

应用场景与落地建议

在生产环境中使用 termtrack,需要注意数据源可靠性与实时性。SatNOGS 公开数据更新略慢,具体而言,对于运营级别的应用可能需要引入第三方专业数据供应商,以确保数据的实时性和准确性。这种情况下,还需要实现高可用和容错机制保障应用在线运行。适用于金融信息广播、天气监测、通讯领域等重要的应用场景。

综合评价

优点

  • 简洁易用:无需复杂的设备,刷起卫星仅需几行命令即可实现。
  • 开源社区活跃:依赖于活跃的开源社区,社区提供持续的技术支持和及时代码迭代。
  • 轻量级交互体验:采用 golang 和 gocui 实现的轻量级解决方案。

缺点

  • 数据更新频率:依赖的 TLE 数据源更新频率有限,对于急需高精度卫星数据的特定业务场景,可能需要自行搭建专业数据获取管道来满足实时跟踪的需求。
  • 仅限 TLE 数据源:当前实现主要依赖 TLE 数据源,一定程度上限制了其数据源的丰富性。

关于

GitHub 原始描述(英文)

Track satellites in your terminal

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
664
价值分
347
活跃状态
活跃

语言占比

Python

贡献者

README

TermTrack

Track orbiting objects (such as the International Space Station) in your terminal!

Screenshot

Requires Python 3.10+ and a terminal with 256 colors. A black background is highly recommended.

pip install termtrack
termtrack -figmntxo 1 iss
Usage: termtrack [OPTIONS] [SATELLITE]

  Shows a world map tracking SATELLITE. Valid values for SATELLITE are
  numbers from http://www.celestrak.com/NORAD/elements/master.php (for
  your convenience, a number of aliases have been provided).

  Example satellite aliases (find more with --aliases):
      hubble          Hubble Space Telescope
      iss             International Space Station

  Hotkeys:
      a       Toggle apsides markers
      c       Toggle next-orbit coverage overlay
      d       Toggle ascent/descent markers
      f       Toggle footprint (satellite horizon)
      g       Toggle latitude/longitude grid
      i       Toggle info panels
      n       Toggle night shading
      o       Cycle through drawing 0-3 next orbits
      p       Pause/resume
      q       Quit
      r       Reset plotted time to current
      t       Toggle topography
      x       Toggle crosshair
      left    Small step back in time
      right   Small step forward in time
      down    Large step back in time
      up      Large step forward in time

Options:
  --aliases                 Show all satellite aliases and exit
  --apsides                 Draw apoapsis and periapsis markers
  -b, --body BODY           Which celestial body to draw: Earth, Moon or Mars
                            (defaults to Earth)
  -c, --coverage            Show next-orbit coverage overlay
  -f, --footprint           Draw satellite footprint/horizon
  --fps N                   Frames per second (defaults to 1)
  -g, --grid                Draw latitude/longitude grid
  -i, --info                Show info panels
  -m, --me                  Auto-detect your location as observer
  -n, --night               Shade night side
  -o, --orbits N            Draw this many orbits ahead of the satellite
  --orbit-ascdesc           Draw orbits with ascent/descent markers
  -O, --observer 'LAT LON'  Space-separated latitude and longitude of an
                            observer; overrides IP-geolocation
  -p, --paused              Start paused
  -P, --planets PLANETS     Comma-separated list of celestial objects to draw
                            (e.g. 'sun,moon')
  -r, --orbit-res [/]N[+]   Set distance of orbit markers: 'N' means N
                            minutes, '/N' means 1/Nth of orbital period,
                            append a plus sign to interpolate in between
                            markers (defaults to /70)
  -t, --topo                Enable coloring of topographical features
  --tle FILE                read TLE data from FILE instead of downloading it
                            (SATELLITE will have no effect and can be omitted)
  -x, --crosshair           Draw crosshair around satellite location
  --version                 Show version and exit
  --help                    Show this message and exit

Credit goes to vain/asciiworld for inspiration and some tasty pieces of code.


Latest Version Python 3.10+ License


How Stuff Works

To draw the map, TermTrack will look at a shapefile from Natural Earth in order to find coordinates that are within a landmass. While computationally expensive, this method yields the most accurate and good-looking maps at all terminal sizes. To determine the color of each pixel, a relatively low-resolution and low-quality JPEG image is used. If you look at the image (termtrack/data/earth.jpg), you’ll notice it has green oceans. This is to ensure that ocean blue will not spill over into coastal areas during downsampling. Same goes for the expanded white coast of Antarctica. Finally, the image has been tuned to produce good-looking colors against a black background. The resolution and quality of the image is not really a concern since we do not need maximum per-pixel precision to make the Sahara appear yellow. After computing land/ocean status and land color, this information is cached in ~/.termtrack_map_cache, so it will not have to be rendered again for the current terminal size.

For Mars and the Moon there is no shapefile to read and the entire area is colored according to similar JPEG color maps.

Night shading for each pixel is done by looking at the Sun’s elevation (as computed by skyfield) and shifting the color of the pixel towards blue accordingly. Twilight starts when the Sun is 18° below the horizon (astronomical twilight) and ends when it has risen to 0°.

Satellite locations are derived from TLE data downloaded from CelesTrak. The data is fed into skyfield where the current position of the satellite is computed using SGP4. Most of the data you see in the info panels is provided by skyfield, but the apsides’ locations as well as the satellite footprint outline are computed by TermTrack itself.

Known Issues

When looking at the ISS, you may notice some inconsistencies:

  • the apoapsis/periapsis altitudes from the info panel do not match up with live altitude values when the satellite actually is at that point
  • sometimes the current altitude is lower/higher than periapsis/apoapsis altitude
  • the location of apoapsis/periapsis markers from --apsides are not located at the transition points between plus and minus signs drawn by --orbit-ascdesc

Where do these errors come from? The locations of the apsides are derived from the true anomaly which matches values from http://www.satellite-calculations.com/TLETracker/SatTracker.htm so I’m assuming that’s not the source of the error. The shape of the Earth also does not explain the deviations in altitude.

Interestingly enough, when you look at more eccentric orbits like that of QZS-1 (37158) the errors seem to disappear, suggesting that the issue is merely inaccuracy instead of a plain wrong calculation somewhere.

评论

暂无评论