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.
131 lines
3.5 KiB
Go
131 lines
3.5 KiB
Go
package astro
|
|
|
|
import (
|
|
"b612.me/astro/moon"
|
|
"b612.me/astro/star"
|
|
"b612.me/astro/sun"
|
|
"b612.me/astro/tools"
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
func BasicMoon(date time.Time, format uint8) {
|
|
fmt.Printf("时间: %s\n", date.Format("2006-01-02 15:04:05"))
|
|
lo := moon.ApparentLo(date)
|
|
eo := moon.Phase(date)
|
|
bo := moon.TrueBo(date)
|
|
fmt.Println("月亮")
|
|
fmt.Println("------------------------")
|
|
switch format {
|
|
case 0:
|
|
fmt.Printf("黄经: %f\n", lo)
|
|
fmt.Printf("黄纬: %f\n", bo)
|
|
case 1:
|
|
flo := tools.Format(lo, 0)
|
|
fbo := tools.Format(bo, 0)
|
|
fmt.Printf("黄经: %s\n", flo)
|
|
fmt.Printf("黄纬: %s\n", fbo)
|
|
}
|
|
phaseStr := ""
|
|
mslo := tools.Limit360(lo - sun.ApparentLo(date))
|
|
if mslo >= 0 && mslo <= 30 {
|
|
phaseStr = "新月"
|
|
} else if mslo > 30 && mslo <= 75 {
|
|
phaseStr = "上峨眉月"
|
|
} else if mslo > 75 && mslo <= 135 {
|
|
phaseStr = "上弦月"
|
|
} else if mslo > 135 && mslo < 170 {
|
|
phaseStr = "盈凸月"
|
|
} else if mslo >= 170 && mslo <= 190 {
|
|
phaseStr = "满月"
|
|
} else if mslo > 190 && mslo < 225 {
|
|
phaseStr = "亏凸月"
|
|
} else if mslo >= 225 && mslo < 285 {
|
|
phaseStr = "下弦月"
|
|
} else if mslo >= 285 && mslo < 330 {
|
|
phaseStr = "下峨眉月"
|
|
} else {
|
|
phaseStr = "残月"
|
|
}
|
|
|
|
fmt.Printf("月相: %.2f%% %s\n", eo*100, phaseStr)
|
|
sx := moon.NextShangXianYue(date)
|
|
xx := moon.NextXiaXianYue(date)
|
|
wang := moon.NextWangYue(date)
|
|
shuo := moon.NextShuoYue(date)
|
|
fmt.Printf("朔月: %s\n", shuo.Format("2006-01-02 15:04:05"))
|
|
fmt.Printf("上弦: %s\n", sx.Format("2006-01-02 15:04:05"))
|
|
fmt.Printf("望月: %s\n", wang.Format("2006-01-02 15:04:05"))
|
|
fmt.Printf("下弦: %s\n", xx.Format("2006-01-02 15:04:05"))
|
|
|
|
}
|
|
|
|
func MoonDetail(date time.Time, lon, lat, height float64, format uint8) {
|
|
var err error
|
|
ra, dec := moon.ApparentRaDec(date, lon, lat)
|
|
tmp := new(time.Time)
|
|
*tmp, err = moon.RiseTime(date, lon, lat, height, true)
|
|
if err != nil {
|
|
if err == moon.ERR_NOT_TODAY {
|
|
*tmp, err = moon.RiseTime(date.AddDate(0, 0, -1), lon, lat, 0, true)
|
|
if err != nil {
|
|
*tmp = time.Time{}
|
|
}
|
|
}
|
|
}
|
|
rise := *tmp
|
|
tmp = new(time.Time)
|
|
*tmp, err = moon.DownTime(date, lon, lat, 0, true)
|
|
if err != nil {
|
|
if err == moon.ERR_NOT_TODAY {
|
|
*tmp, err = moon.DownTime(date.AddDate(0, 0, 1), lon, lat, 0, true)
|
|
if err != nil {
|
|
*tmp = time.Time{}
|
|
}
|
|
}
|
|
}
|
|
if tmp.Before(rise) {
|
|
tmp = new(time.Time)
|
|
*tmp, err = moon.DownTime(date.AddDate(0, 0, 1), lon, lat, 0, true)
|
|
if err != nil {
|
|
if err == moon.ERR_NOT_TODAY {
|
|
*tmp, err = moon.DownTime(date.AddDate(0, 0, 2), lon, lat, 0, true)
|
|
if err != nil {
|
|
*tmp = time.Time{}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
set := tmp
|
|
cst := star.Constellation(ra, dec, date)
|
|
switch format {
|
|
case 0:
|
|
fmt.Printf("视赤经: %s\n", ra)
|
|
fmt.Printf("视赤纬: %s\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)
|
|
}
|
|
fmt.Printf("星座: %s\n", cst)
|
|
fmt.Printf("升起: %s\n", rise.Format("2006-01-02 15:04:05"))
|
|
fmt.Printf("落下: %s\n", set.Format("2006-01-02 15:04:05"))
|
|
az := moon.Azimuth(date, lon, lat)
|
|
alt := moon.Zenith(date, lon, lat)
|
|
ta := moon.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)
|
|
}
|
|
}
|