Exemple #1
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))
	}
}
Exemple #2
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″
}
Exemple #3
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)
	}
}
Exemple #4
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″
}
Exemple #5
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
}
Exemple #6
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)
		}
	}
}
Exemple #7
0
func ExampleNewRA() {
	// Example 1.a, p. 8.
	a := base.NewRA(9, 14, 55.8)
	fmt.Printf("%.6f\n", math.Tan(a.Rad()))
	// Output:
	// -0.877517
}
Exemple #8
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′
}
Exemple #9
0
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
}
Exemple #10
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)
		}
	}
}
Exemple #11
0
func ExampleLen4Half() {
	// Example 3.f, p. 32.
	half, err := interp.Len4Half([]float64{
		base.NewRA(10, 18, 48.732).Rad(),
		base.NewRA(10, 23, 22.835).Rad(),
		base.NewRA(10, 27, 57.247).Rad(),
		base.NewRA(10, 32, 31.983).Rad(),
	})
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("%.3d", base.NewFmtRA(half))
	// Output:
	// 10ʰ25ᵐ40ˢ.001
}
Exemple #12
0
func ExampleError() {
	// Example p. 124.
	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()

	ω := line.Error(rζ, dζ, rδ, dδ, rε, dε)
	fmt.Println(base.DecSymAdd(fmt.Sprintf("%.6f", ω*180/math.Pi), '°'))
	fmt.Printf("%.0f″\n", ω*3600*180/math.Pi)
	fmt.Println(base.NewFmtAngle(ω))
	// Output:
	// 0°.089876
	// 324″
	// 5′24″
}
Exemple #13
0
func ExampleSmallest_b() {
	// Exercise, p. 128.
	r1 := base.NewRA(9, 5, 41.44).Rad()
	r2 := base.NewRA(9, 9, 29).Rad()
	r3 := base.NewRA(8, 59, 47.14).Rad()
	d1 := base.NewAngle(false, 18, 30, 30).Rad()
	d2 := base.NewAngle(false, 17, 43, 56.7).Rad()
	d3 := base.NewAngle(false, 17, 49, 36.8).Rad()
	d, t := circle.Smallest(r1, d1, r2, d2, r3, d3)
	fmt.Printf("Δ = %.62s\n", base.NewFmtAngle(d))
	if t {
		fmt.Println("type I")
	} else {
		fmt.Println("type II")
	}
	// Output:
	// Δ = 2°19′
	// type I
}
Exemple #14
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″
}
Exemple #15
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″
}
Exemple #16
0
func ExampleSmallest_a() {
	// Example 20.a, p. 128.
	r1 := base.NewRA(12, 41, 8.64).Rad()
	r2 := base.NewRA(12, 52, 5.21).Rad()
	r3 := base.NewRA(12, 39, 28.11).Rad()
	d1 := base.NewAngle(true, 5, 37, 54.2).Rad()
	d2 := base.NewAngle(true, 4, 22, 26.2).Rad()
	d3 := base.NewAngle(true, 1, 50, 3.7).Rad()
	d, t := circle.Smallest(r1, d1, r2, d2, r3, d3)
	fmt.Printf("Δ = %s = %.62s\n",
		base.DecSymAdd(fmt.Sprintf("%.5f", d*180/math.Pi), '°'),
		base.NewFmtAngle(d))
	if t {
		fmt.Println("type I")
	} else {
		fmt.Println("type II")
	}
	// Output:
	// Δ = 4°.26363 = 4°16′
	// type II
}
Exemple #17
0
func ExampleAberrationRonVondrak() {
	// Example 23.b, p. 156
	α := base.NewRA(2, 44, 12.9747).Rad()
	δ := base.NewAngle(false, 49, 13, 39.896).Rad()
	jd := julian.CalendarGregorianToJD(2028, 11, 13.19)
	Δα, Δδ := apparent.AberrationRonVondrak(α, δ, jd)
	fmt.Printf("Δα = %+.9f radian\n", Δα)
	fmt.Printf("Δδ = %+.9f radian\n", Δδ)
	// Output:
	// Δα = +0.000145252 radian
	// Δδ = +0.000032723 radian
}
Exemple #18
0
func TestEqToGal(t *testing.T) {
	g := new(coord.Galactic).EqToGal(&coord.Equatorial{
		RA:  base.NewRA(17, 48, 59.74).Rad(),
		Dec: base.NewAngle(true, 14, 43, 8.2).Rad(),
	})
	if s := fmt.Sprintf("%.4f", g.Lon*180/math.Pi); s != "12.9593" {
		t.Fatal("lon:", s)
	}
	if s := fmt.Sprintf("%+.4f", g.Lat*180/math.Pi); s != "+6.0463" {
		t.Fatal("lat:", s)
	}
}
Exemple #19
0
func ExampleTimes() {
	// 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)
	α3 := []float64{
		base.NewRA(2, 42, 43.25).Rad(),
		base.NewRA(2, 46, 55.51).Rad(),
		base.NewRA(2, 51, 07.69).Rad(),
	}
	δ3 := []float64{
		base.NewAngle(false, 18, 02, 51.4).Rad(),
		base.NewAngle(false, 18, 26, 27.3).Rad(),
		base.NewAngle(false, 18, 49, 38.7).Rad(),
	}
	h0 := rise.Stdh0Stellar
	// Similarly as with Th0, Meeus gives us the value of 56 for ΔT but
	// let's use our package function.
	ΔT := deltat.Interp10A(jd)
	rise, transit, set, err := rise.Times(p, ΔT, h0, Th0, α3, δ3)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println("rising: ", base.NewFmtTime(rise))
	fmt.Println("transit:", base.NewFmtTime(transit))
	fmt.Println("seting: ", base.NewFmtTime(set))
	// Output:
	// rising:  12ʰ26ᵐ9ˢ
	// transit: 19ʰ40ᵐ30ˢ
	// seting:  2ʰ54ᵐ26ˢ
}
Exemple #20
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
}
Exemple #21
0
func ExampleEcliptic_EqToEcl() {
	// Example 13.a, p. 95.
	eq := &coord.Equatorial{
		base.NewRA(7, 45, 18.946).Rad(),
		base.NewAngle(false, 28, 1, 34.26).Rad(),
	}
	obl := coord.NewObliquity(23.4392911 * math.Pi / 180)
	ecl := new(coord.Ecliptic).EqToEcl(eq, obl)
	λStr := base.DecSymAdd(fmt.Sprintf("%.5f", ecl.Lon*180/math.Pi), '°')
	βStr := base.DecSymAdd(fmt.Sprintf("%+.6f", ecl.Lat*180/math.Pi), '°')
	fmt.Println("λ =", λStr)
	fmt.Println("β =", βStr)
	// Output:
	// λ = 113°.21563
	// β = +6°.684170
}
Exemple #22
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
}
Exemple #23
0
func ExampleApproxPosition() {
	// 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
	mα := base.NewHourAngle(true, 0, 0, 0.0169)
	mδ := base.NewAngle(false, 0, 0, 0.006)
	precess.ApproxPosition(eq, eq, epochFrom, epochTo, mα, mδ)
	fmt.Printf("%0.1d\n", base.NewFmtRA(eq.RA))
	fmt.Printf("%+0d\n", base.NewFmtAngle(eq.Dec))
	// Output:
	// 10ʰ07ᵐ12ˢ.1
	// +12°04′32″
}
Exemple #24
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
}
Exemple #25
0
func ExamplePosition() {
	// Example 21.b, p. 135.
	eq := &coord.Equatorial{
		base.NewRA(2, 44, 11.986).Rad(),
		base.NewAngle(false, 49, 13, 42.48).Rad(),
	}
	epochFrom := 2000.0
	jdTo := julian.CalendarGregorianToJD(2028, 11, 13.19)
	epochTo := base.JDEToJulianYear(jdTo)
	precess.Position(eq, eq, epochFrom, epochTo,
		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ᵐ11ˢ.331
	// +49°20′54″.54
}
Exemple #26
0
func TestEquatorial_EclToEq(t *testing.T) {
	// repeat example above
	eq0 := &coord.Equatorial{
		base.NewRA(7, 45, 18.946).Rad(),
		base.NewAngle(false, 28, 1, 34.26).Rad(),
	}
	obl := coord.NewObliquity(23.4392911 * math.Pi / 180)
	ecl := new(coord.Ecliptic).EqToEcl(eq0, obl)

	// now reverse transform
	eq := new(coord.Equatorial).EclToEq(ecl, obl)
	if math.Abs((eq.RA-eq0.RA)/eq.RA) > 1e-15 {
		t.Fatal("RA:", eq0.RA, eq.RA)
	}
	if math.Abs((eq.Dec-eq0.Dec)/eq.Dec) > 1e-15 {
		t.Fatal("Dec:", eq0.Dec, eq.Dec)
	}
}
Exemple #27
0
func ExampleHorizontal_EqToHz() {
	// Example 13.b, p. 95.
	eq := &coord.Equatorial{
		RA:  base.NewRA(23, 9, 16.641).Rad(),
		Dec: base.NewAngle(true, 6, 43, 11.61).Rad(),
	}
	g := &globe.Coord{
		Lat: base.NewAngle(false, 38, 55, 17).Rad(),
		Lon: base.NewAngle(false, 77, 3, 56).Rad(),
	}
	jd := julian.TimeToJD(time.Date(1987, 4, 10, 19, 21, 0, 0, time.UTC))
	st := sidereal.Apparent(jd)
	hz := new(coord.Horizontal).EqToHz(eq, g, st)
	AStr := base.DecSymAdd(fmt.Sprintf("%+.3f", hz.Az*180/math.Pi), '°')
	hStr := base.DecSymAdd(fmt.Sprintf("%+.3f", hz.Alt*180/math.Pi), '°')
	fmt.Println("A =", AStr)
	fmt.Println("h =", hStr)
	// Output:
	// A = +68°.034
	// h = +15°.125
}
Exemple #28
0
// Test with proper motion of Regulus, with equatorial motions given
// in Example 21.a, p. 132, and ecliptic motions given in table 21.A,
// p. 138.
func TestEqProperMotionToEcl(t *testing.T) {
	ε := coord.NewObliquity(nutation.MeanObliquity(base.J2000))
	mλ, mβ := eqProperMotionToEcl(
		// eq motions from p. 132.
		base.NewHourAngle(true, 0, 0, 0.0169).Rad(),
		base.NewAngle(false, 0, 0, 0.006).Rad(),
		2000.0,
		// eq coordinates from p. 132.
		new(coord.Ecliptic).EqToEcl(&coord.Equatorial{
			RA:  base.NewRA(10, 8, 22.3).Rad(),
			Dec: base.NewAngle(false, 11, 58, 2).Rad(),
		}, ε))
	d := math.Abs((mλ - base.NewAngle(true, 0, 0, .2348).Rad()) / mλ)
	if d*169 > 1 { // 169 = significant digits of given lon
		t.Fatal("mλ")
	}
	d = math.Abs((mβ - base.NewAngle(true, 0, 0, 0.0813).Rad()) / mβ)
	if d*6 > 1 { // 6 = significant digit of given lat
		t.Fatal("mβ")
	}
}
Exemple #29
0
func ExamplePlanetary() {
	// Example 18.a, p. 117.

	// Day of month is sufficient for a time scale.
	day1 := 5.
	day5 := 9.

	// Text asks for Mercury-Venus conjunction, so r1, d1 is Venus ephemeris,
	// r2, d2 is Mercury ephemeris.

	// Venus
	r1 := []float64{
		base.NewRA(10, 27, 27.175).Rad(),
		base.NewRA(10, 26, 32.410).Rad(),
		base.NewRA(10, 25, 29.042).Rad(),
		base.NewRA(10, 24, 17.191).Rad(),
		base.NewRA(10, 22, 57.024).Rad(),
	}
	d1 := []float64{
		base.NewAngle(false, 4, 04, 41.83).Rad(),
		base.NewAngle(false, 3, 55, 54.66).Rad(),
		base.NewAngle(false, 3, 48, 03.51).Rad(),
		base.NewAngle(false, 3, 41, 10.25).Rad(),
		base.NewAngle(false, 3, 35, 16.61).Rad(),
	}
	// Mercury
	r2 := []float64{
		base.NewRA(10, 24, 30.125).Rad(),
		base.NewRA(10, 25, 00.342).Rad(),
		base.NewRA(10, 25, 12.515).Rad(),
		base.NewRA(10, 25, 06.235).Rad(),
		base.NewRA(10, 24, 41.185).Rad(),
	}
	d2 := []float64{
		base.NewAngle(false, 6, 26, 32.05).Rad(),
		base.NewAngle(false, 6, 10, 57.72).Rad(),
		base.NewAngle(false, 5, 57, 33.08).Rad(),
		base.NewAngle(false, 5, 46, 27.07).Rad(),
		base.NewAngle(false, 5, 37, 48.45).Rad(),
	}
	// compute conjunction
	day, dd, err := conjunction.Planetary(day1, day5, r1, d1, r2, d2)
	if err != nil {
		fmt.Println(err)
		return
	}
	// time of conjunction
	fmt.Printf("1991 August %.5f\n", day)

	// more useful clock format
	dInt, dFrac := math.Modf(day)
	fmt.Printf("1991 August %d at %s TD\n", int(dInt),
		base.NewFmtTime(dFrac*24*3600))

	// deltat func needs jd
	jd := julian.CalendarGregorianToJD(1991, 8, day)
	// compute UT = TD - ΔT, and separate back into calendar components.
	// (we could use our known calendar components, but this illustrates
	// the more general technique that would allow for rollovers.)
	y, m, d := julian.JDToCalendar(jd - deltat.Interp10A(jd)/(3600*24))
	// format as before
	dInt, dFrac = math.Modf(d)
	fmt.Printf("%d %s %d at %s UT\n", y, time.Month(m), int(dInt),
		base.NewFmtTime(dFrac*24*3600))

	// Δδ
	fmt.Printf("Δδ = %s\n", base.NewFmtAngle(dd))

	// Output:
	// 1991 August 7.23797
	// 1991 August 7 at 5ʰ42ᵐ41ˢ TD
	// 1991 August 7 at 5ʰ41ᵐ43ˢ UT
	// Δδ = 2°8′22″
}
Exemple #30
0
	sH, cH := math.Sincos(H)
	sφ, cφ := math.Sincos(φ)
	sδ, cδ := math.Sincos(ψ)
	A = math.Atan2(sH, cH*sφ-(sδ/cδ)*cφ) // (13.5) p. 93
	h = math.Asin(sφ*sδ + cφ*cδ*cH)      // (13.6) p. 93
	return
}

// Galactic coordinates are referenced to the plane of the Milky Way.
type Galactic struct {
	Lat float64 // Latitude (b) in radians
	Lon float64 // Longitude (l) in radians
}

var galacticNorth = &Equatorial{
	RA:  base.NewRA(12, 49, 0).Rad(),
	Dec: 27.4 * math.Pi / 180,
}

var galacticLon0 = 123 * math.Pi / 180

// EqToGal converts equatorial coordinates to galactic coordinates.
//
// Equatorial coordinates must be referred to the standard equinox of B1950.0.
// For conversion to B1950, see package precess and utility functions in
// package "common".
func (g *Galactic) EqToGal(eq *Equatorial) *Galactic {
	sdα, cdα := math.Sincos(galacticNorth.RA - eq.RA)
	sgδ, cgδ := math.Sincos(galacticNorth.Dec)
	sδ, cδ := math.Sincos(eq.Dec)
	x := math.Atan2(sdα, cdα*sgδ-(sδ/cδ)*cgδ)           // (13.7) p. 94