Skip to content

Commit 0896533

Browse files
committed
feat: 增强日月食搜索、沙罗周期与内行星凌日
- 使用压缩表加速查找日月食沙罗周期信息 - 优化日月食搜索跳步,减少非食季朔望月扫描 - 新增本地日全食、日环食、月全食搜索接口,返回 ok 区分未找到结果 - 新增水星、金星地心凌日查询及测试
1 parent 84d3e14 commit 0896533

20 files changed

Lines changed: 1987 additions & 408 deletions

README.en.md

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ go get github.com/starainrt/astro
4646
- Lunar position, rise/set, Earth distance, phase, new/full/quarter times, apparent diameter, bright-limb angle, parallactic angle, geocentric/topocentric libration, apsides, nodes, maximum declination
4747
- `lite/sun` and `lite/moon` lightweight approximation chains for watches, frontends, mini programs, and other resource-constrained environments
4848
- Global and local solar/lunar eclipses, solar central paths, partial footprints, visible local lunar eclipses, Saros metadata, and SVG diagrams
49-
- Seven major planets with positions, rise/set, conjunction/opposition/station events, quadratures, elongations, nodes, phase, apparent magnitude, apparent diameter, parallactic angle, and physical ephemerides
49+
- Seven major planets with positions, rise/set, conjunction/opposition/station events, quadratures, elongations, Mercury/Venus geocentric transits, nodes, phase, apparent magnitude, apparent diameter, parallactic angle, and physical ephemerides
5050
- 9100+ star catalog entries, constellation lookup, proper-motion propagation, rise/set, parallactic angle, and apparent altitude
5151
- Coordinate transforms, topocentric coordinates, sidereal time, precession, nutation, angular distance, refraction, airmass, parallactic angle, and Galactic coordinates
5252
- Standalone formulas for blackbody radiation, synodic periods, photometry, telescope limiting magnitude, stellar radius/temperature/luminosity relations, and airmass models
@@ -63,7 +63,7 @@ go get github.com/starainrt/astro
6363
| `moon` | Lunar position, rise/set, phases, new/full/quarter times, apparent altitude, parallactic angle, diameter, bright-limb angle, geocentric/topocentric libration, apsides, nodes, maximum declination |
6464
| `lite/sun` / `lite/moon` | Lightweight Sun/Moon approximation chains for minute-level rise/set, lightweight sky position, and lunar-phase work |
6565
| `eclipse` / `eclipse/svg` | Global/local solar and lunar eclipses, solar central paths, partial footprints, local visibility filtering, Saros metadata, SVG output |
66-
| `mercury` / `venus` | Positions, rise/set, conjunctions, stations, elongations, phase, parallactic angle, magnitude, diameter, nodes, physical ephemerides |
66+
| `mercury` / `venus` | Positions, rise/set, conjunctions, stations, elongations, geocentric transits, phase, parallactic angle, magnitude, diameter, nodes, physical ephemerides |
6767
| `mars` / `jupiter` / `saturn` / `uranus` / `neptune` | Positions, rise/set, conjunction/opposition, stations, quadratures, phase, parallactic angle, magnitude, diameter, nodes, physical ephemerides |
6868
| `earth` | Earth orbital eccentricity, perihelion, aphelion |
6969
| `star` | Constellation lookup, star catalog, proper motion / precession / nutation correction, stellar rise/set, parallactic angle, apparent altitude |
@@ -674,6 +674,8 @@ Common entry points:
674674
- `LastSolarEclipse` / `NextSolarEclipse` / `ClosestSolarEclipse`: search global solar eclipses
675675
- `LocalSolarEclipseOnDate`: detect whether a site can see a local solar eclipse on that date
676676
- `LastLocalSolarEclipse` / `NextLocalSolarEclipse` / `ClosestLocalSolarEclipse`: search locally visible solar eclipses
677+
- `LastLocalTotalSolarEclipse` / `NextLocalTotalSolarEclipse` / `ClosestLocalTotalSolarEclipse`: search locally visible total solar eclipses, returning `(info, ok)`
678+
- `LastLocalAnnularSolarEclipse` / `NextLocalAnnularSolarEclipse` / `ClosestLocalAnnularSolarEclipse`: search locally visible annular solar eclipses, returning `(info, ok)`
677679
- `SolarEclipseCentralPath`: compute central line, northern/southern limits, and greatest-eclipse point
678680
- `SolarEclipsePartialFootprints`: compute the partial-eclipse penumbral footprint on Earth
679681
- `eclipse/svg.LocalSolarEclipseSVG`: render a local solar-disk SVG
@@ -925,6 +927,7 @@ Common entry points:
925927
- `LastLunarEclipse` / `NextLunarEclipse` / `ClosestLunarEclipse`: search global lunar eclipses
926928
- `LocalLunarEclipseOnDate`: detect whether a visible lunar eclipse is visible from a site on a local date
927929
- `LastLocalLunarEclipse` / `NextLocalLunarEclipse` / `ClosestLocalLunarEclipse`: search visible local lunar eclipses
930+
- `LastLocalTotalLunarEclipse` / `NextLocalTotalLunarEclipse` / `ClosestLocalTotalLunarEclipse`: search visible local total lunar eclipses, returning `(info, ok)`
928931
- `GeometricLocalLunarEclipseOnDate`: detect geometric lunar eclipse overlap without filtering by whether the Moon is above the horizon
929932
- `eclipse/svg.LunarEclipseSVG`: render a lunar-eclipse shadow-path SVG
930933

