コード例 #1
0
ファイル: pp_test.go プロジェクト: thecc4re/meeus
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)
		}
	}
}
コード例 #2
0
ファイル: perihelion_test.go プロジェクト: pjh59/meeus
func TestJS(t *testing.T) {
	// p. 270
	j := pa.Aphelion(pa.Jupiter, 1981.5)
	y, m, d := julian.JDToCalendar(j)
	if y != 1981 || m != 7 || int(d) != 19 {
		t.Fatal(y, m, d)
	}
	s := pa.Perihelion(pa.Saturn, 1944.5)
	y, m, d = julian.JDToCalendar(s)
	if y != 1944 || m != 7 || int(d) != 30 {
		t.Fatal(y, m, d)
	}
}
コード例 #3
0
ファイル: perihelion_test.go プロジェクト: pjh59/meeus
func TestEarth(t *testing.T) {
	// p. 273
	j := pa.Perihelion(pa.EMBary, 1990)
	y, m, d := julian.JDToCalendar(j)
	if y != 1990 || m != 1 || int(d) != 3 {
		t.Fatal(y, m, d)
	}
	j = pa.Perihelion(pa.Earth, 1990)
	y, m, df := julian.JDToCalendar(j)
	d, f := math.Modf(df)
	if y != 1990 || m != 1 || int(d) != 4 || int(f*24+.5) != 16 {
		t.Fatal(y, m, df)
	}
}
コード例 #4
0
ファイル: julian_test.go プロジェクト: thecc4re/meeus
func ExampleJDToCalendar() {
	// Example 7.c, p. 64.
	y, m, d := julian.JDToCalendar(2436116.31)
	fmt.Printf("%d %s %.2f\n", y, time.Month(m), d)
	// Output:
	// 1957 October 4.81
}
コード例 #5
0
ファイル: line_test.go プロジェクト: soniakeys/meeus
func ExampleTime() {
	// Example 19.a, p. 121.
	r1 := unit.AngleFromDeg(113.56833)
	d1 := unit.AngleFromDeg(31.89756)
	r2 := unit.AngleFromDeg(116.25042)
	d2 := unit.AngleFromDeg(28.03681)
	r3 := make([]unit.Angle, 5)
	for i, ri := range []float64{
		118.98067, 119.59396, 120.20413, 120.81108, 121.41475} {
		r3[i] = unit.AngleFromDeg(ri)
	}
	d3 := make([]unit.Angle, 5)
	for i, di := range []float64{
		21.68417, 21.58983, 21.49394, 21.39653, 21.29761} {
		d3[i] = unit.AngleFromDeg(di)
	}
	// use JD as time to handle month boundary
	jd, err := line.Time(r1, d1, r2, d2, r3, d3,
		julian.CalendarGregorianToJD(1994, 9, 29),
		julian.CalendarGregorianToJD(1994, 10, 3))
	if err != nil {
		fmt.Println(err)
		return
	}
	y, m, d := julian.JDToCalendar(jd)
	dInt, dFrac := math.Modf(d)
	fmt.Printf("%d %s %.4f\n", y, time.Month(m), d)
	fmt.Printf("%d %s %d, at %h TD(UT)\n", y, time.Month(m), int(dInt),
		sexa.FmtTime(unit.TimeFromDay(dFrac)))
	// Output:
	// 1994 October 1.2233
	// 1994 October 1, at 5ʰ TD(UT)
}
コード例 #6
0
ファイル: line_test.go プロジェクト: thecc4re/meeus
func ExampleTime() {
	// Example 19.a, p. 121.

	// convert degree data to radians
	r1 := 113.56833 * math.Pi / 180
	d1 := 31.89756 * math.Pi / 180
	r2 := 116.25042 * math.Pi / 180
	d2 := 28.03681 * math.Pi / 180
	r3 := make([]float64, 5)
	for i, ri := range []float64{
		118.98067, 119.59396, 120.20413, 120.81108, 121.41475} {
		r3[i] = ri * math.Pi / 180
	}
	d3 := make([]float64, 5)
	for i, di := range []float64{
		21.68417, 21.58983, 21.49394, 21.39653, 21.29761} {
		d3[i] = di * math.Pi / 180
	}
	// use JD as time to handle month boundary
	jd, err := line.Time(r1, d1, r2, d2, r3, d3,
		julian.CalendarGregorianToJD(1994, 9, 29),
		julian.CalendarGregorianToJD(1994, 10, 3))
	if err != nil {
		fmt.Println(err)
		return
	}
	y, m, d := julian.JDToCalendar(jd)
	dInt, dFrac := math.Modf(d)
	fmt.Printf("%d %s %.4f\n", y, time.Month(m), d)
	fmt.Printf("%d %s %d, at %h TD(UT)\n", y, time.Month(m), int(dInt),
		sexa.NewFmtTime(dFrac*24*3600))
	// Output:
	// 1994 October 1.2233
	// 1994 October 1, at 5ʰ TD(UT)
}
コード例 #7
0
ファイル: solardisk_test.go プロジェクト: thecc4re/meeus
func ExampleCycle() {
	j := solardisk.Cycle(1699)
	fmt.Printf("%.4f\n", j)
	y, m, d := julian.JDToCalendar(j)
	fmt.Printf("%d %s %.2f\n", y, time.Month(m), d)
	// Output:
	// 2444480.7230
	// 1980 August 29.22
}
コード例 #8
0
ファイル: pp_test.go プロジェクト: soniakeys/meeus
func ExampleTimes_computed() {
	// Example 15.a, p. 103, but using meeus packages to compute values
	// given in the text.
	jd := julian.CalendarGregorianToJD(1988, 3, 20)
	p := globe.Coord{
		Lon: unit.NewAngle(' ', 71, 5, 0),
		Lat: unit.NewAngle(' ', 42, 20, 0),
	}
	// Th0 computed rather than taken from the text.
	Th0 := sidereal.Apparent0UT(jd)

	// Venus α, δ computed rather than taken from the text.
	e, err := pp.LoadPlanet(pp.Earth)
	if err != nil {
		fmt.Println(err)
		return
	}
	v, err := pp.LoadPlanet(pp.Venus)
	if err != nil {
		fmt.Println(err)
		return
	}
	α := make([]unit.RA, 3)
	δ := make([]unit.Angle, 3)
	α[0], δ[0] = elliptic.Position(v, e, jd-1)
	α[1], δ[1] = elliptic.Position(v, e, jd)
	α[2], δ[2] = elliptic.Position(v, e, jd+1)
	for i, j := range []float64{jd - 1, jd, jd + 1} {
		_, m, d := julian.JDToCalendar(j)
		fmt.Printf("%s %.0f  α: %0.2s  δ: %0.1s\n",
			time.Month(m), d, sexa.FmtRA(α[i]), sexa.FmtAngle(δ[i]))
	}

	// ΔT computed rather than taken from the text.
	ΔT := deltat.Interp10A(jd)
	fmt.Printf("ΔT: %.1f\n", ΔT)

	h0 := rise.Stdh0Stellar
	tRise, tTransit, tSet, err := rise.Times(p, ΔT, h0, Th0, α, δ)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("rising:   %+.5f %02s\n", tRise/86400, sexa.FmtTime(tRise))
	fmt.Printf("transit:  %+.5f %02s\n", tTransit/86400, sexa.FmtTime(tTransit))
	fmt.Printf("seting:   %+.5f %02s\n", tSet/86400, sexa.FmtTime(tSet))
	// Output:
	// March 19  α: 2ʰ42ᵐ43.25ˢ  δ: 18°02′51.4″
	// March 20  α: 2ʰ46ᵐ55.51ˢ  δ: 18°26′27.3″
	// March 21  α: 2ʰ51ᵐ07.69ˢ  δ: 18°49′38.7″
	// ΔT: 55.9
	// rising:   +0.51766  12ʰ25ᵐ26ˢ
	// transit:  +0.81980  19ʰ40ᵐ30ˢ
	// seting:   +0.12130  02ʰ54ᵐ40ˢ
}
コード例 #9
0
ファイル: perihelion_test.go プロジェクト: pjh59/meeus
func ExamplePerihelion() {
	// Example 38.a, p. 270
	j := pa.Perihelion(pa.Venus, 1978.79)
	fmt.Printf("%.3f\n", j)
	y, m, df := julian.JDToCalendar(j)
	d, f := math.Modf(df)
	fmt.Printf("%d %s %d at %dʰ\n", y, time.Month(m), int(d), int(f*24+.5))
	// Output:
	// 2443873.704
	// 1978 December 31 at 5ʰ
}
コード例 #10
0
ファイル: planetary_test.go プロジェクト: thecc4re/meeus
func ExampleMarsStation2() {
	// Example 36.d, p. 254
	j := planetary.MarsStation2(1997.3)
	fmt.Printf("%.3f\n", j)
	y, m, df := julian.JDToCalendar(j)
	d, f := math.Modf(df)
	fmt.Printf("%d %s %d, at %dʰ\n", y, time.Month(m), int(d), int(f*24+.5))
	// Output:
	// 2450566.255
	// 1997 April 27, at 18ʰ
}
コード例 #11
0
ファイル: perihelion_test.go プロジェクト: pjh59/meeus
func ExampleAphelion() {
	// Example 38.b, p. 270
	j := pa.Aphelion(pa.Mars, 2032.5)
	fmt.Printf("%.3f\n", j)
	y, m, df := julian.JDToCalendar(j)
	d, f := math.Modf(df)
	fmt.Printf("%d %s %d at %dʰ\n", y, time.Month(m), int(d), int(f*24+.5))
	// Output:
	// 2463530.456
	// 2032 October 24 at 23ʰ
}
コード例 #12
0
ファイル: planetary_test.go プロジェクト: thecc4re/meeus
func ExampleMercuryInfConj() {
	// Example 36.a, p. 252
	j := planetary.MercuryInfConj(1993.75)
	fmt.Printf("%.3f\n", j)
	y, m, df := julian.JDToCalendar(j)
	d, f := math.Modf(df)
	fmt.Printf("%d %s %d, at %dʰ\n", y, time.Month(m), int(d), int(f*24+.5))
	// Output:
	// 2449297.645
	// 1993 November 6, at 3ʰ
}
コード例 #13
0
ファイル: planetary_test.go プロジェクト: thecc4re/meeus
func ExampleSaturnConj() {
	// Example 36.b, p. 252
	j := planetary.SaturnConj(2125.5)
	fmt.Printf("%.3f\n", j)
	y, m, df := julian.JDToCalendar(j)
	d, f := math.Modf(df)
	fmt.Printf("%d %s %d, at %dʰ\n", y, time.Month(m), int(d), int(f*24+.5))
	// Output:
	// 2497437.904
	// 2125 August 26, at 10ʰ
}
コード例 #14
0
ファイル: node_test.go プロジェクト: pjh59/meeus
func ExampleEllipticDescending() {
	// Example 39.a, p. 276
	t, r := node.EllipticDescending(17.9400782, .96727426,
		111.84644*math.Pi/180,
		julian.CalendarGregorianToJD(1986, 2, 9.45891))
	y, m, d := julian.JDToCalendar(t)
	fmt.Printf("%d %s %.2f\n", y, time.Month(m), d)
	fmt.Printf("%.4f AU\n", r)
	// Output:
	// 1986 March 10.37
	// 0.8493 AU
}
コード例 #15
0
ファイル: node_test.go プロジェクト: pjh59/meeus
func ExampleParabolicDescending() {
	// Example 29.b, p. 277
	t, r := node.ParabolicDescending(1.324502,
		154.9103*math.Pi/180,
		julian.CalendarGregorianToJD(1989, 8, 20.291))
	y, m, d := julian.JDToCalendar(t)
	fmt.Printf("%d %s %.3f\n", y, time.Month(m), d)
	fmt.Printf("%.4f AU\n", r)
	// Output:
	// 1989 September 17.636
	// 1.3901 AU
}
コード例 #16
0
ファイル: node_test.go プロジェクト: pjh59/meeus
func ExampleParabolicAscending() {
	// Example 29.b, p. 277
	t, r := node.ParabolicAscending(1.324502,
		154.9103*math.Pi/180,
		julian.CalendarGregorianToJD(1989, 8, 20.291))
	y, m, d := julian.JDToCalendar(t)
	fmt.Printf("%d %s %d\n", y, time.Month(m), int(d))
	fmt.Printf("%.2f AU\n", r)
	// Output:
	// 1977 September 17
	// 28.07 AU
}
コード例 #17
0
ファイル: node_test.go プロジェクト: soniakeys/meeus
func ExampleEllipticAscending() {
	// Example 39.a, p. 276
	t, r := node.EllipticAscending(17.9400782, .96727426,
		unit.AngleFromDeg(111.84644),
		julian.CalendarGregorianToJD(1986, 2, 9.45891))
	y, m, d := julian.JDToCalendar(t)
	fmt.Printf("%d %s %.2f\n", y, time.Month(m), d)
	fmt.Printf("%.4f AU\n", r)
	// Output:
	// 1985 November 9.16
	// 1.8045 AU
}
コード例 #18
0
ファイル: apsis_test.go プロジェクト: soniakeys/meeus
func ExampleApogee() {
	// Example 50.a, p. 357.
	j := apsis.Apogee(1988.75)
	fmt.Printf("JDE = %.4f\n", j)
	y, m, d := julian.JDToCalendar(j)
	d, f := math.Modf(d)
	fmt.Printf("%d %s %d, at %m TD\n", y, time.Month(m), int(d),
		sexa.FmtTime(unit.TimeFromDay(f)))
	// Output:
	// JDE = 2447442.3543
	// 1988 October 7, at 20ʰ30ᵐ TD
}
コード例 #19
0
ファイル: pp_test.go プロジェクト: thecc4re/meeus
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)
	}
}
コード例 #20
0
ファイル: moonnode_test.go プロジェクト: pjh59/meeus
func ExampleAscending() {
	// Example 51.a, p. 365.
	j := moonnode.Ascending(1987.37)
	fmt.Printf("%.5f\n", j)
	y, m, d := julian.JDToCalendar(j)
	d, f := math.Modf(d)
	fmt.Printf("%d %s %d, at %d TD\n", y, time.Month(m), int(d),
		base.NewFmtTime(f*24*3600))
	// Output:
	// 2446938.76803
	// 1987 May 23, at 6ʰ25ᵐ58ˢ TD
}
コード例 #21
0
ファイル: apsis_test.go プロジェクト: pjh59/meeus
func ExampleApogee() {
	// Example 50.a, p. 357.
	j := apsis.Apogee(1988.75)
	fmt.Printf("JDE = %.4f\n", j)
	y, m, d := julian.JDToCalendar(j)
	d, f := math.Modf(d)
	fmt.Printf("%d %s %d, at %.62d TD\n", y, time.Month(m), int(d),
		base.NewFmtTime(f*24*3600))
	// Output:
	// JDE = 2447442.3543
	// 1988 October 7, at 20ʰ30ᵐ TD
}
コード例 #22
0
ファイル: pp_test.go プロジェクト: thecc4re/meeus
func ExampleSunrise() {
	earth, err := pp.LoadPlanet(pp.Earth)
	if err != nil {
		fmt.Println(err)
		return
	}
	j0 := julian.CalendarGregorianToJD(1992, 4, 15)
	j := moon.Sunrise(-20*math.Pi/180, 9.7*math.Pi/180, j0, earth)
	y, m, d := julian.JDToCalendar(j)
	fmt.Printf("%d %s %.4f TD\n", y, time.Month(m), d)
	// Output:
	// 1992 April 11.8069 TD
}
コード例 #23
0
ファイル: node_test.go プロジェクト: pjh59/meeus
func ExampleEllipticAscending_venus() {
	// Example 39.c, p. 278
	var k elementplanet.Elements
	elementplanet.Mean(elementplanet.Venus,
		julian.CalendarGregorianToJD(1979, 1, 1), &k)
	t, _ := node.EllipticAscending(k.Axis, k.Ecc,
		k.Peri-k.Node,
		perihelion.Perihelion(perihelion.Venus, 1979))
	y, m, d := julian.JDToCalendar(t)
	fmt.Printf("%d %s %.3f\n", y, time.Month(m), d)
	// Output:
	// 1978 November 27.409
}
コード例 #24
0
ファイル: planetary_test.go プロジェクト: thecc4re/meeus
func ExampleMercuryWestElongation() {
	// Example 36.c, p. 253
	j, e := planetary.MercuryWestElongation(1993.9)
	fmt.Printf("%.2f\n", j)
	y, m, df := julian.JDToCalendar(j)
	d, f := math.Modf(df)
	fmt.Printf("%d %s %d, at %dʰ\n", y, time.Month(m), int(d), int(f*24+.5))
	fmt.Printf("%.4f deg\n", e*180/math.Pi)
	fmt.Printf("%m\n", sexa.NewFmtAngle(e))
	// Output:
	// 2449314.14
	// 1993 November 22, at 15ʰ
	// 19.7506 deg
	// 19°45′
}
コード例 #25
0
ファイル: moonmaxdec_test.go プロジェクト: pjh59/meeus
func ExampleNorth_c() {
	// Example 52.c, p. 370.
	j, δ := moonmaxdec.North(-3.8)
	fmt.Printf("JDE = %.4f\n", j)
	y, m, d := julian.JDToCalendar(j)
	d, f := math.Modf(d)
	fmt.Printf("%d %s %d at %0.64d TD\n", y, time.Month(m), int(d),
		base.NewFmtTime(f*24*3600))
	fmt.Printf("δ = %.4f\n", δ*180/math.Pi)
	fmt.Printf("%+0.62d\n", base.NewFmtAngle(δ))
	// Output:
	// JDE = 1719672.1412
	// -4 March 16 at 15ʰ TD
	// δ = 28.9739
	// +28°58′
}
コード例 #26
0
ファイル: moonmaxdec_test.go プロジェクト: pjh59/meeus
func ExampleSouth() {
	// Example 52.b, p. 370.
	j, δ := moonmaxdec.South(2049.3)
	fmt.Printf("JDE = %.4f\n", j)
	y, m, d := julian.JDToCalendar(j)
	d, f := math.Modf(d)
	fmt.Printf("%d %s %d at %0.64d TD\n", y, time.Month(m), int(d),
		base.NewFmtTime(f*24*3600))
	fmt.Printf("δ = %.4f\n", δ*180/math.Pi)
	fmt.Printf("%+0.62d\n", base.NewFmtAngle(δ))
	// Output:
	// JDE = 2469553.0834
	// 2049 April 21 at 14ʰ TD
	// δ = -22.1384
	// -22°08′
}
コード例 #27
0
ファイル: moonmaxdec_test.go プロジェクト: pjh59/meeus
func ExampleNorth() {
	// Example 52.a, p. 370.
	j, δ := moonmaxdec.North(1988.95)
	fmt.Printf("JDE = %.4f\n", j)
	y, m, d := julian.JDToCalendar(j)
	d, f := math.Modf(d)
	fmt.Printf("%d %s %d at %0.62d TD\n", y, time.Month(m), int(d),
		base.NewFmtTime(f*24*3600))
	fmt.Printf("δ = %.4f\n", δ*180/math.Pi)
	fmt.Printf("%+0d\n", base.NewFmtAngle(δ))
	// Output:
	// JDE = 2447518.3346
	// 1988 December 22 at 20ʰ02ᵐ TD
	// δ = 28.1562
	// +28°09′22″
}
コード例 #28
0
ファイル: moonmaxdec_test.go プロジェクト: soniakeys/meeus
func ExampleNorth_c() {
	// Example 52.c, p. 370.
	j, δ := moonmaxdec.North(-3.8)
	fmt.Printf("JDE = %.4f\n", j)
	y, m, d := julian.JDToCalendar(j)
	d, f := math.Modf(d)
	fmt.Printf("%d %s %d at %0h TD\n", y, time.Month(m), int(d),
		sexa.FmtTime(unit.TimeFromDay(f)))
	fmt.Printf("δ = %.4f\n", δ.Deg())
	fmt.Printf("%+0m\n", sexa.FmtAngle(δ))
	// Output:
	// JDE = 1719672.1412
	// -4 March 16 at 15ʰ TD
	// δ = 28.9739
	// +28°58′
}
コード例 #29
0
ファイル: julian_test.go プロジェクト: thecc4re/meeus
func TestYMD(t *testing.T) {
	for _, tp := range []struct {
		jd   float64
		y, m int
		d    float64
	}{
		{1842713, 333, 1, 27.5},
		{1507900.13, -584, 5, 28.63},
	} {
		y, m, d := julian.JDToCalendar(tp.jd)
		if y != tp.y || m != tp.m || math.Abs(d-tp.d) > .01 {
			t.Logf("%#v", tp)
			t.Fatal("JDToYMD", y, m, d)
		}
	}
}
コード例 #30
0
ファイル: deltat.go プロジェクト: thecc4re/meeus
func Interp10A(jde float64) float64 {
	// kind of crazy, working in calendar years, but it seems that's what
	// we're supposed to do.
	y, m, d := julian.JDToCalendar(jde)
	l := julian.LeapYearGregorian(y)
	yl := 365.
	if l {
		yl++
	}
	yf := float64(y) + float64(julian.DayOfYear(y, m, int(d+.5), l))/yl
	d3, err := interp.Len3ForInterpolateX(yf, tableYear1, tableYearN, table10A)
	if err != nil {
		panic(err) // error would indicate a bug in interp.Slice.
	}
	return d3.InterpolateX(yf)
}