func ExampleTimes() { // Example 15.a, p. 103. // Venus on 1988 March 20 p := globe.Coord{ Lon: unit.NewAngle(' ', 71, 5, 0), Lat: unit.NewAngle(' ', 42, 20, 0), } Th0 := unit.NewTime(' ', 11, 50, 58.1) α3 := []unit.RA{ unit.NewRA(2, 42, 43.25), unit.NewRA(2, 46, 55.51), unit.NewRA(2, 51, 07.69), } δ3 := []unit.Angle{ unit.NewAngle(' ', 18, 02, 51.4), unit.NewAngle(' ', 18, 26, 27.3), unit.NewAngle(' ', 18, 49, 38.7), } h0 := unit.AngleFromDeg(-.5667) ΔT := unit.Time(56) tRise, tTransit, tSet, err := rise.Times(p, ΔT, h0, Th0, α3, δ3) 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: // rising: +0.51766 12ʰ25ᵐ26ˢ // transit: +0.81980 19ʰ40ᵐ30ˢ // seting: +0.12130 02ʰ54ᵐ40ˢ }
// First exercise, p. 110. func TestSep(t *testing.T) { r1 := unit.NewRA(4, 35, 55.2).Angle() d1 := unit.NewAngle(' ', 16, 30, 33) r2 := unit.NewRA(16, 29, 24).Angle() d2 := unit.NewAngle('-', 26, 25, 55) d := angle.Sep(r1, d1, r2, d2) answer := unit.NewAngle(' ', 169, 58, 0) if math.Abs((d - answer).Rad()) > 1e-4 { t.Fatal(d, answer) } }
func ExampleSep() { // Example 17.a, p. 110. r1 := unit.NewRA(14, 15, 39.7).Angle() d1 := unit.NewAngle(' ', 19, 10, 57) r2 := unit.NewRA(13, 25, 11.6).Angle() d2 := unit.NewAngle('-', 11, 9, 41) d := angle.Sep(r1, d1, r2, d2) fmt.Println(sexa.FmtAngle(d)) // Output: // 32°47′35″ }
func TestSepHav(t *testing.T) { // Example 17.a, p. 110. r1 := unit.NewRA(14, 15, 39.7).Angle() d1 := unit.NewAngle(' ', 19, 10, 57) r2 := unit.NewRA(13, 25, 11.6).Angle() d2 := unit.NewAngle('-', 11, 9, 41) d := angle.SepHav(r1, d1, r2, d2) s := fmt.Sprint(sexa.FmtAngle(d)) if s != "32°47′35″" { t.Fatal(s) } }
func ExampleAngle() { // Example p. 123. rδ := unit.NewRA(5, 32, 0.40).Angle() dδ := unit.NewAngle('-', 0, 17, 56.9) rε := unit.NewRA(5, 36, 12.81).Angle() dε := unit.NewAngle('-', 1, 12, 7.0) rζ := unit.NewRA(5, 40, 45.52).Angle() dζ := unit.NewAngle('-', 1, 56, 33.3) n := line.Angle(rδ, dδ, rε, dε, rζ, dζ) fmt.Printf("%.4f degrees\n", n.Deg()) fmt.Printf("%m\n", sexa.FmtAngle(n)) // Output: // 172.4830 degrees // 172°29′ }
func TestPrecessor_Precess(t *testing.T) { // Exercise, p. 136. eqFrom := &coord.Equatorial{ RA: unit.NewRA(2, 31, 48.704), Dec: unit.NewAngle(' ', 89, 15, 50.72), } mα := unit.HourAngleFromSec(.19877) mδ := unit.AngleFromSec(-.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", sexa.FmtRA(eqTo.RA), sexa.FmtAngle(eqTo.Dec)) { t.Fatal(i) } } }
func ExampleProperMotion3D() { // Example 21.d, p. 141. eqFrom := &coord.Equatorial{ RA: unit.NewRA(6, 45, 8.871), Dec: unit.NewAngle('-', 16, 42, 57.99), } mra := unit.HourAngleFromSec(-0.03847) mdec := unit.AngleFromSec(-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, sexa.FmtRA(eqTo.RA), sexa.FmtAngle(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 }
// Exercise, p. 136. func TestPosition(t *testing.T) { eqFrom := &coord.Equatorial{ unit.NewRA(2, 31, 48.704), unit.NewAngle(' ', 89, 15, 50.72), } eqTo := &coord.Equatorial{} mα := unit.HourAngleFromSec(0.19877) mδ := unit.AngleFromSec(-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("%.2s", sexa.FmtRA(eqTo.RA)) δStr := fmt.Sprintf("%.2s", sexa.FmtAngle(eqTo.Dec)) if αStr != tc.α { t.Fatal("got:", αStr, "want:", tc.α) } if δStr != tc.δ { t.Fatal(δStr) } } }
func ExampleApproxTimes() { // Example 15.a, p. 103. // Venus on 1988 March 20 p := globe.Coord{ Lon: unit.NewAngle(' ', 71, 5, 0), Lat: unit.NewAngle(' ', 42, 20, 0), } Th0 := unit.NewTime(' ', 11, 50, 58.1) α := unit.NewRA(2, 46, 55.51) δ := unit.NewAngle(' ', 18, 26, 27.3) h0 := rise.Stdh0Stellar tRise, tTransit, tSet, err := rise.ApproxTimes(p, h0, Th0, α, δ) if err != nil { fmt.Println(err) return } // Units for "m" values given near top of p. 104 are day fraction. 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: // rising: +0.51816 12ʰ26ᵐ09ˢ // transit: +0.81965 19ʰ40ᵐ17ˢ // seting: +0.12113 02ʰ54ᵐ26ˢ }
func ExampleAngleError() { // Example p. 125. rδ := unit.NewRA(5, 32, 0.40).Angle() dδ := unit.NewAngle('-', 0, 17, 56.9) rε := unit.NewRA(5, 36, 12.81).Angle() dε := unit.NewAngle('-', 1, 12, 7.0) rζ := unit.NewRA(5, 40, 45.52).Angle() dζ := unit.NewAngle('-', 1, 56, 33.3) n, ω := line.AngleError(rδ, dδ, rε, dε, rζ, dζ) fmt.Printf("%m\n", sexa.FmtAngle(n)) fmt.Println(sexa.FmtAngle(ω)) // Output: // 7°31′ // -5′24″ }
func ExampleError() { // Example p. 124. rδ := unit.NewRA(5, 32, 0.40).Angle() dδ := unit.NewAngle('-', 0, 17, 56.9) rε := unit.NewRA(5, 36, 12.81).Angle() dε := unit.NewAngle('-', 1, 12, 7.0) rζ := unit.NewRA(5, 40, 45.52).Angle() dζ := unit.NewAngle('-', 1, 56, 33.3) ω := line.Error(rζ, dζ, rδ, dδ, rε, dε) e := sexa.FmtAngle(ω) fmt.Printf("%.6j\n", e) fmt.Printf("%.0f″\n", ω.Sec()) fmt.Println(e) // Output: // 0°.089876 // 324″ // 5′24″ }
func ExampleSmallest_b() { // Exercise, p. 128. r1 := unit.NewRA(9, 5, 41.44).Angle() r2 := unit.NewRA(9, 9, 29).Angle() r3 := unit.NewRA(8, 59, 47.14).Angle() d1 := unit.NewAngle(' ', 18, 30, 30) d2 := unit.NewAngle(' ', 17, 43, 56.7) d3 := unit.NewAngle(' ', 17, 49, 36.8) d, t := circle.Smallest(r1, d1, r2, d2, r3, d3) fmt.Printf("Δ = %m\n", sexa.FmtAngle(d)) if t { fmt.Println("type I") } else { fmt.Println("type II") } // Output: // Δ = 2°19′ // type I }
func ExampleSmallest_a() { // Example 20.a, p. 128. r1 := unit.NewRA(12, 41, 8.64).Angle() r2 := unit.NewRA(12, 52, 5.21).Angle() r3 := unit.NewRA(12, 39, 28.11).Angle() d1 := unit.NewAngle('-', 5, 37, 54.2) d2 := unit.NewAngle('-', 4, 22, 26.2) d3 := unit.NewAngle('-', 1, 50, 3.7) d, t := circle.Smallest(r1, d1, r2, d2, r3, d3) fd := sexa.FmtAngle(d) fmt.Printf("Δ = %.5j = %m\n", fd, fd) if t { fmt.Println("type I") } else { fmt.Println("type II") } // Output: // Δ = 4°.26363 = 4°16′ // type II }
func ExampleAberration() { // Example 23.a, p. 152 α := unit.NewRA(2, 46, 11.331) δ := unit.NewAngle(' ', 49, 20, 54.54) jd := julian.CalendarGregorianToJD(2028, 11, 13.19) Δα2, Δδ2 := apparent.Aberration(α, δ, jd) fmt.Printf("%.3s %.3s\n", sexa.FmtAngle(unit.Angle(Δα2)), // (Δα2 is in HourAngle) sexa.FmtAngle(Δδ2)) // Output: // 30.045″ 6.697″ }
func TestEqToGal(t *testing.T) { g := new(coord.Galactic).EqToGal(&coord.Equatorial{ RA: unit.NewRA(17, 48, 59.74), Dec: unit.NewAngle('-', 14, 43, 8.2), }) if s := fmt.Sprintf("%.4f", g.Lon.Deg()); s != "12.9593" { t.Fatal("lon:", s) } if s := fmt.Sprintf("%+.4f", g.Lat.Deg()); s != "+6.0463" { t.Fatal("lat:", s) } }
func ExampleAberrationRonVondrak() { // Example 23.b, p. 156 α := unit.NewRA(2, 44, 12.9747) δ := unit.NewAngle(' ', 49, 13, 39.896) 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 }
func ExampleNutation() { // Example 23.a, p. 152 α := unit.NewRA(2, 46, 11.331) δ := unit.NewAngle(' ', 49, 20, 54.54) jd := julian.CalendarGregorianToJD(2028, 11, 13.19) Δα1, Δδ1 := apparent.Nutation(α, δ, jd) fmt.Printf("%.3s %.3s\n", sexa.FmtAngle(unit.Angle(Δα1)), // (Δα1 is in HourAngle) sexa.FmtAngle(Δδ1)) // Output: // 15.843″ 6.217″ }
func ExampleEcliptic_EqToEcl() { // Example 13.a, p. 95. eq := &coord.Equatorial{ unit.NewRA(7, 45, 18.946), unit.NewAngle(' ', 28, 1, 34.26), } obl := coord.NewObliquity(unit.AngleFromDeg(23.4392911)) ecl := new(coord.Ecliptic).EqToEcl(eq, obl) fmt.Printf("λ = %.5j\n", sexa.FmtAngle(ecl.Lon)) fmt.Printf("β = %+.6j\n", sexa.FmtAngle(ecl.Lat)) // Output: // λ = 113°.21563 // β = +6°.684170 }
func ExampleApproxAnnualPrecession() { // Example 21.a, p. 132. eq := &coord.Equatorial{ unit.NewRA(10, 8, 22.3), unit.NewAngle(' ', 11, 58, 2), } epochFrom := 2000.0 epochTo := 1978.0 Δα, Δδ := precess.ApproxAnnualPrecession(eq, epochFrom, epochTo) fmt.Printf("%+.3d\n", sexa.FmtHourAngle(Δα)) fmt.Printf("%+.2d\n", sexa.FmtAngle(Δδ)) // Output: // +3ˢ.207 // -17″.71 }
func ExamplePositionRonVondrak() { // Example 23.b, p. 156 jd := julian.CalendarGregorianToJD(2028, 11, 13.19) eq := &coord.Equatorial{ RA: unit.NewRA(2, 44, 11.986), Dec: unit.NewAngle(' ', 49, 13, 42.48), } apparent.PositionRonVondrak(eq, eq, base.JDEToJulianYear(jd), unit.HourAngleFromSec(.03425), unit.AngleFromSec(-.0895)) fmt.Printf("α = %0.3d\n", sexa.FmtRA(eq.RA)) fmt.Printf("δ = %0.2d\n", sexa.FmtAngle(eq.Dec)) // Output: // α = 2ʰ46ᵐ14ˢ.392 // δ = 49°21′07″.45 }
func ExampleApproxPosition() { // Example 21.a, p. 132. eq := &coord.Equatorial{ unit.NewRA(10, 8, 22.3), unit.NewAngle(' ', 11, 58, 2), } epochFrom := 2000.0 epochTo := 1978.0 mα := unit.HourAngleFromSec(-0.0169) mδ := unit.AngleFromSec(0.006) precess.ApproxPosition(eq, eq, epochFrom, epochTo, mα, mδ) fmt.Printf("%0.1d\n", sexa.FmtRA(eq.RA)) fmt.Printf("%+0d\n", sexa.FmtAngle(eq.Dec)) // Output: // 10ʰ07ᵐ12ˢ.1 // +12°04′32″ }
func TestEquatorial_EclToEq(t *testing.T) { // repeat example above eq0 := &coord.Equatorial{ unit.NewRA(7, 45, 18.946), unit.NewAngle(' ', 28, 1, 34.26), } 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).Rad()/eq.RA.Rad()) > 1e-15 { t.Fatal("RA:", eq0.RA, eq.RA) } if math.Abs((eq.Dec-eq0.Dec).Rad()/eq.Dec.Rad()) > 1e-15 { t.Fatal("Dec:", eq0.Dec, eq.Dec) } }
func ExamplePosition() { // Example 21.b, p. 135. eq := &coord.Equatorial{ unit.NewRA(2, 44, 11.986), unit.NewAngle(' ', 49, 13, 42.48), } epochFrom := 2000.0 jdTo := julian.CalendarGregorianToJD(2028, 11, 13.19) epochTo := base.JDEToJulianYear(jdTo) precess.Position(eq, eq, epochFrom, epochTo, unit.HourAngleFromSec(0.03425), unit.AngleFromSec(-0.0895)) fmt.Printf("%0.3d\n", sexa.FmtRA(eq.RA)) fmt.Printf("%+0.2d\n", sexa.FmtAngle(eq.Dec)) // Output: // 2ʰ46ᵐ11ˢ.331 // +49°20′54″.54 }
func ExampleHorizontal_EqToHz() { // Example 13.b, p. 95. eq := &coord.Equatorial{ RA: unit.NewRA(23, 9, 16.641), Dec: unit.NewAngle('-', 6, 43, 11.61), } g := &globe.Coord{ Lat: unit.NewAngle(' ', 38, 55, 17), Lon: unit.NewAngle(' ', 77, 3, 56), } 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) fmt.Printf("A = %+.3j\n", sexa.FmtAngle(hz.Az)) fmt.Printf("h = %+.3j\n", sexa.FmtAngle(hz.Alt)) // Output: // A = +68°.034 // h = +15°.125 }
func ExampleStellar() { // Exercise, p. 119. day1 := 7. day5 := 27. r2 := []unit.Angle{ unit.NewRA(15, 3, 51.937).Angle(), unit.NewRA(15, 9, 57.327).Angle(), unit.NewRA(15, 15, 37.898).Angle(), unit.NewRA(15, 20, 50.632).Angle(), unit.NewRA(15, 25, 32.695).Angle(), } d2 := []unit.Angle{ unit.NewAngle('-', 8, 57, 34.51), unit.NewAngle('-', 9, 9, 03.88), unit.NewAngle('-', 9, 17, 37.94), unit.NewAngle('-', 9, 23, 16.25), unit.NewAngle('-', 9, 26, 01.01), } 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 := unit.NewRA(15, 17, 0.421) + unit.RAFromSec(pmr*dc) d1 := unit.NewAngle('-', 9, 22, 58.54) + unit.AngleFromSec(pmd*dc) fmt.Printf("α′ = %.3d, δ′ = %.2d\n", sexa.FmtRA(r1), sexa.FmtAngle(d1)) day, dd, err := conjunction.Stellar(day1, day5, r1.Angle(), d1, r2, d2) if err != nil { fmt.Println(err) return } fmt.Println(sexa.FmtAngle(dd)) dInt, dFrac := math.Modf(day) fmt.Printf("1996 February %d at %s TD\n", int(dInt), sexa.FmtTime(unit.TimeFromDay(dFrac))) // 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 }
// 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. unit.NewHourAngle('-', 0, 0, 0.0169), unit.NewAngle(' ', 0, 0, 0.006), 2000.0, // eq coordinates from p. 132. new(coord.Ecliptic).EqToEcl(&coord.Equatorial{ RA: unit.NewRA(10, 8, 22.3), Dec: unit.NewAngle(' ', 11, 58, 2), }, ε)) d := math.Abs((mλ - unit.AngleFromSec(-.2348)).Rad() / mλ.Rad()) if d*169 > 1 { // 169 = significant digits of given lon t.Fatal("mλ") } d = math.Abs((mβ - unit.AngleFromSec(-.0813)).Rad() / mβ.Rad()) if d*6 > 1 { // 6 = significant digit of given lat t.Fatal("mβ") } }
// First exercise, p. 110. func TestSep(t *testing.T) { r1 := unit.NewRA(4, 35, 55.2).Angle() d1 := unit.NewAngle(' ', 16, 30, 33) r2 := unit.NewRA(16, 29, 24).Angle() d2 := unit.NewAngle('-', 26, 25, 55) d := angle.Sep(r1, d1, r2, d2) answer := unit.NewAngle(' ', 169, 58, 0) if math.Abs((d - answer).Rad()) > 1e-4 { t.Fatal(d, answer) } } var ( r1 = []unit.Angle{ unit.NewRA(10, 29, 44.27).Angle(), unit.NewRA(10, 36, 19.63).Angle(), unit.NewRA(10, 43, 01.75).Angle(), } d1 = []unit.Angle{ unit.NewAngle(' ', 11, 02, 05.9), unit.NewAngle(' ', 10, 29, 51.7), unit.NewAngle(' ', 9, 55, 16.7), } r2 = []unit.Angle{ unit.NewRA(10, 33, 29.64).Angle(), unit.NewRA(10, 33, 57.97).Angle(), unit.NewRA(10, 34, 26.22).Angle(), } d2 = []unit.Angle{ unit.NewAngle(' ', 10, 40, 13.2),
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 := []unit.Angle{ unit.NewRA(10, 27, 27.175).Angle(), unit.NewRA(10, 26, 32.410).Angle(), unit.NewRA(10, 25, 29.042).Angle(), unit.NewRA(10, 24, 17.191).Angle(), unit.NewRA(10, 22, 57.024).Angle(), } d1 := []unit.Angle{ unit.NewAngle(' ', 4, 04, 41.83), unit.NewAngle(' ', 3, 55, 54.66), unit.NewAngle(' ', 3, 48, 03.51), unit.NewAngle(' ', 3, 41, 10.25), unit.NewAngle(' ', 3, 35, 16.61), } // Mercury r2 := []unit.Angle{ unit.NewRA(10, 24, 30.125).Angle(), unit.NewRA(10, 25, 00.342).Angle(), unit.NewRA(10, 25, 12.515).Angle(), unit.NewRA(10, 25, 06.235).Angle(), unit.NewRA(10, 24, 41.185).Angle(), } d2 := []unit.Angle{ unit.NewAngle(' ', 6, 26, 32.05), unit.NewAngle(' ', 6, 10, 57.72), unit.NewAngle(' ', 5, 57, 33.08), unit.NewAngle(' ', 5, 46, 27.07), unit.NewAngle(' ', 5, 37, 48.45), } // 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), sexa.FmtTime(unit.TimeFromDay(dFrac))) // 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).Day()) // format as before dInt, dFrac = math.Modf(d) fmt.Printf("%d %s %d at %s UT\n", y, time.Month(m), int(dInt), sexa.FmtTime(unit.TimeFromDay(dFrac))) // Δδ fmt.Printf("Δδ = %s\n", sexa.FmtAngle(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″ }
sH, cH := math.Sincos(H) sφ, cφ := φ.Sincos() sδ, cδ := ψ.Sincos() A = unit.Angle(math.Atan2(sH, cH*sφ-(sδ/cδ)*cφ)) // (13.5) p. 93 h = unit.Angle(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 unit.Angle // Latitude (b) in radians Lon unit.Angle // Longitude (l) in radians } var galacticNorth = &Equatorial{ RA: unit.NewRA(12, 49, 0), Dec: unit.AngleFromDeg(27.4), } var galacticLon0 = unit.AngleFromDeg(123) // 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 "unit". func (g *Galactic) EqToGal(eq *Equatorial) *Galactic { sdα, cdα := (galacticNorth.RA - eq.RA).Sincos() sgδ, cgδ := galacticNorth.Dec.Sincos() sδ, cδ := eq.Dec.Sincos() // (13.7) p. 94