@@ -1191,6 +1194,67 @@ For `date := 2020-01-01 08:08:08 CST`, the output is:
11911194
76.86008484515058 256.8600848451506 // Venus ascending-node and descending-node longitudes, degrees
11921195
```
11931196

1197+
Mercury and Venus also expose `NextTransit` / `LastTransit` / `ClosestTransit` for geocentric planetary transits. "Geocentric" means the planet disk crosses the solar disk as seen from Earth's center; it does not test whether the Sun is above the horizon at a particular observing site. For observing plans, combine this with local solar altitude and weather.
1198+
1199+
```go
1200+
package main
1201+
1202+
import (
1203+
"fmt"
1204+
"time"
1205+
1206+
"github.com/starainrt/astro/mercury"
1207+
"github.com/starainrt/astro/venus"
1208+
)
1209+
1210+
func main() {
1211+
// Next geocentric Mercury transit after the beginning of 2019.
1212+
mercuryTransit := mercury.NextTransit(time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC))
1213+
fmt.Println(mercuryTransit.Valid)
1214+
fmt.Println(mercuryTransit.Start)
1215+
fmt.Println(mercuryTransit.InternalStart)
1216+
fmt.Println(mercuryTransit.Greatest)
1217+
fmt.Println(mercuryTransit.InternalEnd)
1218+
fmt.Println(mercuryTransit.End)
1219+
fmt.Println(mercuryTransit.Duration)
1220+
fmt.Println(mercuryTransit.MinimumSeparationArcsec)
1221+
fmt.Println(mercuryTransit.SunSemidiameterArcsec)
1222+
fmt.Println(mercuryTransit.PlanetSemidiameterArcsec)
1223+
1224+
// Next geocentric Venus transit after the beginning of 2012.
1225+
venusTransit := venus.NextTransit(time.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC))
1226+
fmt.Println(venusTransit.Valid)
1227+
fmt.Println(venusTransit.Start)
1228+
fmt.Println(venusTransit.InternalStart)
1229+
fmt.Println(venusTransit.Greatest)
1230+
fmt.Println(venusTransit.InternalEnd)
1231+
fmt.Println(venusTransit.End)
1232+
fmt.Println(venusTransit.Duration)
1233+
}
1234+
```
1235+
1236+
Output:
1237+
1238+
```text
1239+
true // a valid geocentric Mercury transit was found
1240+
2019-11-11 12:35:31.637522578 +0000 UTC // first contact: Mercury externally enters the solar disk
1241+
2019-11-11 12:37:12.887506484 +0000 UTC // second contact: Mercury is fully inside the solar disk
1242+
2019-11-11 15:19:48.430488109 +0000 UTC // greatest transit: Mercury center is closest to the Sun center
1243+
2019-11-11 18:02:29.246907234 +0000 UTC // third contact: Mercury starts leaving the solar disk
1244+
2019-11-11 18:04:10.707873702 +0000 UTC // fourth contact: Mercury externally leaves the solar disk
1245+
5h28m39.070351124s // geocentric transit duration from first to fourth contact
1246+
75.92460219695154 // minimum Mercury-Sun center separation at greatest transit, arcseconds
1247+
968.8881521396688 // solar semidiameter at greatest transit, arcseconds
1248+
4.978442856283907 // Mercury semidiameter at greatest transit, arcseconds
1249+
true // a valid geocentric Venus transit was found
1250+
2012-06-05 22:09:47.581470608 +0000 UTC // first contact: Venus externally enters the solar disk
1251+
2012-06-05 22:27:35.979940295 +0000 UTC // second contact: Venus is fully inside the solar disk
1252+
2012-06-06 01:29:35.686955451 +0000 UTC // greatest transit: Venus center is closest to the Sun center
1253+
2012-06-06 04:31:35.18302828 +0000 UTC // third contact: Venus starts leaving the solar disk
1254+
2012-06-06 04:49:23.581457734 +0000 UTC // fourth contact: Venus externally leaves the solar disk
1255+
6h39m35.999987126s // geocentric transit duration from first to fourth contact
1256+
```
1257+
11941258
#### Outer planets
11951259

11961260
```go
@@ -1767,7 +1831,7 @@ Notes:
17671831
- `lite/sun` and `lite/moon` lightweight Sun/Moon chains for minute-level rise/set, lightweight position, and lunar-phase work
17681832
- Earth eccentricity, Sun-Earth distance, perihelion, aphelion
17691833
- Apparent/mean sidereal time, constellation lookup, common coordinate transforms, refraction, airmass, parallactic angle, Galactic coordinates
1770-
- Seven major-planet coordinates, Sun/body and Earth/body distances, special events, physical ephemerides, apparent diameters, phases, parallactic angles, and nodes
1834+
- Seven major-planet coordinates, Sun/body and Earth/body distances, special events, Mercury/Venus geocentric transits, physical ephemerides, apparent diameters, phases, parallactic angles, and nodes
17711835
- Chinese lunisolar calendar conversion from 104 BCE to 3000 CE
17721836
- 9100+ star catalog
17731837
- Generic small-body orbit propagation, H-G apparent magnitude, visual-binary position angle and separation

