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ˢ }
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 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) } } }
func ExampleTopocentric2() { // Example 40.a, p. 280 Δα, Δδ := parallax.Topocentric2( unit.RAFromDeg(339.530208), unit.AngleFromDeg(-15.771083), .37276, .546861, .836339, unit.Angle(unit.NewHourAngle(' ', 7, 47, 27)), julian.CalendarGregorianToJD(2003, 8, 28+ unit.NewTime(' ', 3, 17, 0).Day())) fmt.Printf("Δα = %.2s (sec of RA)\n", sexa.FmtHourAngle(Δα)) fmt.Printf("Δδ = %.1s (sec of Dec)\n", sexa.FmtAngle(Δδ)) // Output: // Δα = 1.29ˢ (sec of RA) // Δδ = -14.1″ (sec of Dec) }
func ExampleTopocentric() { // Example 40.a, p. 280 α, δ := parallax.Topocentric( unit.RAFromDeg(339.530208), unit.AngleFromDeg(-15.771083), .37276, .546861, .836339, unit.Angle(unit.NewHourAngle(' ', 7, 47, 27)), julian.CalendarGregorianToJD(2003, 8, 28+ unit.NewTime(' ', 3, 17, 0).Day())) fmt.Printf("α' = %.2d\n", sexa.FmtRA(α)) fmt.Printf("δ' = %.1d\n", sexa.FmtAngle(δ)) // Output: // α' = 22ʰ38ᵐ8ˢ.54 // δ' = -15°46′30″.0 }
func ExampleLen3_InterpolateX() { // Example 3.a, p. 25. d3, err := interp.NewLen3(7, 9, []float64{ .884226, .877366, .870531, }) if err != nil { fmt.Println(err) return } x := 8 + unit.NewTime(' ', 4, 21, 0).Day() // 8th day at 4:21 y := d3.InterpolateX(x) fmt.Printf("%.6f\n", y) // Output: // 0.876125 }
func ExampleTopocentric3() { // same test case as example 40.a, p. 280 α := unit.RAFromDeg(339.530208) δ := unit.AngleFromDeg(-15.771083) Δ := .37276 ρsφʹ := .546861 ρcφʹ := .836339 L := unit.Angle(unit.NewHourAngle(' ', 7, 47, 27)) jde := julian.CalendarGregorianToJD(2003, 8, 28+ unit.NewTime(' ', 3, 17, 0).Day()) Hʹ, δʹ := parallax.Topocentric3(α, δ, Δ, ρsφʹ, ρcφʹ, L, jde) fmt.Printf("Hʹ = %.2d\n", sexa.FmtHourAngle(Hʹ)) θ0 := sidereal.Apparent(jde) αʹ := unit.RAFromRad(θ0.Rad() - L.Rad() - Hʹ.Rad()) // same result as example 40.a, p. 280 fmt.Printf("αʹ = %.2d\n", sexa.FmtRA(αʹ)) fmt.Printf("δʹ = %.1d\n", sexa.FmtAngle(δʹ)) // Output: // Hʹ = -4ʰ44ᵐ50ˢ.28 // αʹ = 22ʰ38ᵐ8ˢ.54 // δʹ = -15°46′30″.0 }