Esempio n. 1
0
func ExampleRing() {
	// Example 45.a, p. 320
	earth, err := pp.LoadPlanet(pp.Earth, "")
	if err != nil {
		fmt.Println(err)
		return
	}
	saturn, err := pp.LoadPlanet(pp.Saturn, "")
	if err != nil {
		fmt.Println(err)
		return
	}
	B, Bʹ, ΔU, P, a, b := saturnring.Ring(2448972.50068, earth, saturn)
	fmt.Printf("B  = %.3f\n", B*180/math.Pi)
	fmt.Printf("Bʹ = %.3f\n", Bʹ*180/math.Pi)
	fmt.Printf("ΔU = %.3f\n", ΔU*180/math.Pi)
	fmt.Printf("P  = %.3f\n", P*180/math.Pi)
	fmt.Printf("a  = %.2d\n", base.NewFmtAngle(a))
	fmt.Printf("b  = %.2d\n", base.NewFmtAngle(b))
	// Output:
	// B  = 16.442
	// Bʹ = 14.679
	// ΔU = 4.198
	// P  = 6.741
	// a  = 35″.87
	// b  = 10″.15
}
Esempio n. 2
0
func ExampleAberration() {
	// Example 23.a, p. 152
	α := base.NewRA(2, 46, 11.331).Rad()
	δ := base.NewAngle(false, 49, 20, 54.54).Rad()
	jd := julian.CalendarGregorianToJD(2028, 11, 13.19)
	Δα2, Δδ2 := apparent.Aberration(α, δ, jd)
	fmt.Printf("%.3s  %.3s\n", base.NewFmtAngle(Δα2), base.NewFmtAngle(Δδ2))
	// Output:
	// 30.045″  6.697″
}
Esempio n. 3
0
func ExampleNutation() {
	// Example 23.a, p. 152
	α := base.NewRA(2, 46, 11.331).Rad()
	δ := base.NewAngle(false, 49, 20, 54.54).Rad()
	jd := julian.CalendarGregorianToJD(2028, 11, 13.19)
	Δα1, Δδ1 := apparent.Nutation(α, δ, jd)
	fmt.Printf("%.3s  %.3s\n", base.NewFmtAngle(Δα1), base.NewFmtAngle(Δδ1))
	// Output:
	// 15.843″  6.217″
}
Esempio n. 4
0
func ExampleNewAngle() {
	// Example negative values, p. 9.
	a := base.NewAngle(true, 13, 47, 22)
	fmt.Println(base.NewFmtAngle(a.Rad()))
	a = base.NewAngle(true, 0, 32, 41)
	// use # flag to force output of all three components
	fmt.Printf("%#s\n", base.NewFmtAngle(a.Rad()))
	// Output:
	// -13°47′22″
	// -0°32′41″
}
Esempio n. 5
0
func ExampleStellar() {
	// Exercise, p. 119.
	day1 := 7.
	day5 := 27.
	r2 := []float64{
		base.NewRA(15, 3, 51.937).Rad(),
		base.NewRA(15, 9, 57.327).Rad(),
		base.NewRA(15, 15, 37.898).Rad(),
		base.NewRA(15, 20, 50.632).Rad(),
		base.NewRA(15, 25, 32.695).Rad(),
	}
	d2 := []float64{
		base.NewAngle(true, 8, 57, 34.51).Rad(),
		base.NewAngle(true, 9, 9, 03.88).Rad(),
		base.NewAngle(true, 9, 17, 37.94).Rad(),
		base.NewAngle(true, 9, 23, 16.25).Rad(),
		base.NewAngle(true, 9, 26, 01.01).Rad(),
	}
	jd := julian.CalendarGregorianToJD(1996, 2, 17)
	dt := jd - base.J2000
	dy := dt / base.JulianYear
	dc := dy / 100
	fmt.Printf("%.2f years\n", dy)
	fmt.Printf("%.4f century\n", dc)

	pmr := -.649 // sec/cen
	pmd := -1.91 // sec/cen
	r1 := base.NewRA(15, 17, 0.421+pmr*dc).Rad()
	// Careful with quick and dirty way of applying correction to seconds
	// component before converting to radians.  The dec here is negative
	// so correction must be subtracted.  Alternative, less error-prone,
	// way would be to convert both to radians, then add.
	d1 := base.NewAngle(true, 9, 22, 58.54-pmd*dc).Rad()
	fmt.Printf("α′ = %.3d, δ′ = %.2d\n",
		base.NewFmtRA(r1), base.NewFmtAngle(d1))

	day, dd, err := conjunction.Stellar(day1, day5, r1, d1, r2, d2)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(base.NewFmtAngle(dd))
	dInt, dFrac := math.Modf(day)
	fmt.Printf("1996 February %d at %s TD\n", int(dInt),
		base.NewFmtTime(dFrac*24*3600))

	// Output:
	// -3.87 years
	// -0.0387 century
	// α′ = 15ʰ17ᵐ0ˢ.446, δ′ = -9°22′58″.47
	// 3′38″
	// 1996 February 18 at 6ʰ36ᵐ55ˢ TD
}
Esempio n. 6
0
func ExampleEclipticAtHorizon() {
	ε := 23.44 * math.Pi / 180
	φ := 51 * math.Pi / 180
	θ := 75 * math.Pi / 180
	λ1, λ2, I := parallactic.EclipticAtHorizon(ε, φ, θ)
	fmt.Println(base.NewFmtAngle(λ1))
	fmt.Println(base.NewFmtAngle(λ2))
	fmt.Println(base.NewFmtAngle(I))
	// Output:
	// 169°21′30″
	// 349°21′30″
	// 61°53′14″
}
Esempio n. 7
0
func TestDiurnalPathAtHorizon(t *testing.T) {
	φ := 40 * math.Pi / 180
	ε := 23.44 * math.Pi / 180
	J := parallactic.DiurnalPathAtHorizon(0, φ)
	Jexp := math.Pi/2 - φ
	if math.Abs((J-Jexp)/Jexp) > 1e-15 {
		t.Fatal("0 dec:", base.NewFmtAngle(J))
	}
	J = parallactic.DiurnalPathAtHorizon(ε, φ)
	Jexp = base.NewAngle(false, 45, 31, 0).Rad()
	if math.Abs((J-Jexp)/Jexp) > 1e-3 {
		t.Fatal("solstace:", base.NewFmtAngle(J))
	}
}
Esempio n. 8
0
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", base.NewFmtRA(α))
	fmt.Printf("δ = %.0d\n", base.NewFmtAngle(δ))
	fmt.Printf("ψ = %.2f\n", ψ*180/math.Pi)
	// Output:
	// α = 10ʰ34ᵐ14ˢ.2
	// δ = 19°9′31″
	// ψ = 40.51
}
Esempio n. 9
0
func ExampleProperMotion3D() {
	// Example 21.d, p. 141.
	eqFrom := &coord.Equatorial{
		RA:  base.NewRA(6, 45, 8.871).Rad(),
		Dec: base.NewAngle(true, 16, 42, 57.99).Rad(),
	}
	mra := base.NewHourAngle(false, 0, 0, -0.03847)
	mdec := base.NewAngle(false, 0, 0, -1.2053)
	r := 2.64           // given in correct unit
	mr := -7.6 / 977792 // magic conversion factor
	eqTo := &coord.Equatorial{}
	fmt.Printf("Δr = %.9f, Δα = %.10f, Δδ = %.10f\n", mr, mra, mdec)
	for _, epoch := range []float64{1000, 0, -1000, -2000, -10000} {
		precess.ProperMotion3D(eqFrom, eqTo, 2000, epoch, r, mr, mra, mdec)
		fmt.Printf("%8.1f  %0.2d  %-0.1d\n", epoch,
			base.NewFmtRA(eqTo.RA), base.NewFmtAngle(eqTo.Dec))
	}
	// Output:
	// Δr = -0.000007773, Δα = -0.0000027976, Δδ = -0.0000058435
	//   1000.0  6ʰ45ᵐ47ˢ.16  -16°22′56″.0
	//      0.0  6ʰ46ᵐ25ˢ.09  -16°03′00″.8
	//  -1000.0  6ʰ47ᵐ02ˢ.67  -15°43′12″.3
	//  -2000.0  6ʰ47ᵐ39ˢ.91  -15°23′30″.6
	// -10000.0  6ʰ52ᵐ25ˢ.72  -12°50′06″.7
}
Esempio n. 10
0
// Exercise, p. 136.
func TestPosition(t *testing.T) {
	eqFrom := &coord.Equatorial{
		base.NewRA(2, 31, 48.704).Rad(),
		base.NewAngle(false, 89, 15, 50.72).Rad(),
	}
	eqTo := &coord.Equatorial{}
	mα := base.NewHourAngle(false, 0, 0, 0.19877)
	mδ := base.NewAngle(true, 0, 0, 0.0152)
	for _, tc := range []struct {
		α, δ string
		jde  float64
	}{
		{"1 22 33.90", "88 46 26.18", base.BesselianYearToJDE(1900)},
		{"3 48 16.43", "89 27 15.38", base.JulianYearToJDE(2050)},
		{"5 53 29.17", "89 32 22.18", base.JulianYearToJDE(2100)},
	} {
		epochTo := base.JDEToJulianYear(tc.jde)
		precess.Position(eqFrom, eqTo, 2000.0, epochTo, mα, mδ)
		αStr := fmt.Sprintf("%.2x", base.NewFmtRA(eqTo.RA))
		δStr := fmt.Sprintf("%.2x", base.NewFmtAngle(eqTo.Dec))
		if αStr != tc.α {
			t.Fatal("got:", αStr, "want:", tc.α)
		}
		if δStr != tc.δ {
			t.Fatal(δStr)
		}
	}
}
Esempio n. 11
0
func ExampleApparentLongitude() {
	// Example 25.a, p. 165.
	T := base.J2000Century(julian.CalendarGregorianToJD(1992, 10, 13))
	fmt.Println("λ:", base.NewFmtAngle(solar.ApparentLongitude(T)))
	// Output:
	// λ: 199°54′32″
}
Esempio n. 12
0
func ExampleAngleError() {
	// Example p. 125.
	rδ := base.NewRA(5, 32, 0.40).Rad()
	dδ := base.NewAngle(true, 0, 17, 56.9).Rad()
	rε := base.NewRA(5, 36, 12.81).Rad()
	dε := base.NewAngle(true, 1, 12, 7.0).Rad()
	rζ := base.NewRA(5, 40, 45.52).Rad()
	dζ := base.NewAngle(true, 1, 56, 33.3).Rad()

	n, ω := line.AngleError(rδ, dδ, rε, dε, rζ, dζ)
	fmt.Printf("%.62s\n", base.NewFmtAngle(n))
	fmt.Println(base.NewFmtAngle(ω))
	// Output:
	// 7°31′
	// -5′24″
}
Esempio n. 13
0
func TestPrecessor_Precess(t *testing.T) {
	// Exercise, p. 136.
	eqFrom := &coord.Equatorial{
		RA:  base.NewRA(2, 31, 48.704).Rad(),
		Dec: base.NewAngle(false, 89, 15, 50.72).Rad(),
	}
	mα := base.NewHourAngle(false, 0, 0, .19877)
	mδ := base.NewAngle(false, 0, 0, -.0152)
	epochs := []float64{
		base.JDEToJulianYear(base.B1900),
		2050,
		2100,
	}
	answer := []string{
		"α = 1ʰ22ᵐ33ˢ.90   δ = +88°46′26″.18",
		"α = 3ʰ48ᵐ16ˢ.43   δ = +89°27′15″.38",
		"α = 5ʰ53ᵐ29ˢ.17   δ = +89°32′22″.18",
	}
	eqTo := &coord.Equatorial{}
	for i, epochTo := range epochs {
		precess.Position(eqFrom, eqTo, 2000, epochTo, mα, mδ)
		if answer[i] != fmt.Sprintf("α = %0.2d   δ = %+0.2d",
			base.NewFmtRA(eqTo.RA), base.NewFmtAngle(eqTo.Dec)) {
			t.Fatal(i)
		}
	}
}
Esempio n. 14
0
// p. 83
func TestLatDiff(t *testing.T) {
	φ0 := base.NewAngle(false, 45, 5, 46.36).Rad()
	diff := base.NewFmtAngle(globe.GeocentricLatitudeDifference(φ0))
	if f := fmt.Sprintf("%.2d", diff); f != "11′32″.73" {
		t.Fatal(f)
	}
}
Esempio n. 15
0
func ExampleNutation() {
	// Example 22.a, p. 148.
	jd := julian.CalendarGregorianToJD(1987, 4, 10)
	Δψ, Δε := nutation.Nutation(jd)
	ε0 := nutation.MeanObliquity(jd)
	ε := ε0 + Δε
	fmt.Printf("%+.3d\n", base.NewFmtAngle(Δψ))
	fmt.Printf("%+.3d\n", base.NewFmtAngle(Δε))
	fmt.Printf("%.3d\n", base.NewFmtAngle(ε0))
	fmt.Printf("%.3d\n", base.NewFmtAngle(ε))
	// Output:
	// -3″.788
	// +9″.443
	// 23°26′27″.407
	// 23°26′36″.850
}
Esempio n. 16
0
func ExampleApogeeParallax() {
	// Example 50.a, p. 357.
	p := apsis.ApogeeParallax(1988.75)
	fmt.Printf("%.3f\n", p*180/math.Pi*3600)
	fmt.Printf("%0.3d\n", base.NewFmtAngle(p))
	// Output:
	// 3240.679
	// 54′00″.679
}
Esempio n. 17
0
// Second exercise, p. 110.
func TestMinSep(t *testing.T) {
	sep, err := angle.MinSep(jd1, jd3, r1, d1, r2, d2)
	if err != nil {
		t.Fatal(err)
	}
	answer := .5017 * math.Pi / 180 // on p. 111
	if math.Abs((sep-answer)/sep) > 1e-3 {
		t.Fatal(base.NewFmtAngle(sep))
	}
}
Esempio n. 18
0
func ExampleApparentEquatorial() {
	// Example 25.a, p. 165.
	jde := julian.CalendarGregorianToJD(1992, 10, 13)
	α, δ := solar.ApparentEquatorial(jde)
	fmt.Printf("α: %.1d\n", base.NewFmtRA(α))
	fmt.Printf("δ: %d\n", base.NewFmtAngle(δ))
	// Output:
	// α: 13ʰ13ᵐ31ˢ.4
	// δ: -7°47′6″
}
Esempio n. 19
0
// First exercise, p. 110.
func TestSep(t *testing.T) {
	r1 := base.NewRA(4, 35, 55.2).Rad()
	d1 := base.NewAngle(false, 16, 30, 33).Rad()
	r2 := base.NewRA(16, 29, 24).Rad()
	d2 := base.NewAngle(true, 26, 25, 55).Rad()
	d := angle.Sep(r1, d1, r2, d2)
	answer := base.NewAngle(false, 169, 58, 0).Rad()
	if math.Abs(d-answer) > 1e-4 {
		t.Fatal(base.NewFmtAngle(d))
	}
}
Esempio n. 20
0
func ExampleSep() {
	// Example 17.a, p. 110.
	r1 := base.NewRA(14, 15, 39.7).Rad()
	d1 := base.NewAngle(false, 19, 10, 57).Rad()
	r2 := base.NewRA(13, 25, 11.6).Rad()
	d2 := base.NewAngle(true, 11, 9, 41).Rad()
	d := angle.Sep(r1, d1, r2, d2)
	fmt.Println(base.NewFmtAngle(d))
	// Output:
	// 32°47′35″
}
Esempio n. 21
0
func TestSepHav(t *testing.T) {
	// Example 17.a, p. 110.
	r1 := base.NewRA(14, 15, 39.7).Rad()
	d1 := base.NewAngle(false, 19, 10, 57).Rad()
	r2 := base.NewRA(13, 25, 11.6).Rad()
	d2 := base.NewAngle(true, 11, 9, 41).Rad()
	d := angle.SepHav(r1, d1, r2, d2)
	s := fmt.Sprint(base.NewFmtAngle(d))
	if s != "32°47′35″" {
		t.Fatal(s)
	}
}
Esempio n. 22
0
func ExampleTopocentric() {
	// Example 40.a, p. 280
	α, δ := parallax.Topocentric(339.530208*math.Pi/180,
		-15.771083*math.Pi/180,
		.37276, .546861, .836339,
		base.NewHourAngle(false, 7, 47, 27).Rad(),
		julian.CalendarGregorianToJD(2003, 8, 28+(3+17./60)/24))
	fmt.Printf("α' = %.2d\n", base.NewFmtRA(α))
	fmt.Printf("δ' = %.1d\n", base.NewFmtAngle(δ))
	// Output:
	// α' = 22ʰ38ᵐ8ˢ.54
	// δ' = -15°46′30″.0
}
Esempio n. 23
0
func ExampleAstrometric() {
	// Example 37.a, p. 266
	e, err := pp.LoadPlanet(pp.Earth, "")
	if err != nil {
		fmt.Println(err)
		return
	}
	α, δ := pluto.Astrometric(2448908.5, e)
	fmt.Printf("α: %.1d\n", base.NewFmtRA(α))
	fmt.Printf("δ: %.0d\n", base.NewFmtAngle(δ))
	// Output:
	// α: 15ʰ31ᵐ43ˢ.8
	// δ: -4°27′29″
}
Esempio n. 24
0
func ExampleApproxAnnualPrecession() {
	// Example 21.a, p. 132.
	eq := &coord.Equatorial{
		base.NewRA(10, 8, 22.3).Rad(),
		base.NewAngle(false, 11, 58, 2).Rad(),
	}
	epochFrom := 2000.0
	epochTo := 1978.0
	Δα, Δδ := precess.ApproxAnnualPrecession(eq, epochFrom, epochTo)
	fmt.Printf("%+.3d\n", base.NewFmtHourAngle(Δα.Rad()))
	fmt.Printf("%+.2d\n", base.NewFmtAngle(Δδ.Rad()))
	// Output:
	// +3ˢ.207
	// -17″.71
}
Esempio n. 25
0
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("%.62d\n", base.NewFmtAngle(e))
	// Output:
	// 2449314.14
	// 1993 November 22, at 15ʰ
	// 19.7506 deg
	// 19°45′
}
Esempio n. 26
0
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′
}
Esempio n. 27
0
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′
}
Esempio n. 28
0
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″
}
Esempio n. 29
0
func ExampleAngle() {
	// Example p. 123.
	rδ := base.NewRA(5, 32, 0.40).Rad()
	dδ := base.NewAngle(true, 0, 17, 56.9).Rad()
	rε := base.NewRA(5, 36, 12.81).Rad()
	dε := base.NewAngle(true, 1, 12, 7.0).Rad()
	rζ := base.NewRA(5, 40, 45.52).Rad()
	dζ := base.NewAngle(true, 1, 56, 33.3).Rad()

	n := line.Angle(rδ, dδ, rε, dε, rζ, dζ)
	fmt.Printf("%.4f degrees\n", n*180/math.Pi)
	fmt.Printf("%.62s\n", base.NewFmtAngle(n))
	// Output:
	// 172.4830 degrees
	// 172°29′
}
Esempio n. 30
0
func ExamplePositionRonVondrak() {
	// Example 23.b, p. 156
	jd := julian.CalendarGregorianToJD(2028, 11, 13.19)
	eq := &coord.Equatorial{
		RA:  base.NewRA(2, 44, 11.986).Rad(),
		Dec: base.NewAngle(false, 49, 13, 42.48).Rad(),
	}
	apparent.PositionRonVondrak(eq, eq, base.JDEToJulianYear(jd),
		base.NewHourAngle(false, 0, 0, 0.03425),
		base.NewAngle(true, 0, 0, 0.0895))
	fmt.Printf("α = %0.3d\n", base.NewFmtRA(eq.RA))
	fmt.Printf("δ = %0.2d\n", base.NewFmtAngle(eq.Dec))
	// Output:
	// α = 2ʰ46ᵐ14ˢ.392
	// δ = 49°21′07″.45
}