コード例 #1
0
ファイル: moon.go プロジェクト: pebbe/novas
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))
}
コード例 #2
0
ファイル: planets.go プロジェクト: pebbe/novas
func main() {

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

	// END OF USER SETTINGS

	fmt.Println(novas.EphInfo(), "\n")

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

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

	fmt.Println("\n            Distance   Altitude   Azimuth   Disc")
	for _, obj := range []*novas.Body{
		novas.Mercury(),
		novas.Venus(),
		novas.Mars(),
		novas.Jupiter(),
		novas.Saturn(),
		novas.Uranus(),
		novas.Neptune(),
		novas.Pluto(),
	} {
		data := obj.Topo(now, geo, novas.REFR_NONE)
		fmt.Printf("%-8s%12.6f%11.2f%10.2f%7.0f\n", obj.Name(), data.Dis, data.Alt, data.Az, obj.Disc(now))
	}
}
コード例 #3
0
ファイル: star_test.go プロジェクト: pebbe/novas
func TestTopoStar(t *testing.T) {
	nt := novas.Date(2008, 4, 24, 10, 36, 18, 0, time.UTC)
	star := novas.NewStar("GMB 1830", "FK6", 1307, 11.88299133, 37.71867646, 4003.27, -5815.07, 109.21, -98.8)
	place := novas.NewPlace(42.0, -70, 0, 18, 1010)
	data := star.Topo(nt, place, novas.REFR_NONE)
	tests := [][3]string{
		{"Distance", "NaN", fmt.Sprintf("%.6f", data.Dis)},
		{"Altitude", "4.808569", fmt.Sprintf("%.6f", data.Alt)},
		{"Azimuth", "318.528197", fmt.Sprintf("%.6f", data.Az)},
	}
	for _, test := range tests {
		if test[1] != test[2] {
			t.Errorf("%s: expected %s, got %s", test[0], test[1], test[2])
		}
	}
}
コード例 #4
0
ファイル: planet_test.go プロジェクト: pebbe/novas
func TestTopoPlanet(t *testing.T) {
	nt := novas.Date(2012, 12, 13, 12, 0, 0, 0, time.UTC)
	sun := novas.Sun()
	place := novas.NewPlace(53.21853, 6.5670, 0, 18, 1010)
	data := sun.Topo(nt, place, novas.REFR_NONE)
	tests := [][3]string{
		{"Distance in AU", "0.984414", fmt.Sprintf("%.6f", data.Dis)},
		{"Altitude", "13.278250", fmt.Sprintf("%.6f", data.Alt)},
		{"Azimuth", "187.524224", fmt.Sprintf("%.6f", data.Az)},
	}
	for _, test := range tests {
		if test[1] != test[2] {
			t.Errorf("%s: expected %s, got %s", test[0], test[1], test[2])
		}
	}
}
コード例 #5
0
ファイル: star.go プロジェクト: pebbe/novas
func main() {

	t := novas.Date(2008, 4, 24, 10, 36, 18, 0, time.UTC)

	star := novas.NewStar("GMB 1830", "FK6", 1307, 11.88299133, 37.71867646, 4003.27, -5815.07, 109.21, -98.8)
	data := star.App(t)

	fmt.Println("Results for star", star.Name(), "at", t.Local())

	fmt.Printf("Right ascension:    %10.6f\n", data.RA)
	fmt.Printf("Declination:        %10.6f\n", data.Dec)
	fmt.Printf("Ecliptic longitude: %10.6f\n", data.ELon)
	fmt.Printf("Ecliptic latitude:  %10.6f\n", data.ELat)

	place := novas.NewPlace(42.0, -70, 0, 18, 1010)

	data2 := star.Topo(t, place, novas.REFR_NONE)
	fmt.Printf("Altitude:           %10.6f\n", data2.Alt)
	fmt.Printf("Azimuth:            %10.6f\n", data2.Az)
}
コード例 #6
0
ファイル: sun.go プロジェクト: pebbe/novas
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")

	sun := novas.Sun()

	fmt.Printf("Distance from earth's center:   %.7f AU\n", sun.App(now).Dis)

	data := sun.Topo(now, geo, novas.REFR_NONE)

	fmt.Printf("Distance from surface location: %.7f AU\n\n", data.Dis)

	fmt.Printf("Altitude: %7.3f°\nAzimuth:  %7.3f°\n\n", data.Alt, data.Az)

	fmt.Println("             Azimuth  Altitude")

	t0 := novas.Date(now.Year(), int(now.Month()), now.Day(), 0, 0, 0, 0, now.Location())

	t1, topo, err := sun.Rise(t0, geo, sundip, time.Second, novas.REFR_NONE)
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Printf("Sun rise:  %8.2f°            %s\n", topo.Az, t1)
		t0 = t1
	}

	t1, topo, err = sun.High(t0, geo, time.Second, novas.REFR_NONE)
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Printf("High noon: %8.2f° %8.2f°  %s\n", topo.Az, topo.Alt, t1)
		t0 = t1
	}

	t1, topo, err = sun.Set(t0, geo, sundip, time.Second, novas.REFR_NONE)
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Printf("Sun set:   %8.2f°            %s\n", topo.Az, t1)
		t0 = t1
	}

	t1, topo, err = sun.Low(t0, geo, time.Second, novas.REFR_NONE)
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Printf("Deep night:%8.2f° %8.2f°  %s\n\n", topo.Az, topo.Alt, t1)
		t0 = t1
	}

	fmt.Println("Start of seasons in northern hempisphere")
	fmt.Println("Spring:", novas.Spring(now.Time.Year(), time.Second))
	fmt.Println("Summer:", novas.Summer(now.Time.Year(), time.Second))
	fmt.Println("Autumn:", novas.Autumn(now.Time.Year(), time.Second))
	fmt.Println("Winter:", novas.Winter(now.Time.Year(), time.Second))
}