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.
77 lines
2.1 KiB
Go
77 lines
2.1 KiB
Go
5 days ago
|
package astro
|
||
|
|
||
|
import (
|
||
|
"b612.me/astro/star"
|
||
|
"b612.me/astro/sun"
|
||
|
"b612.me/astro/tools"
|
||
|
"fmt"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
func BasicSun(date time.Time, format uint8) {
|
||
|
fmt.Printf("时间: %s\n", date.Format("2006-01-02 15:04:05"))
|
||
|
ra, dec := sun.ApparentRaDec(date)
|
||
|
lo := sun.ApparentLo(date)
|
||
|
eo := sun.EclipticObliquity(date, true)
|
||
|
fmt.Println("太阳")
|
||
|
fmt.Println("------------------------")
|
||
|
switch format {
|
||
|
case 0:
|
||
|
fmt.Printf("视赤经: %f\n", ra)
|
||
|
fmt.Printf("视赤纬: %f\n", dec)
|
||
|
fmt.Printf("视黄经: %f\n", lo)
|
||
|
fmt.Printf("黄赤交角: %f\n", eo)
|
||
|
case 1:
|
||
|
fra := tools.Format(ra/15, 1)
|
||
|
fdec := tools.Format(dec, 0)
|
||
|
flo := tools.Format(lo, 0)
|
||
|
feo := tools.Format(eo, 0)
|
||
|
fmt.Printf("视赤经: %s\n", fra)
|
||
|
fmt.Printf("视赤纬: %s\n", fdec)
|
||
|
fmt.Printf("视黄经: %s\n", flo)
|
||
|
fmt.Printf("黄赤交角: %s\n", feo)
|
||
|
}
|
||
|
cst := star.Constellation(ra, dec, date)
|
||
|
fmt.Printf("星座: %s\n", cst)
|
||
|
}
|
||
|
|
||
|
func SunDetail(date time.Time, lon, lat, height float64, format uint8) {
|
||
|
rise, err := sun.RiseTime(date, lon, lat, height, true)
|
||
|
if err != nil {
|
||
|
fmt.Println(err)
|
||
|
}
|
||
|
set, err := sun.DownTime(date, lon, lat, height, true)
|
||
|
if err != nil {
|
||
|
fmt.Println(err)
|
||
|
}
|
||
|
morning, err := sun.MorningTwilight(date, lon, lat, -6)
|
||
|
if err != nil {
|
||
|
fmt.Println(err)
|
||
|
}
|
||
|
evening, err := sun.EveningTwilight(date, lon, lat, -6)
|
||
|
if err != nil {
|
||
|
fmt.Println(err)
|
||
|
|
||
|
}
|
||
|
fmt.Printf("晨朦影: %s\n", morning.Format("2006-01-02 15:04:05"))
|
||
|
fmt.Printf("升起: %s\n", rise.Format("2006-01-02 15:04:05"))
|
||
|
fmt.Printf("落下: %s\n", set.Format("2006-01-02 15:04:05"))
|
||
|
fmt.Printf("昏朦影: %s\n", evening.Format("2006-01-02 15:04:05"))
|
||
|
az := sun.Azimuth(date, lon, lat)
|
||
|
alt := sun.Zenith(date, lon, lat)
|
||
|
ta := sun.HourAngle(date, lon, lat)
|
||
|
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)
|
||
|
}
|
||
|
}
|