Repository navigation
如何联系? #14
yangyang-studio
started this conversation in
General
如何联系?
#14
Replies: 6 comments 2 replies
|
hello~非常感谢你对这个项目的兴趣。 你需要安装一下go语言,然后写个代码调用,这里可以让AI帮你来生成相关的指引和代码,比如大模型生成的指引示例如下:
package main
import (
"fmt"
"time"
"github.com/starainrt/astro/sun"
"github.com/starainrt/astro/moon"
"github.com/starainrt/astro/calendar"
)
func main() {
// 使用北京时间
cst := time.FixedZone("CST", 8*3600)
now := time.Now().In(cst)
fmt.Println("=== 今天的基本信息 ===")
fmt.Println("公历:", now.Format("2006-01-02"))
// 农历
lunar, _ := calendar.SolarToLunar(now)
fmt.Println("农历:", lunar.LunarDescWithEmperor())
// 太阳
fmt.Printf("太阳视黄经: %.2f°\n", sun.ApparentLo(now))
// 月亮
fmt.Printf("月相: %.1f%% (0=新月, 100=满月)\n", moon.Phase(now)*100)
}
看到输出就成功了! |
1 reply
|
hello~ package main
import (
"fmt"
"os"
"time"
"github.com/starainrt/astro/eclipse"
eclipsesvg "github.com/starainrt/astro/eclipse/svg"
)
func main() {
cst := time.FixedZone("CST", 8*3600) //定义北京时间
// 这里的2042-08-01:它只是ClosestLunarEclipse的搜索起点。
// 这个时间不是月食当天,也不是食甚时间。
searchTime := time.Date(2042, 8, 1, 0, 0, 0, 0, time.UTC)
info := eclipse.ClosestLunarEclipse(searchTime)
fmt.Printf("搜索起点:%s\n", formatTime(searchTime))
fmt.Println("说明:上面的时间只用于搜索最近一次月食,不是要画图的月食时间。")
printLunarEclipseInfo("ClosestLunarEclipse 找到的月食", info)
// 如果要判断“这次月食所在的北京时间自然日有没有月食”,直接使用找到的食甚时间。
eventLocalTime := info.Maximum.In(cst)
today, ok := eclipse.LunarEclipseOnDate(eventLocalTime)
fmt.Printf("\n%s 北京时间当天是否有月食:%v\n", eventLocalTime.Format("2006-01-02"), ok)
if ok {
printLunarEclipseInfo("LunarEclipseOnDate 查询结果", today)
}
// 生成 SVG 时,用上面找到的真正月食时间。最稳妥的是 info.Maximum(食甚时间)。
svg, svgOK := eclipsesvg.LunarEclipseSVG(
info.Maximum,
eclipsesvg.LunarEclipseSVGOptions{
Width: 960,
Height: 620,
Step: 10 * time.Minute,
Location: cst,
},
)
fmt.Printf("\nSVG 生成成功:%v\n", svgOK)
if !svgOK {
panic("2042-09-29 lunar eclipse SVG was not generated")
}
const svgFile = "lunar-eclipse-2042-09-29.svg"
if err := os.WriteFile(svgFile, []byte(svg), 0o644); err != nil {
panic(err)
}
fmt.Printf("SVG 文件:%s\n", svgFile)
}
func printLunarEclipseInfo(title string, info eclipse.LunarEclipseInfo) {
fmt.Printf("\n%s\n", title)
fmt.Printf("- 食型:%s\n", info.Type)
fmt.Printf("- 沙罗:has=%v value=%+v\n", info.HasSaros, info.Saros)
fmt.Printf("- 半影食分:%.12f\n", info.PenumbralMagnitude)
fmt.Printf("- 本影食分:%.12f\n", info.UmbralMagnitude)
fmt.Printf("- 半影始:%s\n", formatOptionalTime(info.PenumbralStart))
fmt.Printf("- 初亏:%s\n", formatOptionalTime(info.PartialStart))
fmt.Printf("- 食既:%s\n", formatOptionalTime(info.TotalStart))
fmt.Printf("- 食甚:%s\n", formatTime(info.Maximum))
fmt.Printf("- 生光:%s\n", formatOptionalTime(info.TotalEnd))
fmt.Printf("- 复圆:%s\n", formatOptionalTime(info.PartialEnd))
fmt.Printf("- 半影终:%s\n", formatOptionalTime(info.PenumbralEnd))
}
func formatOptionalTime(t time.Time) string {
if t.IsZero() {
return "-"
}
return formatTime(t)
}
func formatTime(t time.Time) string {
return t.Format("2006-01-02 15:04:05.999999999 MST")
}运行结果是: 和NASA的数据在这里https://eclipse.gsfc.nasa.gov/LEplot/LEplot2001/LE2042Sep29N.pdf
这个误差级别对于当前库的月食演示用途是正常的。NASA 图页使用 |
0 replies
|
OK |
0 replies
|
日食和月食的时间范围有多久? |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
你好,作者!
我是天文爱好者,想运行你的这个go语言,第一次接触,我该如何操作?我这边的电脑是Windows系统。我问了一些淘宝店家,他们说你的内容是封装好的,需要写程序才能运行,不知道是不是这样的?我这边怎么联系您?方便留个微信吗?
谢谢!
All reactions