Beispiel #1
0
func main() {

	latitude, longitude := 53.21853, 6.5670 // Groningen, The Netherlands

	// END OF USER SETTINGS

	now := novas.Now()
	fmt.Println(now)

	geo := novas.NewPlace(latitude, longitude, 0, 20, 1010)
	fmt.Println("\nLocation:", geo, "\n")

	moon := novas.Moon()

	fmt.Printf("Distance from earth's center:   %.0f km\n", moon.App(now).Dis*novas.AU)

	data := moon.Topo(now, geo, novas.REFR_NONE)
	fmt.Printf("Distance from surface location: %.0f km\n\n", data.Dis*novas.AU)
	fmt.Printf("Altitude: %7.3f°\nAzimuth:  %7.3f°\n\n", data.Alt, data.Az)

	fmt.Printf("Phase of the moon: %.2f°, illuminated: %.0f%%\n\n", novas.MoonPhase(now), moon.Disc(now))

	fmt.Println("Next new moon:      ", novas.MoonPhaseNext(now, 0, 30*time.Second))
	fmt.Println("Next first quarter: ", novas.MoonPhaseNext(now, 90, 30*time.Second))
	fmt.Println("Next full moon:     ", novas.MoonPhaseNext(now, 180, 30*time.Second))
	fmt.Println("Next third quarter: ", novas.MoonPhaseNext(now, 270, 30*time.Second))
}
Beispiel #2
0
func TestDisc(t *testing.T) {
	tests := []string{
		"Moon 62",
		"Mercury 13",
		"Venus 48",
		"Mars 97",
		"Jupiter 100",
	}
	nt := novas.Date(2012, 4, 1, 0, 0, 0, 0, time.UTC)
	for i, n := range []*novas.Body{
		novas.Moon(),
		novas.Mercury(),
		novas.Venus(),
		novas.Mars(),
		novas.Jupiter(),
	} {
		got := fmt.Sprintf("%s %.0f", n.Name(), n.Disc(nt))
		if tests[i] != got {
			t.Errorf("expected %s, got %s", tests[i], got)
		}
	}
}