Esempio n. 1
0
func TestEarth2(t *testing.T) {
	// p. 274
	v, err := pp.LoadPlanet(pp.Earth)
	if err != nil {
		t.Fatal(err)
	}
	for _, d := range ep {
		yf := float64(d.y) + (float64(d.m)-.5)/12
		u, r := pa.Perihelion2(pa.Earth, yf, .0004, v)
		y, m, df := julian.JDToCalendar(u)
		dd, f := math.Modf(df)
		if y != d.y || m != d.m || int(dd) != d.d ||
			math.Abs(f*24-d.h) > .01 ||
			math.Abs(r-d.r) > .000001 {
			t.Log(d)
			t.Fatal(y, m, int(dd), f*24, r)
		}
	}
	for _, d := range ea {
		yf := float64(d.y) + (float64(d.m)-.5)/12
		u, r := pa.Aphelion2(pa.Earth, yf, .0004, v)
		y, m, df := julian.JDToCalendar(u)
		dd, f := math.Modf(df)
		if y != d.y || m != d.m || int(dd) != d.d ||
			math.Abs(f*24-d.h) > .01 ||
			math.Abs(r-d.r) > .000001 {
			t.Log(d)
			t.Fatal(y, m, int(dd), f*24, r)
		}
	}
}
Esempio n. 2
0
func TestN2(t *testing.T) {
	v, err := pp.LoadPlanet(pp.Neptune, "")
	if err != nil {
		t.Fatal(err)
	}
	for _, d := range sn {
		yf := float64(d.y) + (float64(d.m)-.5)/12
		var u, r float64
		if d.ap == 'a' {
			u, r = pa.Aphelion2(pa.Neptune, yf, 1, v)
		} else {
			u, r = pa.Perihelion2(pa.Neptune, yf, 1, v)
		}
		y, m, df := julian.JDToCalendar(u)
		if y != d.y || m != d.m || int(df) != d.d || math.Abs(r-d.r) > .0001 {
			t.Log(d)
			t.Fatal(y, m, df, r)
		}
	}
}
Esempio n. 3
0
func TestS2(t *testing.T) {
	// p. 271
	v, err := pp.LoadPlanet(pp.Saturn)
	if err != nil {
		t.Fatal(err)
	}
	for _, d := range sd {
		yf := float64(d.y) + (float64(d.m)-.5)/12
		var s, r float64
		if d.ap == 'a' {
			s, r = pa.Aphelion2(pa.Saturn, yf, 1, v)
		} else {
			s, r = pa.Perihelion2(pa.Saturn, yf, 1, v)
		}
		y, m, df := julian.JDToCalendar(s)
		if y != d.y || m != d.m || int(df) != d.d || math.Abs(r-d.r) > .0001 {
			t.Log(d)
			t.Fatal(y, m, df, r)
		}
	}
}
Esempio n. 4
0
func TestJS2(t *testing.T) {
	// p. 270
	v, err := pp.LoadPlanet(pp.Jupiter)
	if err != nil {
		t.Fatal(err)
	}
	j, _ := pa.Aphelion2(pa.Jupiter, 1981.5, 1, v)
	y, m, d := julian.JDToCalendar(j)
	if y != 1981 || m != 7 || int(d) != 28 {
		t.Fatal(y, m, d)
	}
	v, err = pp.LoadPlanet(pp.Saturn)
	if err != nil {
		t.Fatal(err)
	}
	s, _ := pa.Perihelion2(pa.Saturn, 1944.5, 1, v)
	y, m, d = julian.JDToCalendar(s)
	if y != 1944 || m != 9 || int(d) != 8 {
		t.Fatal(y, m, d)
	}
}