README.md

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ go get github.com/starainrt/astro
4444
- 🌙 **月亮计算**:天球位置、月出月落、地月距离、月相、朔望时间、视直径、亮边位置角、视差角、地心/站心天平动、近远地点、交点、最大赤纬等
4545
- 🪶 **轻量链路**`lite/sun``lite/moon` 提供面向手表、前端、小程序和其它资源受限环境的轻量近似太阳/月亮算法,覆盖天球位置、升落和月相
4646
- 🌗 **日月食**:全局日食、站心日食、中心线/偏食足迹、月食、地方可见月食与 SVG 示意图
47-
- 🪐 **行星计算**:七大行星天球位置、升落时间、合冲留等特殊天象时间、升交点/降交点、视直径/视半径、相位、视差角、节点、视星等与物理星历
47+
- 🪐 **行星计算**:七大行星天球位置、升落时间、合冲留、大距、水星/金星地心凌日等特殊天象时间、升交点/降交点、视直径/视半径、相位、视差角、节点、视星等与物理星历
4848
-**恒星计算**:指定天球坐标所属星座;同时包含9100颗恒星数据库,可计算升降时间、视差角和视高度角,获取指定日期的恒星坐标信息
4949
- 🧭 **坐标工具**:黄道/赤道/地平坐标转换、站心坐标、恒星时、岁差、章动、角距离、大气折射、大气质量、视差角、银道坐标
5050
- 🔭 **研究公式**:黑体辐射、会合周期、星等距离换算、望远镜极限星等、恒星半径/温度/光度换算、大气质量模型
@@ -61,7 +61,7 @@ go get github.com/starainrt/astro
6161
| `moon` | 月亮位置、月出月落、月相、朔望弦、视高度角、视差角、视直径、亮边位置角、地心/站心天平动、近远地点、交点、最大赤纬 |
6262
| `lite/sun` / `lite/moon` | 轻量太阳/月亮近似链路,面向分钟级升落、轻量天球位置和月相计算 |
6363
| `eclipse` / `eclipse/svg` | 全局/局地日月食、日食中心线与偏食足迹、局地可见性筛选、日月食 SVG |
64-
| `mercury` / `venus` | 水星、金星位置、升落、合日、留、大距、相位、视差角、视星等、视直径、节点和物理星历 |
64+
| `mercury` / `venus` | 水星、金星位置、升落、合日、留、大距、地心凌日、相位、视差角、视星等、视直径、节点和物理星历 |
6565
| `mars` / `jupiter` / `saturn` / `uranus` / `neptune` | 外行星位置、升落、合冲、留、方照、相位、视差角、视星等、视直径、节点和物理星历 |
6666
| `earth` | 地球轨道偏心率、近日点、远日点 |
6767
| `star` | 星座判定、恒星数据库、恒星自行/岁差/章动修正、恒星升落、视差角、视高度角 |
@@ -742,6 +742,8 @@ func main() {
742742
- `LastSolarEclipse` / `NextSolarEclipse` / `ClosestSolarEclipse`:搜索全局日食
743743
- `LocalSolarEclipseOnDate`:判断某地当天是否能看到站心日食
744744
- `LastLocalSolarEclipse` / `NextLocalSolarEclipse` / `ClosestLocalSolarEclipse`:搜索某地可见的站心日食
745+
- `LastLocalTotalSolarEclipse` / `NextLocalTotalSolarEclipse` / `ClosestLocalTotalSolarEclipse`:搜索某地可见的日全食,返回 `(info, ok)`
746+
- `LastLocalAnnularSolarEclipse` / `NextLocalAnnularSolarEclipse` / `ClosestLocalAnnularSolarEclipse`:搜索某地可见的日环食,返回 `(info, ok)`
745747
- `SolarEclipseCentralPath`:计算中心线、南北界和食甚点
746748
- `SolarEclipsePartialFootprints`:计算偏食半影在地球表面的足迹
747749
- `eclipse/svg.LocalSolarEclipseSVG`:生成某地的日面视圆 SVG
@@ -995,6 +997,7 @@ true 13424 // 北京日全食 SVG 生成成功,长度 13424 字节
995997
- `LastLunarEclipse` / `NextLunarEclipse` / `ClosestLunarEclipse`:搜索全局月食
996998
- `LocalLunarEclipseOnDate`:判断某地当天是否能看到可见月食
997999
- `LastLocalLunarEclipse` / `NextLocalLunarEclipse` / `ClosestLocalLunarEclipse`:搜索某地可见月食
1000+
- `LastLocalTotalLunarEclipse` / `NextLocalTotalLunarEclipse` / `ClosestLocalTotalLunarEclipse`:搜索某地可见月全食,返回 `(info, ok)`
9981001
- `GeometricLocalLunarEclipseOnDate`:判断某地当天是否发生几何月食,不做“月亮在地平线上方”的可见性过滤
9991002
- `eclipse/svg.LunarEclipseSVG`:生成月食穿影图 SVG
10001003

@@ -1267,6 +1270,67 @@ fmt.Println(venus.AscendingNode(date), venus.DescendingNode(date))
12671270
76.86008484515058 256.8600848451506 // 金星升交点、降交点黄经,单位度
12681271
```
12691272

1273+
水星和金星还提供 `NextTransit` / `LastTransit` / `ClosestTransit` 地心凌日查询。这里的“地心”指从地球中心看到的行星圆面经过太阳圆面,不判断某个地点当时太阳是否在地平线上;如果要做观测计划,还需要结合本地太阳高度角和天气条件。
1274+
1275+
```go
1276+
package main
1277+
1278+
import (
1279+
"fmt"
1280+
"time"
1281+
1282+
"github.com/starainrt/astro/mercury"
1283+
"github.com/starainrt/astro/venus"
1284+
)
1285+
1286+
func main() {
1287+
// 查询 2019 年之后下一次地心水星凌日。
1288+
mercuryTransit := mercury.NextTransit(time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC))
1289+
fmt.Println(mercuryTransit.Valid)
1290+
fmt.Println(mercuryTransit.Start)
1291+
fmt.Println(mercuryTransit.InternalStart)
1292+
fmt.Println(mercuryTransit.Greatest)
1293+
fmt.Println(mercuryTransit.InternalEnd)
1294+
fmt.Println(mercuryTransit.End)
1295+
fmt.Println(mercuryTransit.Duration)
1296+
fmt.Println(mercuryTransit.MinimumSeparationArcsec)
1297+
fmt.Println(mercuryTransit.SunSemidiameterArcsec)
1298+
fmt.Println(mercuryTransit.PlanetSemidiameterArcsec)
1299+
1300+
// 查询 2012 年之后下一次地心金星凌日。
1301+
venusTransit := venus.NextTransit(time.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC))
1302+
fmt.Println(venusTransit.Valid)
1303+
fmt.Println(venusTransit.Start)
1304+
fmt.Println(venusTransit.InternalStart)
1305+
fmt.Println(venusTransit.Greatest)
1306+
fmt.Println(venusTransit.InternalEnd)
1307+
fmt.Println(venusTransit.End)
1308+
fmt.Println(venusTransit.Duration)
1309+
}
1310+
```
1311+
1312+
输出结果:
1313+
1314+
```text
1315+
true // 找到一次有效的地心水星凌日
1316+
2019-11-11 12:35:31.637522578 +0000 UTC // 一触:水星外切进入太阳圆面
1317+
2019-11-11 12:37:12.887506484 +0000 UTC // 二触:水星完全进入太阳圆面
1318+
2019-11-11 15:19:48.430488109 +0000 UTC // 凌甚:水星中心最接近太阳中心
1319+
2019-11-11 18:02:29.246907234 +0000 UTC // 三触:水星开始离开太阳圆面
1320+
2019-11-11 18:04:10.707873702 +0000 UTC // 四触:水星外切离开太阳圆面
1321+
5h28m39.070351124s // 一触到四触的地心凌日持续时间
1322+
75.92460219695154 // 凌甚时水星中心与太阳中心的最小角距离,单位角秒
1323+
968.8881521396688 // 凌甚时太阳视半径,单位角秒
1324+
4.978442856283907 // 凌甚时水星视半径,单位角秒
1325+
true // 找到一次有效的地心金星凌日
1326+
2012-06-05 22:09:47.581470608 +0000 UTC // 一触:金星外切进入太阳圆面
1327+
2012-06-05 22:27:35.979940295 +0000 UTC // 二触:金星完全进入太阳圆面
1328+
2012-06-06 01:29:35.686955451 +0000 UTC // 凌甚:金星中心最接近太阳中心
1329+
2012-06-06 04:31:35.18302828 +0000 UTC // 三触:金星开始离开太阳圆面
1330+
2012-06-06 04:49:23.581457734 +0000 UTC // 四触:金星外切离开太阳圆面
1331+
6h39m35.999987126s // 一触到四触的地心凌日持续时间
1332+
```
1333+
12701334
#### 外行星
12711335

12721336
```go
@@ -1849,7 +1913,7 @@ func main() {
18491913
-`lite/sun``lite/moon` 轻量太阳/月亮链路:面向分钟级升落、轻量位置和月相计算
18501914
- ✅ 地球偏心率、日地距离、近日点、远日点
18511915
- ✅ 真平恒星时、星座计算、常用坐标转换、大气折射、大气质量、视差角、银道坐标
1852-
- ✅ 七大行星坐标、距日距地距离、特殊天象、物理星历、视直径、相位、视差角与节点
1916+
- ✅ 七大行星坐标、距日距地距离、特殊天象、水星/金星地心凌日、物理星历、视直径、相位、视差角与节点
18531917
- ✅ 公农历转换(公元前104年-公元3000年)
18541918
- ✅ 9100+恒星数据库
18551919
- ✅ 通用小天体轨道传播、H-G 视星等、视双星位置角/角距

0 commit comments

Comments
 (0)