예제 #1
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])
		}
	}
}
예제 #2
0
파일: planet_test.go 프로젝트: pebbe/novas
func TestAppPlanet(t *testing.T) {
	nt := novas.Date(2012, 12, 13, 12, 0, 0, 0, time.UTC)
	sun := novas.Sun()
	data := sun.App(nt)
	tests := [][3]string{
		{"Right ascension", "17.411478", fmt.Sprintf("%.6f", data.RA)},
		{"Declination", "-23.187681", fmt.Sprintf("%.6f", data.Dec)},
		{"Distance in AU", "0.984424", fmt.Sprintf("%.6f", data.Dis)},
		{"Ecliptic longitude", "261.890295", fmt.Sprintf("%.6f", data.ELon)},
		{"Ecliptic latitude", "0.001756", fmt.Sprintf("%.6f", data.ELat)},
	}
	for _, test := range tests {
		if test[1] != test[2] {
			t.Errorf("%s: expected %s, got %s", test[0], test[1], test[2])
		}
	}
}
예제 #3
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))
}