新增恒星相关计算

master
兔子 3 years ago
parent 7604fabf8f
commit bb07e23238
Signed by: b612
GPG Key ID: 481225A74DEB62A1

@ -17,10 +17,10 @@ func Benchmark_All(b *testing.B) {
func show() {
jde := GetNowJDE() - 1
ra := HSunSeeRa(jde - 8.0/24.0)
dec := HSunSeeDec(jde - 8.0/24.0)
ra := HSunApparentRa(jde - 8.0/24.0)
dec := HSunApparentDec(jde - 8.0/24.0)
fmt.Printf("当前JDE:%.14f\n", jde)
fmt.Println("当前太阳黄经:", HSunSeeLo(jde-8.0/24.0))
fmt.Println("当前太阳黄经:", HSunApparentLo(jde-8.0/24.0))
fmt.Println("当前太阳赤经:", ra)
fmt.Println("当前太阳赤纬:", dec)
fmt.Println("当前太阳星座:", WhichCst(ra, dec, jde))

@ -68,7 +68,7 @@ func ZhanXinRaDec(ra, dec, lat, lon, jd, au, h float64) (float64, float64) {
sinpi := Sin(0.0024427777777) / au
pcosi := pcosi(lat, h)
psini := psini(lat, h)
tH := Limit360(TD2UT(SeeStarTime(jd), false)*15 + lon - ra)
tH := Limit360(TD2UT(ApparentSiderealTime(jd), false)*15 + lon - ra)
nra := math.Atan2(-pcosi*sinpi*Sin(tH), (Cos(dec)-pcosi*sinpi*Cos(tH))) * 180 / math.Pi
ndec := math.Atan2((Sin(dec)-psini*sinpi)*Cos(nra), (Cos(dec)-pcosi*sinpi*Cos(tH))) * 180 / math.Pi
@ -78,7 +78,7 @@ func ZhanXinRaDec(ra, dec, lat, lon, jd, au, h float64) (float64, float64) {
func ZhanXinRa(ra, dec, lat, lon, jd, au, h float64) float64 { //jd为格林尼治标准时
sinpi := Sin(0.0024427777777) / au
pcosi := pcosi(lat, h)
tH := Limit360(TD2UT(SeeStarTime(jd), false)*15 + lon - ra)
tH := Limit360(TD2UT(ApparentSiderealTime(jd), false)*15 + lon - ra)
nra := math.Atan2(-pcosi*sinpi*Sin(tH), (Cos(dec)-pcosi*sinpi*Cos(tH))) * 180 / math.Pi
return ra + nra
}
@ -87,7 +87,7 @@ func ZhanXinDec(ra, dec, lat, lon, jd, au, h float64) float64 { //jd为格林尼
sinpi := Sin(0.0024427777777) / au
pcosi := pcosi(lat, h)
psini := psini(lat, h)
tH := Limit360(TD2UT(SeeStarTime(jd), false)*15 + lon - ra)
tH := Limit360(TD2UT(ApparentSiderealTime(jd), false)*15 + lon - ra)
nra := math.Atan2(-pcosi*sinpi*Sin(tH), (Cos(dec)-pcosi*sinpi*Cos(tH))) * 180 / math.Pi
ndec := math.Atan2((Sin(dec)-psini*sinpi)*Cos(nra), (Cos(dec)-pcosi*sinpi*Cos(tH))) * 180 / math.Pi
@ -99,7 +99,7 @@ func ZhanXinLo(lo, bo, lat, lon, jd, au, h float64) float64 { //jd为格林尼
S := psini(lat, h)
sinpi := Sin(0.0024427777777) / au
ra := LoToRa(lo, bo, jd)
tH := Limit360(TD2UT(SeeStarTime(jd), false)*15 + lon - ra)
tH := Limit360(TD2UT(ApparentSiderealTime(jd), false)*15 + lon - ra)
N := Cos(lo)*Cos(bo) - C*sinpi*Cos(tH)
nlo := math.Atan2(Sin(lo)*Cos(bo)-sinpi*(S*Sin(Sita(jd))+C*Cos(Sita(jd))*Sin(tH)), N) * 180 / math.Pi
return nlo
@ -110,7 +110,7 @@ func ZhanXinBo(lo, bo, lat, lon, jd, au, h float64) float64 { //jd为格林尼
S := psini(lat, h)
sinpi := Sin(0.0024427777777) / au
ra := LoToRa(lo, bo, jd)
tH := Limit360(TD2UT(SeeStarTime(jd), false)*15 + lon - ra)
tH := Limit360(TD2UT(ApparentSiderealTime(jd), false)*15 + lon - ra)
N := Cos(lo)*Cos(bo) - C*sinpi*Cos(tH)
nlo := math.Atan2(Sin(lo)*Cos(bo)-sinpi*(S*Sin(Sita(jd))+C*Cos(Sita(jd))*Sin(tH)), N) * 180 / math.Pi
nbo := math.Atan2(Cos(nlo)*(Sin(bo)-sinpi*(S*Cos(Sita(jd))-C*Sin(Sita(jd))*Sin(tH))), N) * 180 / math.Pi

@ -1033,7 +1033,7 @@ func MoonAway(JD float64) float64 { //'月地距离
/*
* @name
*/
func MoonSeeLo(JD float64) float64 {
func MoonApparentLo(JD float64) float64 {
return MoonTrueLo(JD) + HJZD(JD)
}
@ -1041,7 +1041,7 @@ func MoonSeeLo(JD float64) float64 {
*
*/
func MoonTrueDec(JD float64) float64 {
MoonLo := MoonSeeLo(JD)
MoonLo := MoonApparentLo(JD)
MoonBo := MoonTrueBo(JD)
tmp := Sin(MoonBo)*Cos(Sita(JD)) + Cos(MoonBo)*Sin(Sita(JD))*Sin(MoonLo)
res := ArcSin(tmp)
@ -1052,7 +1052,7 @@ func MoonTrueDec(JD float64) float64 {
*
*/
func MoonTrueRa(JD float64) float64 {
MoonLo := MoonSeeLo(JD)
MoonLo := MoonApparentLo(JD)
MoonBo := MoonTrueBo(JD)
tmp := (Sin(MoonLo)*Cos(Sita(JD)) - Tan(MoonBo)*Sin(Sita(JD))) / Cos(MoonLo)
tmp = ArcTan(tmp)
@ -1070,7 +1070,7 @@ func MoonTrueRa(JD float64) float64 {
*
*/
func MoonSeeRa(JD, lon, lat float64, tz int) float64 {
func MoonApparentRa(JD, lon, lat float64, tz int) float64 {
jde := TD2UT(JD, true)
ra := MoonTrueRa(jde - float64(tz)/24.000)
dec := MoonTrueDec(jde - float64(tz)/24.000)
@ -1079,7 +1079,7 @@ func MoonSeeRa(JD, lon, lat float64, tz int) float64 {
return nra
}
func MoonSeeDec(JD, lon, lat, tz float64) float64 {
func MoonApparentDec(JD, lon, lat, tz float64) float64 {
jde := TD2UT(JD, true)
ra := MoonTrueRa(jde - tz/24.0)
dec := MoonTrueDec(jde - tz/24)
@ -1090,8 +1090,8 @@ func MoonSeeDec(JD, lon, lat, tz float64) float64 {
func MoonLight(JD float64) float64 {
MoonBo := HMoonTrueBo(JD)
SunLo := HSunSeeLo(JD)
MoonLo := HMoonSeeLo(JD)
SunLo := HSunApparentLo(JD)
MoonLo := HMoonApparentLo(JD)
tmp := Cos(MoonBo) * Cos(SunLo-MoonLo)
R := RDJL(JD) * 149597870.691
i := R * Sin(ArcCos(tmp)) / (HMoonAway(JD) - R*tmp)
@ -1107,7 +1107,7 @@ func MoonLight(JD float64) float64 {
}
func SunMoonSeek(JDE float64, degree float64) float64 {
p := HMoonSeeLo(JDE) - (HSunSeeLo(JDE)) - degree
p := HMoonApparentLo(JDE) - (HSunApparentLo(JDE)) - degree
for p < -180 {
p += 360
}
@ -1303,7 +1303,7 @@ func MoonAngle(JD, Lon, Lat, TZ float64) float64 {
ndec := ZhanXinDec(ra, dec, Lat, Lon, JD-TZ/24, away, 0)
nra := ZhanXinRa(ra, dec, Lat, Lon, JD-TZ/24, away, 0)
calcjd = JD - TZ/24
st := Limit360(SeeStarTime(calcjd)*15 + Lon)
st := Limit360(ApparentSiderealTime(calcjd)*15 + Lon)
H := Limit360(st - nra)
tmp2 := Sin(H) / (Cos(H)*Sin(Lat) - Tan(ndec)*Cos(Lat))
Angle := ArcTan(tmp2)
@ -1333,7 +1333,7 @@ func MoonHeight(JD, Lon, Lat, TZ float64) float64 {
ndec := ZhanXinDec(ra, dec, Lat, Lon, JD-TZ/24, away, 0)
nra := ZhanXinRa(ra, dec, Lat, Lon, JD-TZ/24, away, 0)
calcjd = JD - TZ/24
st := Limit360(SeeStarTime(calcjd)*15 + Lon)
st := Limit360(ApparentSiderealTime(calcjd)*15 + Lon)
H := Limit360(st - nra)
tmp2 := Sin(Lat)*Sin(ndec) + Cos(ndec)*Cos(Lat)*Cos(H)
return ArcSin(tmp2)
@ -1349,7 +1349,7 @@ func HMoonAngle(JD, Lon, Lat, TZ float64) float64 {
ndec := ZhanXinDec(ra, dec, Lat, Lon, JD-TZ/24, away, 0)
nra := ZhanXinRa(ra, dec, Lat, Lon, JD-TZ/24, away, 0)
calcjd = JD - TZ/24
st := Limit360(SeeStarTime(calcjd)*15 + Lon)
st := Limit360(ApparentSiderealTime(calcjd)*15 + Lon)
H := Limit360(st - nra)
tmp2 := Sin(H) / (Cos(H)*Sin(Lat) - Tan(ndec)*Cos(Lat))
Angle := ArcTan(tmp2)
@ -1376,7 +1376,7 @@ func HMoonHeight(JD, Lon, Lat, TZ float64) float64 {
away := HMoonAway(calcjd) / 149597870.7
nra, ndec := ZhanXinRaDec(ra, dec, Lat, Lon, calcjd, away, 0)
calcjd = JD - TZ/24
st := Limit360(SeeStarTime(calcjd)*15 + Lon)
st := Limit360(ApparentSiderealTime(calcjd)*15 + Lon)
H := Limit360(st - nra)
tmp2 := Sin(Lat)*Sin(ndec) + Cos(ndec)*Cos(Lat)*Cos(H)
return ArcSin(tmp2)
@ -1402,8 +1402,8 @@ func GetMoonTZTime(JD, Lon, Lat, TZ float64) float64 { //实际中天时间{
}
func MoonTimeAngle(JD, Lon, Lat, TZ float64) float64 {
startime := Limit360(SeeStarTime(JD-TZ/24)*15 + Lon)
timeangle := startime - HMoonSeeRa(JD-TZ/24, Lon, Lat, TZ)
startime := Limit360(ApparentSiderealTime(JD-TZ/24)*15 + Lon)
timeangle := startime - HMoonApparentRa(JD-TZ/24, Lon, Lat, TZ)
if timeangle < 0 {
timeangle += 360
}
@ -1458,7 +1458,7 @@ func GetMoonRiseTime(JD, Lon, Lat, TZ, ZS, HEI float64) float64 {
return -2 //沉
}
}
dec := MoonSeeDec(JD1, Lon, Lat, TZ)
dec := MoonApparentDec(JD1, Lon, Lat, TZ)
tmp := (Sin(An) - Sin(dec)*Sin(Lat)) / (Cos(dec) * Cos(Lat))
if math.Abs(tmp) <= 1 && Lat < 85 {
SJ := (180 - ArcCos(tmp)) / 15
@ -1536,7 +1536,7 @@ func GetMoonDownTime(JD, Lon, Lat, TZ, ZS, HEI float64) float64 {
return -1 //拱
}
}
dec := MoonSeeDec(JD1, Lon, Lat, TZ)
dec := MoonApparentDec(JD1, Lon, Lat, TZ)
tmp := (Sin(An) - Sin(dec)*Sin(Lat)) / (Cos(dec) * Cos(Lat))
if math.Abs(tmp) <= 1 && Lat < 85 {
SJ := (ArcCos(tmp)) / 15.0
@ -1662,12 +1662,12 @@ func HMoonAway(JD float64) float64 { //'月地距离
/*
* @name
*/
func HMoonSeeLo(JD float64) float64 {
func HMoonApparentLo(JD float64) float64 {
return HMoonTrueLo(JD) + HJZD(JD)
}
func HMoonTrueRaDec(JD float64) (float64, float64) {
MoonLo := HMoonSeeLo(JD)
MoonLo := HMoonApparentLo(JD)
MoonBo := HMoonTrueBo(JD)
tmp := Sin(MoonBo)*Cos(Sita(JD)) + Cos(MoonBo)*Sin(Sita(JD))*Sin(MoonLo)
res := ArcSin(tmp)
@ -1687,7 +1687,7 @@ func HMoonTrueRaDec(JD float64) (float64, float64) {
*
*/
func HMoonTrueDec(JD float64) float64 {
MoonLo := HMoonSeeLo(JD)
MoonLo := HMoonApparentLo(JD)
MoonBo := HMoonTrueBo(JD)
tmp := Sin(MoonBo)*Cos(Sita(JD)) + Cos(MoonBo)*Sin(Sita(JD))*Sin(MoonLo)
res := ArcSin(tmp)
@ -1698,7 +1698,7 @@ func HMoonTrueDec(JD float64) float64 {
*
*/
func HMoonTrueRa(JD float64) float64 {
MoonLo := HMoonSeeLo(JD)
MoonLo := HMoonApparentLo(JD)
MoonBo := HMoonTrueBo(JD)
tmp := (Sin(MoonLo)*Cos(Sita(JD)) - Tan(MoonBo)*Sin(Sita(JD))) / Cos(MoonLo)
tmp = ArcTan(tmp)
@ -1716,7 +1716,7 @@ func HMoonTrueRa(JD float64) float64 {
*
*/
func HMoonSeeRaDec(JD, lon, lat, tz float64) (float64, float64) {
func HMoonApparentRaDec(JD, lon, lat, tz float64) (float64, float64) {
jde := TD2UT(JD, true)
ra := HMoonTrueRa(jde - tz/24)
dec := HMoonTrueDec(jde - tz/24)
@ -1725,7 +1725,7 @@ func HMoonSeeRaDec(JD, lon, lat, tz float64) (float64, float64) {
return nra, ndec
}
func HMoonSeeRa(JD, lon, lat, tz float64) float64 {
func HMoonApparentRa(JD, lon, lat, tz float64) float64 {
jde := TD2UT(JD, true)
ra := HMoonTrueRa(jde - tz/24)
dec := HMoonTrueDec(jde - tz/24)
@ -1733,7 +1733,7 @@ func HMoonSeeRa(JD, lon, lat, tz float64) float64 {
nra := ZhanXinRa(ra, dec, lat, lon, JD-tz/24, away, 0)
return nra
}
func HMoonSeeDec(JD, lon, lat, tz float64) float64 {
func HMoonApparentDec(JD, lon, lat, tz float64) float64 {
jde := TD2UT(JD, true)
ra := HMoonTrueRa(jde - tz/24)
dec := HMoonTrueDec(jde - tz/24)

@ -9,7 +9,7 @@ import (
func Benchmark_MoonRiseBench(b *testing.B) {
jde := GetNowJDE()
for i := 0; i < b.N; i++ {
GetMoonRiseTime(jde, 115, 32, 8, 0, 10)
GetMoonRiseTime(jde, 105, 40, 8, 0, 10)
}
}
@ -30,7 +30,7 @@ func Test_MoonRise(t *testing.T) {
//jde := Date2JDE(time.Date(2023, 2, 9, 15, 59, 0, 0, cst))
fmt.Println(GetMoonRiseTime(2.4599846948519214e+06, 113.58880556, 87.36833333, 8, 0, 0))
for i := 30.0; i < 90.0; i += 0.3 {
fmt.Println(i, GetMoonRiseTime(2.459984692085961e+06, 113.588, float64(i), 8, 0, 0))
fmt.Println(i, GetMoonRiseTime(2.459984692085961e+06, 117.76653567, float64(i), 8, 0, 0))
}
}
@ -38,7 +38,7 @@ func Test_MoonS(t *testing.T) {
//fmt.Println(Sita(2451547))
//fmt.Println(MoonHeight(2451547, 115, 32, 8))
a := time.Now().UnixNano()
b := GetMoonRiseTime(GetNowJDE(), 115, 32, 8, 0, 10)
b := GetMoonRiseTime(GetNowJDE(), 123, 40, 8, 0, 10)
fmt.Println(HMoonHeight(b, 115, 32, 8))
fmt.Println(time.Now().UnixNano() - a)
fmt.Println(JDE2Date((b)))

@ -12,7 +12,7 @@ func StarHeight(jde, ra, dec, lon, lat, timezone float64) float64 {
// 转换为世界时
utcJde := jde - timezone/24.0
// 计算视恒星时
st := Limit360(SeeStarTime(utcJde)*15 + lon)
st := Limit360(ApparentSiderealTime(utcJde)*15 + lon)
// 计算时角
H := Limit360(st - ra)
// 高度角、时角与天球座标三角转换公式
@ -28,7 +28,7 @@ func StarAzimuth(jde, ra, dec, lon, lat, timezone float64) float64 {
// 转换为世界时
utcJde := jde - timezone/24.0
// 计算视恒星时
st := Limit360(SeeStarTime(utcJde)*15 + lon)
st := Limit360(ApparentSiderealTime(utcJde)*15 + lon)
// 计算时角
H := Limit360(st - ra)
// 三角转换公式
@ -53,26 +53,26 @@ func StarHourAngle(jde, ra, lon, timezone float64) float64 {
// 转换为世界时
utcJde := jde - timezone/24.0
// 计算视恒星时
st := Limit360(SeeStarTime(utcJde)*15 + lon)
st := Limit360(ApparentSiderealTime(utcJde)*15 + lon)
// 计算时角
return Limit360(st - ra)
}
// TrueStarTime 不含章动下的恒星时
func TrueStarTime(JD float64) float64 {
// MeanSiderealTime 不含章动下的恒星时
func MeanSiderealTime(JD float64) float64 {
T := (JD - 2451545) / 36525
return (Limit360(280.46061837+360.98564736629*(JD-2451545.0)+0.000387933*T*T-T*T*T/38710000) / 15)
}
// SeeStarTime 视恒星时,计算章动
func SeeStarTime(JD float64) float64 {
tmp := TrueStarTime(JD)
// ApparentSiderealTime 视恒星时,计算章动
func ApparentSiderealTime(JD float64) float64 {
tmp := MeanSiderealTime(JD)
return tmp + HJZD(JD)*Cos(Sita(JD))/15
}
func StarAngle(RA, DEC, JD, Lon, Lat, TZ float64) float64 {
//JD=JD-8/24+TZ/24;
calcjd := JD - TZ/24
st := Limit360(SeeStarTime(calcjd)*15 + Lon)
st := Limit360(ApparentSiderealTime(calcjd)*15 + Lon)
H := Limit360(st - RA)
tmp2 := Sin(H) / (Cos(H)*Sin(Lat) - Tan(DEC)*Cos(Lat))
Angle := ArcTan(tmp2)

@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"strconv"
"time"
)
// this file contains bright 9100 stars
@ -131,7 +132,7 @@ func parseDec(star []byte) (float64, error) {
}
minute = minute*10 + (star[i] - 48)
}
ori := string(bytes.TrimSpace(star[79:83]))
ori := string(bytes.TrimSpace(star[88:90]))
if ori != "" {
sec, err = strconv.ParseFloat(ori, 64)
if err != nil {
@ -9276,3 +9277,14 @@ func StarDataByHR(hr int) (StarData, error) {
data, err := parseStarData(stardat[hr-1])
return StarData{starData: data}, err
}
func (s starData) RaDecByJde(jde float64) (float64, float64) {
//计算自行
year := ((jde - 2451545.0) / 365.2422)
return ZuoBiaoSuiCha(s.Ra+(year*s.PmRA/3600), s.Dec+(year*s.PmDec/3600), 2451545.0, jde)
}
func (s StarData) RaDecByDate(date time.Time) (float64, float64) {
jde := Date2JDE(date.UTC())
return s.RaDecByJde(jde)
}

@ -1,6 +1,8 @@
package basic
import (
. "b612.me/astro/tools"
"fmt"
"testing"
)
@ -18,3 +20,18 @@ func Test_ParseStar(t *testing.T) {
}
}
func TestGetRaDecByDate(t *testing.T) {
err := LoadStarData()
if err != nil {
t.Fatal(err)
}
sirius, err := StarDataByHR(2491)
if err != nil {
t.Fatal(err)
}
fmt.Println(Format(sirius.Ra/15, 1), Format(sirius.Dec, 0))
now := GetNowJDE()
ra, dec := sirius.RaDecByJde(now)
fmt.Println(Format(ra/15, 1), Format(dec, 0))
}

@ -830,26 +830,26 @@ func SunTrueLo(JD float64) float64 { // '太阳真黄经
return SunTrueLo
}
func SunSeeLo(JD float64) float64 { //'太阳视黄经
func SunApparentLo(JD float64) float64 { //'太阳视黄经
T := (JD - 2451545) / 36525
SunSeeLo := SunTrueLo(JD) - 0.00569 - 0.00478*Sin(125.04-1934.136*T)
return SunSeeLo
SunApparentLo := SunTrueLo(JD) - 0.00569 - 0.00478*Sin(125.04-1934.136*T)
return SunApparentLo
}
func SunSeeRa(JD float64) float64 { // '太阳视赤经
func SunApparentRa(JD float64) float64 { // '太阳视赤经
T := (JD - 2451545) / 36525
sitas := Sita(JD) + 0.00256*Cos(125.04-1934.136*T)
SunSeeRa := ArcTan(Cos(sitas) * Sin(SunSeeLo(JD)) / Cos(SunSeeLo(JD)))
tmp := SunSeeLo(JD)
SunApparentRa := ArcTan(Cos(sitas) * Sin(SunApparentLo(JD)) / Cos(SunApparentLo(JD)))
tmp := SunApparentLo(JD)
if tmp >= 90 && tmp < 180 {
SunSeeRa = 180 + SunSeeRa
SunApparentRa = 180 + SunApparentRa
} else if tmp >= 180 && tmp < 270 {
SunSeeRa = 180 + SunSeeRa
SunApparentRa = 180 + SunApparentRa
} else if tmp >= 270 && tmp <= 360 {
SunSeeRa = 360 + SunSeeRa
SunApparentRa = 360 + SunApparentRa
}
return SunSeeRa
return SunApparentRa
}
func SunTrueRa(JD float64) float64 { //'太阳真赤经
@ -868,11 +868,11 @@ func SunTrueRa(JD float64) float64 { //'太阳真赤经
return SunTrueRa
}
func SunSeeDec(JD float64) float64 { // '太阳视赤纬
func SunApparentDec(JD float64) float64 { // '太阳视赤纬
T := (JD - 2451545) / 36525
sitas := Sita(JD) + 0.00256*Cos(125.04-1934.136*T)
SunSeeDec := ArcSin(Sin(sitas) * Sin(SunSeeLo(JD)))
return SunSeeDec
SunApparentDec := ArcSin(Sin(sitas) * Sin(SunApparentLo(JD)))
return SunApparentDec
}
func SunTrueDec(JD float64) float64 { // '太阳真赤纬
@ -882,7 +882,7 @@ func SunTrueDec(JD float64) float64 { // '太阳真赤纬
}
func SunTime(JD float64) float64 { //均时差
tm := (SunLo(JD) - 0.0057183 - (HSunSeeRa(JD)) + (HJZD(JD))*Cos(Sita(JD))) / 15
tm := (SunLo(JD) - 0.0057183 - (HSunApparentRa(JD)) + (HJZD(JD))*Cos(Sita(JD))) / 15
if tm > 23 {
tm = -24 + tm
}
@ -908,7 +908,7 @@ func HSunTrueBo(JD float64) float64 {
return L
}
func HSunSeeLo(JD float64) float64 {
func HSunApparentLo(JD float64) float64 {
L := HSunTrueLo(JD)
/*
t := (JD - 2451545) / 365250.0
@ -933,36 +933,36 @@ func EarthAway(JD float64) float64 {
return planet.WherePlanet(0, 2, JD)
}
func HSunSeeRaDec(JD float64) (float64, float64) {
func HSunApparentRaDec(JD float64) (float64, float64) {
T := (JD - 2451545) / 36525
sitas := Sita(JD) + 0.00256*Cos(125.04-1934.136*T)
sitas2 := EclipticObliquity(JD, false) + 0.00256*Cos(125.04-1934.136*T)
tmp := HSunSeeLo(JD)
HSunSeeRa := ArcTan(Cos(sitas) * Sin(tmp) / Cos(tmp))
HSunSeeDec := ArcSin(Sin(sitas2) * Sin(tmp))
tmp := HSunApparentLo(JD)
HSunApparentRa := ArcTan(Cos(sitas) * Sin(tmp) / Cos(tmp))
HSunApparentDec := ArcSin(Sin(sitas2) * Sin(tmp))
if tmp >= 90 && tmp < 180 {
HSunSeeRa = 180 + HSunSeeRa
HSunApparentRa = 180 + HSunApparentRa
} else if tmp >= 180 && tmp < 270 {
HSunSeeRa = 180 + HSunSeeRa
HSunApparentRa = 180 + HSunApparentRa
} else if tmp >= 270 && tmp <= 360 {
HSunSeeRa = 360 + HSunSeeRa
HSunApparentRa = 360 + HSunApparentRa
}
return HSunSeeRa, HSunSeeDec
return HSunApparentRa, HSunApparentDec
}
func HSunSeeRa(JD float64) float64 { // '太阳视赤经
func HSunApparentRa(JD float64) float64 { // '太阳视赤经
T := (JD - 2451545) / 36525
sitas := Sita(JD) + 0.00256*Cos(125.04-1934.136*T)
tmp := HSunSeeLo(JD)
HSunSeeRa := ArcTan(Cos(sitas) * Sin(tmp) / Cos(tmp))
tmp := HSunApparentLo(JD)
HSunApparentRa := ArcTan(Cos(sitas) * Sin(tmp) / Cos(tmp))
if tmp >= 90 && tmp < 180 {
HSunSeeRa = 180 + HSunSeeRa
HSunApparentRa = 180 + HSunApparentRa
} else if tmp >= 180 && tmp < 270 {
HSunSeeRa = 180 + HSunSeeRa
HSunApparentRa = 180 + HSunApparentRa
} else if tmp >= 270 && tmp <= 360 {
HSunSeeRa = 360 + HSunSeeRa
HSunApparentRa = 360 + HSunApparentRa
}
return HSunSeeRa
return HSunApparentRa
}
func HSunTrueRa(JD float64) float64 { //'太阳真赤经
@ -980,11 +980,11 @@ func HSunTrueRa(JD float64) float64 { //'太阳真赤经
return HSunTrueRa
}
func HSunSeeDec(JD float64) float64 { // '太阳视赤纬
func HSunApparentDec(JD float64) float64 { // '太阳视赤纬
T := (JD - 2451545) / 36525
sitas := EclipticObliquity(JD, false) + 0.00256*Cos(125.04-1934.136*T)
HSunSeeDec := ArcSin(Sin(sitas) * Sin(HSunSeeLo(JD)))
return HSunSeeDec
HSunApparentDec := ArcSin(Sin(sitas) * Sin(HSunApparentLo(JD)))
return HSunApparentDec
}
func HSunTrueDec(JD float64) float64 { // '太阳真赤纬
@ -1089,7 +1089,7 @@ func GetJQTime(Year, Angle int) float64 { //节气时间
}
func JQLospec(JD float64) float64 {
t := HSunSeeLo(JD)
t := HSunApparentLo(JD)
if t <= 12 {
t += 360
}
@ -1097,7 +1097,7 @@ func JQLospec(JD float64) float64 {
}
func GetXC(jd float64) string { //十二次
tlo := HSunSeeLo(jd)
tlo := HSunApparentLo(jd)
if tlo >= 255 && tlo < 285 {
return "星纪"
} else if tlo >= 285 && tlo < 315 {
@ -1185,7 +1185,7 @@ func GetBanTime(JD, Lon, Lat, TZ, An float64) float64 {
if SunHeight(tztime+0.5, Lon, Lat, ntz) > An {
return -1 //极昼
}
tmp := (Sin(An) - Sin(HSunSeeDec(tztime))*Sin(Lat)) / (Cos(HSunSeeDec(tztime)) * Cos(Lat))
tmp := (Sin(An) - Sin(HSunApparentDec(tztime))*Sin(Lat)) / (Cos(HSunApparentDec(tztime)) * Cos(Lat))
var sundown float64
if math.Abs(tmp) <= 1 && Lat < 85 {
rzsc := ArcCos(tmp) / 15
@ -1224,7 +1224,7 @@ func GetAsaTime(JD, Lon, Lat, TZ, An float64) float64 {
if SunHeight(tztime-0.5, Lon, Lat, ntz) > An {
return -1 //极昼
}
tmp := (Sin(An) - Sin(HSunSeeDec(tztime))*Sin(Lat)) / (Cos(HSunSeeDec(tztime)) * Cos(Lat))
tmp := (Sin(An) - Sin(HSunApparentDec(tztime))*Sin(Lat)) / (Cos(HSunApparentDec(tztime)) * Cos(Lat))
var sunrise float64
if math.Abs(tmp) <= 1 && Lat < 85 {
rzsc := ArcCos(tmp) / 15
@ -1257,8 +1257,8 @@ func GetAsaTime(JD, Lon, Lat, TZ, An float64) float64 {
*
*/
func SunTimeAngle(JD, Lon, Lat, TZ float64) float64 {
startime := Limit360(SeeStarTime(JD-TZ/24)*15 + Lon)
timeangle := startime - HSunSeeRa(TD2UT(JD-TZ/24, true))
startime := Limit360(ApparentSiderealTime(JD-TZ/24)*15 + Lon)
timeangle := startime - HSunApparentRa(TD2UT(JD-TZ/24, true))
if timeangle < 0 {
timeangle += 360
}
@ -1284,7 +1284,7 @@ func GetSunRiseTime(JD, Lon, Lat, TZ, ZS, HEI float64) float64 {
return -1 //极昼
}
//(sin(ho)-sin(φ)*sin(δ2))/(cos(φ)*cos(δ2))
tmp := (Sin(An) - Sin(HSunSeeDec(tztime))*Sin(Lat)) / (Cos(HSunSeeDec(tztime)) * Cos(Lat))
tmp := (Sin(An) - Sin(HSunApparentDec(tztime))*Sin(Lat)) / (Cos(HSunApparentDec(tztime)) * Cos(Lat))
var sunrise float64
if math.Abs(tmp) <= 1 && Lat < 85 {
rzsc := ArcCos(tmp) / 15
@ -1328,7 +1328,7 @@ func GetSunDownTime(JD, Lon, Lat, TZ, ZS, HEI float64) float64 {
if SunHeight(tztime+0.5, Lon, Lat, ntz) > An {
return -1 //极昼
}
tmp := (Sin(An) - Sin(HSunSeeDec(tztime))*Sin(Lat)) / (Cos(HSunSeeDec(tztime)) * Cos(Lat))
tmp := (Sin(An) - Sin(HSunApparentDec(tztime))*Sin(Lat)) / (Cos(HSunApparentDec(tztime)) * Cos(Lat))
var sundown float64
if math.Abs(tmp) <= 1 && Lat < 85 {
rzsc := ArcCos(tmp) / 15
@ -1365,8 +1365,8 @@ func SunHeight(JD, Lon, Lat, TZ float64) float64 {
//truejd := JD - tmp/24
calcjd := JD - TZ/24.0
tjde := TD2UT(calcjd, true)
st := Limit360(SeeStarTime(calcjd)*15 + Lon)
ra, dec := HSunSeeRaDec(tjde)
st := Limit360(ApparentSiderealTime(calcjd)*15 + Lon)
ra, dec := HSunApparentRaDec(tjde)
H := Limit360(st - ra)
tmp2 := Sin(Lat)*Sin(dec) + Cos(dec)*Cos(Lat)*Cos(H)
return ArcSin(tmp2)
@ -1375,9 +1375,9 @@ func LowSunHeight(JD, Lon, Lat, TZ float64) float64 {
//tmp := (TZ*15 - Lon) * 4 / 60
//truejd := JD - tmp/24
calcjd := JD - TZ/24
st := Limit360(SeeStarTime(calcjd)*15 + Lon)
H := Limit360(st - SunSeeRa(TD2UT(calcjd, true)))
dec := SunSeeDec(TD2UT(calcjd, true))
st := Limit360(ApparentSiderealTime(calcjd)*15 + Lon)
H := Limit360(st - SunApparentRa(TD2UT(calcjd, true)))
dec := SunApparentDec(TD2UT(calcjd, true))
tmp2 := Sin(Lat)*Sin(dec) + Cos(dec)*Cos(Lat)*Cos(H)
return ArcSin(tmp2)
}
@ -1385,9 +1385,9 @@ func SunAngle(JD, Lon, Lat, TZ float64) float64 {
//tmp := (TZ*15 - Lon) * 4 / 60
//truejd := JD - tmp/24
calcjd := JD - TZ/24
st := Limit360(SeeStarTime(calcjd)*15 + Lon)
H := Limit360(st - HSunSeeRa(TD2UT(calcjd, true)))
tmp2 := Sin(H) / (Cos(H)*Sin(Lat) - Tan(HSunSeeDec(TD2UT(calcjd, true)))*Cos(Lat))
st := Limit360(ApparentSiderealTime(calcjd)*15 + Lon)
H := Limit360(st - HSunApparentRa(TD2UT(calcjd, true)))
tmp2 := Sin(H) / (Cos(H)*Sin(Lat) - Tan(HSunApparentDec(TD2UT(calcjd, true)))*Cos(Lat))
Angle := ArcTan(tmp2)
if Angle < 0 {
if H/15 < 12 {

@ -14,12 +14,12 @@ func Test_Jq(t *testing.T) {
//fmt.Println(JDE2Date(GetWHTime(2019, 10)))
//fmt.Println(JDE2Date(GetJQTime(2020, 0)))
//date := TD2UT(GetJQTime(2020, 0), true)
//fmt.Println(HSunSeeLo(date))
//fmt.Println(HSunApparentLo(date))
}
func Test_SunLo(t *testing.T) {
fmt.Printf("%.14f\n", HSunTrueLo(2458840.0134162))
fmt.Printf("%.14f", HSunSeeLo(2458840.0134162))
fmt.Printf("%.14f", HSunApparentLo(2458840.0134162))
}
func Benchmark_SunRise(b *testing.B) {
@ -35,7 +35,7 @@ func Benchmark_SunLo(b *testing.B) {
jde := GetNowJDE()
for i := 0; i < b.N; i++ {
//GetNowJDE()
HSunSeeLo(jde)
HSunApparentLo(jde)
}
}
@ -51,16 +51,16 @@ func Test_Cal(t *testing.T) {
func Test_SunRise(t *testing.T) {
a := time.Now().UnixNano()
//b := GetSunRiseTime(GetNowJDE(), 115, 32, 8, 0)
//b = GetSunRiseTime(GetNowJDE()+1, 115, 32, 8, 0)
//b = GetSunRiseTime(GetNowJDE()+2, 115, 32, 8, 0)
//b = GetSunRiseTime(GetNowJDE()+3, 115, 32, 8, 0)
//b = GetSunRiseTime(GetNowJDE()+4, 115, 32, 8, 0)
//b = GetSunRiseTime(GetNowJDE()+5, 115, 32, 8, 0)
//b = GetSunRiseTime(GetNowJDE()+6, 115, 32, 8, 0)
//b = GetSunRiseTime(GetNowJDE()+7, 115, 32, 8, 0)
//b := GetSunRiseTime(GetNowJDE(), 120, 32, 8, 0)
//b = GetSunRiseTime(GetNowJDE()+1, 145, 32, 8, 0)
//b = GetSunRiseTime(GetNowJDE()+2, 135, 50, 8, 0)
//b = GetSunRiseTime(GetNowJDE()+3, 125, 32, 8, 0)
//b = GetSunRiseTime(GetNowJDE()+4, 75, 32, 8, 0)
//b = GetSunRiseTime(GetNowJDE()+5, 85, 32, 8, 0)
//b = GetSunRiseTime(GetNowJDE()+6, 95, 32, 8, 0)
//b = GetSunRiseTime(GetNowJDE()+7, 105, 32, 8, 0)
//b = GetSunRiseTime(GetNowJDE()+8, 115, 32, 8, 0)
b := GetSunRiseTime(GetNowJDE()+9, 115, 32, 8, 0, 10)
b := GetSunRiseTime(GetNowJDE()+9, 125, 32, 8, 0, 10)
fmt.Println(time.Now().UnixNano() - a)
fmt.Println(SunHeight(b, 115, 32, 8))
fmt.Println(JDE2Date((b)))
@ -73,7 +73,7 @@ func Test_SunTwilightMo(t *testing.T) {
fmt.Println(GetAsaTime(jde, 113.58880556, 87.66833333, 8, -6))
for i := 10.0; i < 90.0; i += 0.3 {
fmt.Println(i, GetAsaTime(jde, 113.5880556, float64(i), 8, -6))
fmt.Println(i, GetAsaTime(jde, 125.45506654, float64(i), 8, -6))
}
}

@ -26,44 +26,68 @@ func TrueBo(date time.Time) float64 {
return basic.HMoonTrueBo(basic.TD2UT(jde, true))
}
// SeeLo 月亮视黄经(地心)
// ApparentLo 月亮视黄经(地心)
// 传入UTC对应的儒略日时间
func SeeLo(date time.Time) float64 {
func ApparentLo(date time.Time) float64 {
jde := basic.Date2JDE(date.UTC())
return basic.HMoonSeeLo(basic.TD2UT(jde, true))
return basic.HMoonApparentLo(basic.TD2UT(jde, true))
}
// SeeRa 月亮视赤经(站心)
// TrueRa 月亮视赤经(地心)
// date, 时间
// 返回地心坐标
func TrueRa(date time.Time) float64 {
jde := basic.Date2JDE(date.UTC())
return basic.HMoonTrueRa(basic.TD2UT(jde, true))
}
// TrueDec 月亮视赤纬(地心)
// date, 时间
// 返回地心坐标
func TrueDec(date time.Time) float64 {
jde := basic.Date2JDE(date.UTC())
return basic.HMoonTrueDec(basic.TD2UT(jde, true))
}
// TrueRaDec 月亮视赤纬赤纬(地心)
// date, 时间
// 返回地心坐标
func TrueRaDec(date time.Time) (float64, float64) {
jde := basic.Date2JDE(date.UTC())
return basic.HMoonTrueRaDec(basic.TD2UT(jde, true))
}
// ApparentRa 月亮视赤经(站心)
// date, 时间
// lon, 经度
// lat, 纬度
// 返回站心坐标
func SeeRa(date time.Time, lon, lat float64) float64 {
func ApparentRa(date time.Time, lon, lat float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
return basic.HMoonSeeRa(jde, lon, lat, float64(loc)/3600.0)
return basic.HMoonApparentRa(jde, lon, lat, float64(loc)/3600.0)
}
// SeeDec 月亮视赤纬(站心)
// ApparentDec 月亮视赤纬(站心)
// date, 时间
// lon, 经度
// lat, 纬度
// 返回站心坐标
func SeeDec(date time.Time, lon, lat float64) float64 {
func ApparentDec(date time.Time, lon, lat float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
return basic.HMoonSeeDec(jde, lon, lat, float64(loc)/3600.0)
return basic.HMoonApparentDec(jde, lon, lat, float64(loc)/3600.0)
}
// SeeRaDec 月亮视赤纬(站心)
// ApparentRaDec 月亮视赤纬(站心)
// date, 本地时间
// lon, 经度
// lat, 纬度
// 返回站心坐标
func SeeRaDec(date time.Time, lon, lat float64) (float64, float64) {
func ApparentRaDec(date time.Time, lon, lat float64) (float64, float64) {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
return basic.HMoonSeeRaDec(jde, lon, lat, float64(loc)/3600.0)
return basic.HMoonApparentRaDec(jde, lon, lat, float64(loc)/3600.0)
}
// HourAngle 月亮时角
@ -214,7 +238,7 @@ func nextMoonPhase(date time.Time, typed int) time.Time {
diffCode = 270
}
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
cost := basic.HMoonSeeLo(jde) - basic.HSunSeeLo(jde) - float64(diffCode)
cost := basic.HMoonApparentLo(jde) - basic.HSunApparentLo(jde) - float64(diffCode)
for cost < 0 {
cost += 360
}
@ -242,7 +266,7 @@ func lastMoonPhase(date time.Time, typed int) time.Time {
diffCode = 270
}
jde := basic.TD2UT(basic.Date2JDE(date.UTC()), true)
cost := basic.HMoonSeeLo(jde) - basic.HSunSeeLo(jde) - float64(diffCode)
cost := basic.HMoonApparentLo(jde) - basic.HSunApparentLo(jde) - float64(diffCode)
for cost < 0 {
cost += 360
}

@ -52,3 +52,10 @@ func Test_MoonPhaseDate(t *testing.T) {
fmt.Println("上一朔月", moonPhase01)
}
}
func TestMoon(t *testing.T) {
now := time.Now()
fmt.Println(RiseTime(now, 115, 40, 0, true))
fmt.Println(CulminationTime(now, 115, 40))
fmt.Println(DownTime(now, 115, 40, 0, true))
}

@ -1,14 +1,133 @@
package star
import (
"errors"
"math"
"time"
"b612.me/astro/basic"
)
var (
ERR_STAR_NEVER_RISE = errors.New("ERROR:极夜,星星在今日永远在地平线下!")
ERR_STAR_NEVER_DOWN = errors.New("ERROR:极昼,星星在今日永远在地平线上!")
)
// Constellation
// 计算date对应UTC世界时给定Date坐标赤经、赤纬所在的星座
func Constellation(ra, dec float64, date time.Time) string {
jde := basic.Date2JDE(date.UTC())
return basic.WhichCst(ra, dec, jde)
}
//MeanSiderealTime UTC 平恒星时
func MeanSiderealTime(date time.Time) float64 {
return basic.MeanSiderealTime(basic.Date2JDE(date.UTC()))
}
// ApparentSiderealTime UTC真恒星时
func ApparentSiderealTime(date time.Time) float64 {
return basic.ApparentSiderealTime(basic.Date2JDE(date.UTC()))
}
// RiseTime 星星升起时间
// date, 世界时(忽略此处时区)
// raDate瞬时赤经
// decDate瞬时赤纬
// lon经度东正西负
// lat纬度北正南负
// height高度
// aero,是否进行大气修正
func RiseTime(date time.Time, ra, dec, lon, lat, height float64, aero bool) (time.Time, error) {
var err error
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
riseJde := basic.StarRiseTime(jde, ra, dec, lon, lat, height, timezone, aero)
if riseJde == -2 {
err = ERR_STAR_NEVER_RISE
}
if riseJde == -1 {
err = ERR_STAR_NEVER_DOWN
}
return basic.JDE2DateByZone(riseJde, date.Location(), true), err
}
// DownTime 星星升起时间
// date, 世界时(忽略此处时区)
// raDate瞬时赤经
// decDate瞬时赤纬
// lon经度东正西负
// lat纬度北正南负
// height高度
// aero,是否进行大气修正
func DownTime(date time.Time, ra, dec, lon, lat, height float64, aero bool) (time.Time, error) {
var err error
if date.Hour() > 12 {
date = date.Add(time.Hour * -12)
}
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
riseJde := basic.StarDownTime(jde, ra, dec, lon, lat, height, timezone, aero)
if riseJde == -2 {
err = ERR_STAR_NEVER_RISE
}
if riseJde == -1 {
err = ERR_STAR_NEVER_DOWN
}
return basic.JDE2DateByZone(riseJde, date.Location(), true), err
}
// HourAngle 恒星时角
// 返回给定Date赤经、经度、对应date时区date时刻的太阳时角
func HourAngle(date time.Time, ra, lon float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.StarHourAngle(jde, ra, lon, timezone)
}
// Azimuth 恒星方位角
// 返回给定Date赤经赤纬、经纬度、对应date时区date时刻的恒星方位角正北为0向东增加
func Azimuth(date time.Time, ra, dec, lon, lat float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.StarAzimuth(jde, ra, dec, lon, lat, timezone)
}
// Zenith 恒星高度角
// 返回给定赤经赤纬、经纬度、对应date时区date时刻的太阳高度角
func Zenith(date time.Time, ra, dec, lon, lat float64) float64 {
jde := basic.Date2JDE(date)
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
return basic.StarAzimuth(jde, ra, dec, lon, lat, timezone)
}
// CulminationTime 恒星中天时间
// 返回给定赤经赤纬、经纬度、对应date时区date时刻的太阳中天日期
func CulminationTime(date time.Time, ra, lon float64) time.Time {
jde := basic.Date2JDE(date)
if jde-math.Floor(jde) < 0.5 {
jde--
}
_, loc := date.Zone()
timezone := float64(loc) / 3600.0
calcJde := basic.StarCulminationTime(jde, ra, lon, timezone) - timezone/24.00
return basic.JDE2DateByZone(calcJde, date.Location(), false)
}
// InitStarDatabase 初始化恒星数据库
func InitStarDatabase() error {
return basic.LoadStarData()
}
//通过恒星HR编号获取恒星参数
func GetStarDataByHR(hr int) (basic.StarData, error) {
return basic.StarDataByHR(hr)
}

@ -0,0 +1,26 @@
package star
import (
"b612.me/astro/tools"
"fmt"
"testing"
"time"
)
func TestStar(t *testing.T) {
err := InitStarDatabase()
if err != nil {
t.Fatal(err)
}
sirius, err := GetStarDataByHR(2491)
if err != nil {
t.Fatal(err)
}
fmt.Printf("%+v\n", sirius)
now := time.Now()
ra, dec := sirius.RaDecByDate(now)
fmt.Println(tools.Format(ra/15, 1), tools.Format(dec, 0))
fmt.Println(RiseTime(now, ra, dec, 115, 40, 0, true))
fmt.Println(CulminationTime(now, ra, 115))
fmt.Println(DownTime(now, ra, dec, 115, 40, 0, true))
}

@ -179,36 +179,36 @@ func TrueBo(date time.Time) float64 {
return basic.HSunTrueLo(basic.TD2UT(jde, true))
}
// SeeLo 太阳视黄经
// ApparentLo 太阳视黄经
// 返回date对应UTC世界时的太阳视黄经
func SeeLo(date time.Time) float64 {
func ApparentLo(date time.Time) float64 {
//转换为UTC时间
jde := basic.Date2JDE(date.UTC())
return basic.HSunSeeLo(basic.TD2UT(jde, true))
return basic.HSunApparentLo(basic.TD2UT(jde, true))
}
// SeeRa 太阳地心视赤经
// ApparentRa 太阳地心视赤经
// 返回date对应UTC世界时的太阳视赤经使用黄道坐标转换且默认忽略黄纬
func SeeRa(date time.Time) float64 {
func ApparentRa(date time.Time) float64 {
//转换为UTC时间
jde := basic.Date2JDE(date.UTC())
return basic.HSunSeeRa(basic.TD2UT(jde, true))
return basic.HSunApparentRa(basic.TD2UT(jde, true))
}
// SeeDec 太阳地心视赤纬
// ApparentDec 太阳地心视赤纬
// 返回date对应UTC世界时的太阳视赤纬使用黄道坐标转换且默认忽略黄纬
func SeeDec(date time.Time) float64 {
func ApparentDec(date time.Time) float64 {
//转换为UTC时间
jde := basic.Date2JDE(date.UTC())
return basic.HSunSeeDec(basic.TD2UT(jde, true))
return basic.HSunApparentDec(basic.TD2UT(jde, true))
}
// SeeRaDec 太阳地心视赤经和赤纬
// ApparentRaDec 太阳地心视赤经和赤纬
// 返回date对应UTC世界时的太阳视赤纬使用黄道坐标转换且默认忽略黄纬
func SeeRaDec(date time.Time) (float64, float64) {
func ApparentRaDec(date time.Time) (float64, float64) {
//转换为UTC时间
jde := basic.Date2JDE(date.UTC())
return basic.HSunSeeRaDec(basic.TD2UT(jde, true))
return basic.HSunApparentRaDec(basic.TD2UT(jde, true))
}
// MidFunc 太阳中间方程

@ -0,0 +1,14 @@
package sun
import (
"fmt"
"testing"
"time"
)
func TestSun(t *testing.T) {
now := time.Now()
fmt.Println(RiseTime(now, 115, 40, 0, true))
fmt.Println(CulminationTime(now, 115))
fmt.Println(DownTime(now, 115, 40, 0, true))
}

@ -0,0 +1,24 @@
package tools
import (
"fmt"
"math"
)
func Format(val float64, typed uint8) string {
belowZero := false
if val < 0 {
belowZero = true
val = -val
}
degree := math.Floor(val)
min := math.Floor((val - degree) * 60)
sec := (val - degree - min/60) * 3600
if belowZero {
degree = -degree
}
if typed == 0 {
return fmt.Sprintf("%.0f°%.0f%.2f″", degree, min, sec)
}
return fmt.Sprintf("%.0fh%.0fm%.2fs", degree, min, sec)
}
Loading…
Cancel
Save