예제 #1
0
파일: pp_test.go 프로젝트: thecc4re/meeus
func ExampleElements_Position() {
	// Example 33.b, p. 232.
	earth, err := pp.LoadPlanet(pp.Earth)
	if err != nil {
		fmt.Println(err)
		return
	}
	k := &elliptic.Elements{
		TimeP: julian.CalendarGregorianToJD(1990, 10, 28.54502),
		Axis:  2.2091404,
		Ecc:   .8502196,
		Inc:   11.94524 * math.Pi / 180,
		Node:  334.75006 * math.Pi / 180,
		ArgP:  186.23352 * math.Pi / 180,
	}
	j := julian.CalendarGregorianToJD(1990, 10, 6)
	α, δ, ψ := k.Position(j, earth)
	fmt.Printf("α = %.1d\n", sexa.NewFmtRA(α))
	fmt.Printf("δ = %.0d\n", sexa.NewFmtAngle(δ))
	fmt.Printf("ψ = %.2f\n", ψ*180/math.Pi)
	// Output:
	// α = 10ʰ34ᵐ14ˢ.2
	// δ = 19°9′31″
	// ψ = 40.51
}
예제 #2
0
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)
}
예제 #3
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)
}
예제 #4
0
func ExampleCalendarGregorianToJD_halley() {
	// Example 7.c, p. 64.
	jd1 := julian.CalendarGregorianToJD(1910, 4, 20)
	jd2 := julian.CalendarGregorianToJD(1986, 2, 9)
	fmt.Printf("%.0f days\n", jd2-jd1)
	// Output:
	// 27689 days
}
예제 #5
0
func ExampleElements_AnomalyDistance() {
	// Example 34.a, p. 243
	e := &parabolic.Elements{
		TimeP: julian.CalendarGregorianToJD(1998, 4, 14.4358),
		PDis:  1.487469,
	}
	j := julian.CalendarGregorianToJD(1998, 8, 5)
	ν, r := e.AnomalyDistance(j)
	fmt.Printf("%.5f deg\n", ν*180/math.Pi)
	fmt.Printf("%.6f AU\n", r)
	// Output:
	// 66.78862 deg
	// 2.133911 AU
}
예제 #6
0
func ExampleApparentLongitude() {
	// Example 25.a, p. 165.
	T := base.J2000Century(julian.CalendarGregorianToJD(1992, 10, 13))
	fmt.Println("λ:", sexa.NewFmtAngle(solar.ApparentLongitude(T)))
	// Output:
	// λ: 199°54′32″
}
예제 #7
0
func ExampleMeanAnomaly() {
	// Example 25.a, p. 165.
	T := base.J2000Century(julian.CalendarGregorianToJD(1992, 10, 13))
	fmt.Printf("%.5f\n", solar.MeanAnomaly(T)*180/math.Pi)
	// Output:
	// -2241.00603
}
예제 #8
0
func ExampleInterp10A() {
	// Example 10.a, p. 78.
	dt := deltat.Interp10A(julian.CalendarGregorianToJD(1977, 2, 18))
	fmt.Printf("%+.1f seconds\n", dt)
	// Output:
	// +47.6 seconds
}
예제 #9
0
func ExampleV87Planet_Position() {
	// Example 32.a, p. 219
	jd := julian.CalendarGregorianToJD(1992, 12, 20)
	p, err := pp.LoadPlanet(pp.Venus, "")
	if err != nil {
		fmt.Println(err)
		return
	}
	l, b, r := p.Position(jd)
	fmt.Printf("L = %s\n",
		base.DecSymAdd(fmt.Sprintf("%+.5f", l*180/math.Pi), '°'))
	fmt.Printf("B = %s\n",
		base.DecSymAdd(fmt.Sprintf("%+.5f", b*180/math.Pi), '°'))
	fmt.Printf("R = %.6f AU\n", r)
	// Meeus results:
	// L = +26°.11428
	// B = -2°.62070
	// R = 0.724603 AU
	// Answers below seem close enough.

	// Output:
	// L = +26°.11412
	// B = -2°.62060
	// R = 0.724602 AU
}
예제 #10
0
func ExampleCalendarGregorianToJD_sputnik() {
	// Example 7.a, p. 61.
	jd := julian.CalendarGregorianToJD(1957, 10, 4.81)
	fmt.Printf("%.2f\n", jd)
	// Output:
	// 2436116.31
}
예제 #11
0
파일: rise_test.go 프로젝트: pjh59/meeus
func ExampleApproxTimes() {
	// Example 15.a, p. 103.
	jd := julian.CalendarGregorianToJD(1988, 3, 20)
	p := globe.Coord{
		Lon: base.NewAngle(false, 71, 5, 0).Rad(),
		Lat: base.NewAngle(false, 42, 20, 0).Rad(),
	}
	// Meeus gives us the value of 11h 50m 58.1s but we have a package
	// function for this:
	Th0 := sidereal.Apparent0UT(jd)
	α := base.NewRA(2, 46, 55.51).Rad()
	δ := base.NewAngle(false, 18, 26, 27.3).Rad()
	h0 := rise.Stdh0Stellar
	rise, transit, set, err := rise.ApproxTimes(p, h0, Th0, α, δ)
	if err != nil {
		fmt.Println(err)
		return
	}
	// Units for approximate values given near top of p. 104 are circles.
	fmt.Printf("rising:  %+.5f\n", rise/86400)
	fmt.Printf("transit: %+.5f\n", transit/86400)
	fmt.Printf("seting:  %+.5f\n", set/86400)
	// Output:
	// rising:  +0.51816
	// transit: +0.81965
	// seting:  +0.12113
}
예제 #12
0
func ExampleRadius() {
	// Example 25.a, p. 165.
	T := base.J2000Century(julian.CalendarGregorianToJD(1992, 10, 13))
	fmt.Printf("%.5f AU\n", solar.Radius(T))
	// Output:
	// 0.99766 AU
}
예제 #13
0
func ExampleEccentricity() {
	// Example 25.a, p. 165.
	T := base.J2000Century(julian.CalendarGregorianToJD(1992, 10, 13))
	fmt.Printf("%.9f\n", solar.Eccentricity(T))
	// Output:
	// 0.016711668
}
예제 #14
0
파일: moon_test.go 프로젝트: pjh59/meeus
func ExampleParallax() {
	// Example 47.a, p. 342.
	_, _, Δ := moon.Position(julian.CalendarGregorianToJD(1992, 4, 12))
	π := moon.Parallax(Δ)
	fmt.Printf("π = %.6f\n", π*180/math.Pi)
	// Output:
	// π = 0.991990
}
예제 #15
0
func TestNode(t *testing.T) {
	j := julian.CalendarGregorianToJD(2065, 6, 24)
	var e pe.Elements
	pe.Mean(pe.Mercury, j, &e)
	if Ω := pe.Node(pe.Mercury, j); Ω != e.Node {
		t.Fatal(Ω, "!=", e.Node)
	}
}
예제 #16
0
func TestInc(t *testing.T) {
	j := julian.CalendarGregorianToJD(2065, 6, 24)
	var e pe.Elements
	pe.Mean(pe.Mercury, j, &e)
	if i := pe.Inc(pe.Mercury, j); i != e.Inc {
		t.Fatal(i, "!=", e.Inc)
	}
}
예제 #17
0
func ExampleESmart() {
	// Example 28.b, p. 185
	eq := eqtime.ESmart(julian.CalendarGregorianToJD(1992, 10, 13))
	fmt.Printf("+%.7f rad\n", eq)
	fmt.Printf("%+.1d", sexa.FmtHourAngle(eq))
	// Output:
	// +0.0598256 rad
	// +13ᵐ42ˢ.7
}
예제 #18
0
func ExamplePhaseAngle3() {
	i := moonillum.PhaseAngle3(julian.CalendarGregorianToJD(1992, 4, 12))
	k := base.Illuminated(i)
	fmt.Printf("i = %.2f\n", i*180/math.Pi)
	fmt.Printf("k = %.4f\n", k)
	// Output:
	// i = 68.88
	// k = 0.6801
}
예제 #19
0
func TestIAUvsLaskar(t *testing.T) {
	for _, y := range []int{1000, 2000, 3000} {
		jd := julian.CalendarGregorianToJD(y, 0, 0)
		i := nutation.MeanObliquity(jd)
		l := nutation.MeanObliquityLaskar(jd)
		if math.Abs((i - l).Sec()) > 1 {
			t.Fatal(y)
		}
	}
	for _, y := range []int{0, 4000} {
		jd := julian.CalendarGregorianToJD(y, 0, 0)
		i := nutation.MeanObliquity(jd)
		l := nutation.MeanObliquityLaskar(jd)
		if math.Abs((i - l).Sec()) > 10 {
			t.Fatal(y)
		}
	}
}
예제 #20
0
파일: rise.go 프로젝트: soniakeys/meeus
// Planet computes UT rise, transit and set times for a planet on a day of
// interest.
//
//  yr, mon, day are the Gregorian date.
//  pos is geographic coordinates of observer.
//  e must be a V87Planet object for Earth
//  pl must be a V87Planet object for another planet.
//
// Obtain V87Planet objects with the planetposition package.
//
// Result units are seconds of day and are in the range [0,86400).
func Planet(yr, mon, day int, pos globe.Coord, e, pl *pp.V87Planet) (tRise, tTransit, tSet unit.Time, err error) {
	jd := julian.CalendarGregorianToJD(yr, mon, float64(day))
	α := make([]unit.RA, 3)
	δ := make([]unit.Angle, 3)
	α[0], δ[0] = elliptic.Position(pl, e, jd-1)
	α[1], δ[1] = elliptic.Position(pl, e, jd)
	α[2], δ[2] = elliptic.Position(pl, e, jd+1)
	return Times(pos, deltat.Interp10A(jd), Stdh0Stellar,
		sidereal.Apparent0UT(jd), α, δ)
}
예제 #21
0
func ExampleNutation() {
	// Example 23.a, p. 152
	α := sexa.NewRA(2, 46, 11.331).Rad()
	δ := sexa.NewAngle(false, 49, 20, 54.54).Rad()
	jd := julian.CalendarGregorianToJD(2028, 11, 13.19)
	Δα1, Δδ1 := apparent.Nutation(α, δ, jd)
	fmt.Printf("%.3s  %.3s\n", sexa.NewFmtAngle(Δα1), sexa.NewFmtAngle(Δδ1))
	// Output:
	// 15.843″  6.217″
}
예제 #22
0
func ExampleAberration() {
	// Example 23.a, p. 152
	α := sexa.NewRA(2, 46, 11.331).Rad()
	δ := sexa.NewAngle(false, 49, 20, 54.54).Rad()
	jd := julian.CalendarGregorianToJD(2028, 11, 13.19)
	Δα2, Δδ2 := apparent.Aberration(α, δ, jd)
	fmt.Printf("%.3s  %.3s\n", sexa.NewFmtAngle(Δα2), sexa.NewFmtAngle(Δδ2))
	// Output:
	// 30.045″  6.697″
}
예제 #23
0
func TestApproxNutation(t *testing.T) {
	jd := julian.CalendarGregorianToJD(1987, 4, 10)
	Δψ, Δε := nutation.ApproxNutation(jd)
	if math.Abs(Δψ*(180/math.Pi)*3600+3.788) > .5 {
		t.Fatal(Δψ * (180 / math.Pi) * 3600)
	}
	if math.Abs(Δε*(180/math.Pi)*3600-9.443) > .1 {
		t.Fatal(Δε * (180 / math.Pi) * 3600)
	}
}
예제 #24
0
func TestApproxNutation(t *testing.T) {
	jd := julian.CalendarGregorianToJD(1987, 4, 10)
	Δψ, Δε := nutation.ApproxNutation(jd)
	if math.Abs(Δψ.Sec()+3.788) > .5 {
		t.Fatal(Δψ.Sec())
	}
	if math.Abs(Δε.Sec()-9.443) > .1 {
		t.Fatal(Δε.Sec())
	}
}
예제 #25
0
func ExampleApparentEquatorial() {
	// Example 25.a, p. 165.
	jde := julian.CalendarGregorianToJD(1992, 10, 13)
	α, δ := solar.ApparentEquatorial(jde)
	fmt.Printf("α: %.1d\n", sexa.NewFmtRA(α))
	fmt.Printf("δ: %d\n", sexa.NewFmtAngle(δ))
	// Output:
	// α: 13ʰ13ᵐ31ˢ.4
	// δ: -7°47′6″
}
예제 #26
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ˢ
}
예제 #27
0
func Test2000(t *testing.T) {
	for i := range mar {
		e := &mar[i]
		approx := solstice.March(e.y)
		vsop87 := julian.CalendarGregorianToJD(e.y, 3, e.d) +
			unit.NewTime(' ', e.h, e.m, e.s).Day()
		if math.Abs(vsop87-approx) > 1./24/60 {
			t.Logf("mar %d: got %.5f expected %.5f", e.y, approx, vsop87)
			t.Errorf("%.0f second error", math.Abs(vsop87-approx)*24*60*60)
		}
	}
	for i := range jun {
		e := &jun[i]
		approx := solstice.June(e.y)
		vsop87 := julian.CalendarGregorianToJD(e.y, 6, e.d) +
			unit.NewTime(' ', e.h, e.m, e.s).Day()
		if math.Abs(vsop87-approx) > 1./24/60 {
			t.Logf("jun %d: got %.5f expected %.5f", e.y, approx, vsop87)
			t.Errorf("%.0f second error", math.Abs(vsop87-approx)*24*60*60)
		}
	}
	for i := range sep {
		e := &sep[i]
		approx := solstice.September(e.y)
		vsop87 := julian.CalendarGregorianToJD(e.y, 9, e.d) +
			unit.NewTime(' ', e.h, e.m, e.s).Day()
		if math.Abs(vsop87-approx) > 1./24/60 {
			t.Logf("sep %d: got %.5f expected %.5f", e.y, approx, vsop87)
			t.Errorf("%.0f day error", math.Abs(vsop87-approx))
		}
	}
	for i := range dec {
		e := &dec[i]
		approx := solstice.December(e.y)
		vsop87 := julian.CalendarGregorianToJD(e.y, 12, e.d) +
			unit.NewTime(' ', e.h, e.m, e.s).Day()
		if math.Abs(vsop87-approx) > 1./24/60 {
			t.Logf("dec %d: got %.5f expected %.5f", e.y, approx, vsop87)
			t.Errorf("%.0f second error", math.Abs(vsop87-approx)*24*60*60)
		}
	}
}
예제 #28
0
func TestPhaseAngleEcl2(t *testing.T) {
	j := julian.CalendarGregorianToJD(1992, 4, 12)
	λ, β, _ := moonposition.Position(j)
	λ0 := solar.ApparentLongitude(base.J2000Century(j))
	i := moonillum.PhaseAngleEcl2(λ, β, λ0)
	k := base.Illuminated(i)
	ref := .6775
	if math.Abs(k-ref) > 1e-4 {
		t.Errorf("k = %.4f", k)
	}
}
예제 #29
0
func TestPoly1900to1997(t *testing.T) {
	for y := 1900; y < 1998; y += 2 {
		jd := julian.CalendarGregorianToJD(y, 0, 0)
		t.Logf("%d %.2f  %.1f", y, jd, deltat.Poly1900to1997(jd))
	}
	for _, tp := range []struct {
		year int
		ΔT   float64
	}{
		{1900, -2.8},
		{1950, 29.1},
		{1996, 61.6},
	} {
		jd := julian.CalendarGregorianToJD(tp.year, 0, 0)
		ΔT := deltat.Poly1900to1997(jd)
		if math.Abs(ΔT-tp.ΔT) > 1 {
			t.Fatalf("%#v, got %.1f", tp, ΔT)
		}
	}
}
예제 #30
0
파일: moon_test.go 프로젝트: pjh59/meeus
func ExamplePosition() {
	// Example 47.a, p. 342.
	λ, β, Δ := moon.Position(julian.CalendarGregorianToJD(1992, 4, 12))
	fmt.Printf("λ = %.6f\n", λ*180/math.Pi)
	fmt.Printf("β = %.6f\n", β*180/math.Pi)
	fmt.Printf("Δ = %.1f\n", Δ)
	// Output:
	// λ = 133.162655
	// β = -3.229126
	// Δ = 368409.7
}