You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
2.6 KiB
Go
102 lines
2.6 KiB
Go
package astro
|
|
|
|
import (
|
|
"b612.me/astro/star"
|
|
"b612.me/astro/tools"
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
func BasicStar(date time.Time, name string, format uint8) {
|
|
fmt.Printf("时间: %s\n", date.Format("2006-01-02 15:04:05"))
|
|
s, err := star.StarDataByName(name)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
ra, dec := s.RaDecByDate(date)
|
|
fmt.Printf("%s %s 星等:%.2f\n", s.ChineseName, s.Name, s.Mag)
|
|
fmt.Println("------------------------")
|
|
switch format {
|
|
case 0:
|
|
fmt.Printf("视赤经: %f\n", ra)
|
|
fmt.Printf("视赤纬: %f\n", dec)
|
|
case 1:
|
|
fra := tools.Format(ra/15, 1)
|
|
fdec := tools.Format(dec, 0)
|
|
fmt.Printf("视赤经: %s\n", fra)
|
|
fmt.Printf("视赤纬: %s\n", fdec)
|
|
}
|
|
cst := star.Constellation(ra, dec, date)
|
|
fmt.Printf("星座: %s\n", cst)
|
|
}
|
|
|
|
func StarDetail(date time.Time, name string, lon, lat, height float64, format uint8) {
|
|
s, err := star.StarDataByName(name)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
ra, dec := s.RaDecByDate(date)
|
|
alt := star.Zenith(date, ra, dec, lon, lat)
|
|
ta := star.HourAngle(date, ra, lon)
|
|
zt := star.CulminationTime(date, ra, lon)
|
|
az := star.Azimuth(date, ra, dec, lon, lat)
|
|
var rise, set time.Time
|
|
var duration time.Duration
|
|
for {
|
|
nk := date.Add(duration)
|
|
rise, err = star.RiseTime(nk, ra, dec, lon, lat, height, true)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
if alt > 0 && rise.After(nk) {
|
|
rise, err = star.RiseTime(nk.Add(time.Hour*-24), ra, dec, lon, lat, height, true)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
} else if alt < 0 && rise.Before(nk) {
|
|
rise, err = star.RiseTime(nk.Add(time.Hour*24), ra, dec, lon, lat, height, true)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
|
|
}
|
|
set, err = star.DownTime(nk, ra, dec, lon, lat, height, true)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
if set.Before(rise) {
|
|
set, err = star.DownTime(nk.Add(time.Hour*24), ra, dec, lon, lat, height, true)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
}
|
|
if set.Before(date) {
|
|
duration += time.Hour * 24
|
|
continue
|
|
}
|
|
if zt.Before(rise) {
|
|
zt = star.CulminationTime(nk.Add(time.Hour*24), ra, lon)
|
|
}
|
|
break
|
|
}
|
|
|
|
fmt.Printf("升起: %s\n", rise.Format("2006-01-02 15:04:05"))
|
|
fmt.Printf("中天: %s\n", zt.Format("2006-01-02 15:04:05"))
|
|
fmt.Printf("落下: %s\n", set.Format("2006-01-02 15:04:05"))
|
|
switch format {
|
|
case 0:
|
|
fmt.Printf("方位角: %f\n", az)
|
|
fmt.Printf("高度角: %f\n", alt)
|
|
fmt.Printf("时角: %f\n", ta)
|
|
case 1:
|
|
faz := tools.Format(az, 0)
|
|
falt := tools.Format(alt, 0)
|
|
fta := tools.Format(ta/15, 1)
|
|
fmt.Printf("方位角: %s\n", faz)
|
|
fmt.Printf("高度角: %s\n", falt)
|
|
fmt.Printf("时角: %s\n", fta)
|
|
}
|
|
}
|