feat: 引入可切换星历模型并扩展天象观测链路
- 新增半解析、旧模型、自定义与多源堆叠星历实例,提供 Context、Instance、SPK 读取及状态与视位置计算 - 统一太阳、月球和行星实例接口,扩展黄经穿越、留、相位、最近角距、偕日可见、任意高度升落、轨道节点及凌日等天象查询 - 完善日月食、月掩与凌日的月缘剖面、有限盘面接触、站心修正、局地可见性、全球路径和地图输出 - 新增 SVG、GeoJSON、KML 天象输出及凌日、月掩和月缘地形相关缓存与几何求解 - 新增恒星星表导入与查询,支持 CSV、Hipparcos、BSC5、Stellarium 等格式及名称、交叉标识、锥面检索和星等过滤 - 补充 IAU 2006、地球定向、折射消光、大气观测、轨道传播及半解析行星/月球数据支持 - 将默认未来民用时标切换为 TimeScaleLeapHour,更新 2027–2400 农历速查表、中文日期解析和时区边界处理 - 增加事件基线、跨模型回归、几何边界、月缘地形和输出契约测试,完善中英文手册、示例资源、NOTICE 与忽略规则
This commit is contained in:
+18
-19
@@ -6,7 +6,6 @@ import (
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"b612.me/astro/basic"
|
||||
lite "b612.me/astro/lite/internal"
|
||||
)
|
||||
|
||||
@@ -17,68 +16,68 @@ var (
|
||||
|
||||
// TrueLo 轻量真黄经 / lightweight true ecliptic longitude.
|
||||
func TrueLo(date time.Time) float64 {
|
||||
return lite.SunTrueLo(basic.Date2JD(date.UTC()))
|
||||
return lite.SunTrueLo(lite.Date2JD(date.UTC()))
|
||||
}
|
||||
|
||||
// ApparentLo 轻量视黄经 / lightweight apparent ecliptic longitude.
|
||||
func ApparentLo(date time.Time) float64 {
|
||||
return lite.SunApparentLo(basic.Date2JD(date.UTC()))
|
||||
return lite.SunApparentLo(lite.Date2JD(date.UTC()))
|
||||
}
|
||||
|
||||
// Distance 轻量日地距离 / lightweight Sun-Earth distance in AU.
|
||||
func Distance(date time.Time) float64 {
|
||||
return lite.SunDistanceAU(basic.Date2JD(date.UTC()))
|
||||
return lite.SunDistanceAU(lite.Date2JD(date.UTC()))
|
||||
}
|
||||
|
||||
// TrueRa 轻量真赤经 / lightweight true right ascension.
|
||||
func TrueRa(date time.Time) float64 {
|
||||
ra, _ := lite.SunTrueRaDec(basic.Date2JD(date.UTC()))
|
||||
ra, _ := lite.SunTrueRaDec(lite.Date2JD(date.UTC()))
|
||||
return ra
|
||||
}
|
||||
|
||||
// TrueDec 轻量真赤纬 / lightweight true declination.
|
||||
func TrueDec(date time.Time) float64 {
|
||||
_, dec := lite.SunTrueRaDec(basic.Date2JD(date.UTC()))
|
||||
_, dec := lite.SunTrueRaDec(lite.Date2JD(date.UTC()))
|
||||
return dec
|
||||
}
|
||||
|
||||
// TrueRaDec 轻量真赤经、真赤纬 / lightweight true right ascension and declination.
|
||||
func TrueRaDec(date time.Time) (float64, float64) {
|
||||
return lite.SunTrueRaDec(basic.Date2JD(date.UTC()))
|
||||
return lite.SunTrueRaDec(lite.Date2JD(date.UTC()))
|
||||
}
|
||||
|
||||
// ApparentRa 轻量视赤经 / lightweight apparent right ascension.
|
||||
func ApparentRa(date time.Time) float64 {
|
||||
ra, _ := lite.SunApparentRaDec(basic.Date2JD(date.UTC()))
|
||||
ra, _ := lite.SunApparentRaDec(lite.Date2JD(date.UTC()))
|
||||
return ra
|
||||
}
|
||||
|
||||
// ApparentDec 轻量视赤纬 / lightweight apparent declination.
|
||||
func ApparentDec(date time.Time) float64 {
|
||||
_, dec := lite.SunApparentRaDec(basic.Date2JD(date.UTC()))
|
||||
_, dec := lite.SunApparentRaDec(lite.Date2JD(date.UTC()))
|
||||
return dec
|
||||
}
|
||||
|
||||
// ApparentRaDec 轻量视赤经、视赤纬 / lightweight apparent right ascension and declination.
|
||||
func ApparentRaDec(date time.Time) (float64, float64) {
|
||||
return lite.SunApparentRaDec(basic.Date2JD(date.UTC()))
|
||||
return lite.SunApparentRaDec(lite.Date2JD(date.UTC()))
|
||||
}
|
||||
|
||||
// HourAngle 轻量时角 / lightweight hour angle.
|
||||
func HourAngle(date time.Time, lon, lat float64) float64 {
|
||||
_, _, hourAngle := lite.HorizontalCoordinates(ApparentRa(date), ApparentDec(date), basic.Date2JD(date.UTC()), lon, lat)
|
||||
_, _, hourAngle := lite.HorizontalCoordinates(ApparentRa(date), ApparentDec(date), lite.Date2JD(date.UTC()), lon, lat)
|
||||
return hourAngle
|
||||
}
|
||||
|
||||
// Azimuth 轻量方位角 / lightweight azimuth.
|
||||
func Azimuth(date time.Time, lon, lat float64) float64 {
|
||||
_, azimuth, _ := lite.HorizontalCoordinates(ApparentRa(date), ApparentDec(date), basic.Date2JD(date.UTC()), lon, lat)
|
||||
_, azimuth, _ := lite.HorizontalCoordinates(ApparentRa(date), ApparentDec(date), lite.Date2JD(date.UTC()), lon, lat)
|
||||
return azimuth
|
||||
}
|
||||
|
||||
// Altitude 轻量高度角 / lightweight altitude.
|
||||
func Altitude(date time.Time, lon, lat float64) float64 {
|
||||
altitude, _, _ := lite.HorizontalCoordinates(ApparentRa(date), ApparentDec(date), basic.Date2JD(date.UTC()), lon, lat)
|
||||
altitude, _, _ := lite.HorizontalCoordinates(ApparentRa(date), ApparentDec(date), lite.Date2JD(date.UTC()), lon, lat)
|
||||
return altitude
|
||||
}
|
||||
|
||||
@@ -89,7 +88,7 @@ func Zenith(date time.Time, lon, lat float64) float64 {
|
||||
|
||||
// RiseTime 轻量日出时刻 / lightweight sunrise time.
|
||||
func RiseTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error) {
|
||||
if result, err, handled := civiltime.Event(date, basic.ErrNotOnThisDate, func(d time.Time) (time.Time, error) {
|
||||
if result, err, handled := civiltime.Event(date, lite.ErrNotOnThisDate, func(d time.Time) (time.Time, error) {
|
||||
return RiseTime(d, lon, lat, height, aero)
|
||||
}); handled {
|
||||
return result, err
|
||||
@@ -99,7 +98,7 @@ func RiseTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, e
|
||||
|
||||
// SetTime 轻量日落时刻 / lightweight sunset time.
|
||||
func SetTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, error) {
|
||||
if result, err, handled := civiltime.Event(date, basic.ErrNotOnThisDate, func(d time.Time) (time.Time, error) {
|
||||
if result, err, handled := civiltime.Event(date, lite.ErrNotOnThisDate, func(d time.Time) (time.Time, error) {
|
||||
return SetTime(d, lon, lat, height, aero)
|
||||
}); handled {
|
||||
return result, err
|
||||
@@ -109,11 +108,11 @@ func SetTime(date time.Time, lon, lat, height float64, aero bool) (time.Time, er
|
||||
|
||||
func riseSetTime(date time.Time, lon, lat, height float64, aero, isRise bool) (time.Time, error) {
|
||||
localMidnight := time.Date(date.Year(), date.Month(), date.Day(), 0, 0, 0, 0, date.Location())
|
||||
localJD := basic.Date2JD(localMidnight)
|
||||
localJD := lite.Date2JD(localMidnight)
|
||||
_, offset := localMidnight.Zone()
|
||||
timezone := float64(offset) / 3600.0
|
||||
|
||||
horizonDip := basic.HeightDegreeByLat(height, lat)
|
||||
horizonDip := lite.HeightDegreeByLat(height, lat)
|
||||
|
||||
altitudeFn := func(localJD float64) float64 {
|
||||
utcJD := localJD - timezone/24.0
|
||||
@@ -121,7 +120,7 @@ func riseSetTime(date time.Time, lon, lat, height float64, aero, isRise bool) (t
|
||||
altitude, _, _ := lite.HorizontalCoordinates(ra, dec, utcJD, lon, lat)
|
||||
residual := altitude + horizonDip
|
||||
if aero {
|
||||
residual += basic.RefractionFromTrueAltitude(altitude, 1010, 10)
|
||||
residual += lite.RefractionFromTrueAltitude(altitude, 1010, 10)
|
||||
residual += liteSunSemidiameterDegrees(lite.SunDistanceAU(utcJD))
|
||||
}
|
||||
return residual
|
||||
@@ -138,7 +137,7 @@ func riseSetTime(date time.Time, lon, lat, height float64, aero, isRise bool) (t
|
||||
return time.Time{}, err
|
||||
}
|
||||
}
|
||||
return basic.JD2DateByZone(eventJD-timezone/24, date.Location(), false), nil
|
||||
return lite.JD2DateByZone(eventJD-timezone/24, date.Location(), false), nil
|
||||
}
|
||||
|
||||
func liteSunSemidiameterDegrees(distanceAU float64) float64 {
|
||||
|
||||
Reference in New Issue
Block a user