Exemplo n.º 1
0
func ExampleApproxPlanet() {
	// Example 15.a, p. 103.
	p := globe.Coord{
		Lon: unit.NewAngle(' ', 71, 5, 0),
		Lat: unit.NewAngle(' ', 42, 20, 0),
	}
	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
	}
	tRise, tTransit, tSet, err := rise.ApproxPlanet(1988, 3, 20, p, e, v)
	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ˢ
}
Exemplo n.º 2
0
func ExamplePlanet() {
	// Example 15.a, p. 103.
	p := globe.Coord{
		Lon: unit.NewAngle(' ', 71, 5, 0),
		Lat: unit.NewAngle(' ', 42, 20, 0),
	}
	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
	}
	tRise, tTransit, tSet, err := rise.Planet(1988, 3, 20, p, e, v)
	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ˢ
}
Exemplo n.º 3
0
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ˢ
}
Exemplo n.º 4
0
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ˢ
}
Exemplo n.º 5
0
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ˢ
}
Exemplo n.º 6
0
// 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)
	}
}
Exemplo n.º 7
0
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″
}
Exemplo n.º 8
0
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)
	}
}
Exemplo n.º 9
0
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)
		}
	}
}
Exemplo n.º 10
0
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″
}
Exemplo n.º 11
0
// 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)
		}
	}
}
Exemplo n.º 12
0
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′
}
Exemplo n.º 13
0
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
}
Exemplo n.º 14
0
// p. 83
func TestLatDiff(t *testing.T) {
	φ0 := unit.NewAngle(' ', 45, 5, 46.36)
	diff := globe.GeocentricLatitudeDifference(φ0)
	if f := fmt.Sprintf("%.2d", sexa.FmtAngle(diff)); f != "11′32″.73" {
		t.Fatal(f)
	}
}
Exemplo n.º 15
0
func ExampleApproxTimes_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)
	fmt.Printf("Th0: %.2s\n", sexa.FmtTime(Th0))

	// 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
	}
	α, δ := elliptic.Position(v, e, jd)
	fmt.Printf("α: %.2s\n", sexa.FmtRA(α))
	fmt.Printf("δ: %.1s\n", sexa.FmtAngle(δ))

	h0 := rise.Stdh0Stellar
	tRise, tTransit, tSet, err := rise.ApproxTimes(p, 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:
	// Th0: 11ʰ50ᵐ58.09ˢ
	// α: 2ʰ46ᵐ55.51ˢ
	// δ: 18°26′27.3″
	// rising:   +0.51816  12ʰ26ᵐ09ˢ
	// transit:  +0.81965  19ʰ40ᵐ17ˢ
	// seting:   +0.12113  02ʰ54ᵐ26ˢ
}
Exemplo n.º 16
0
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
}
Exemplo n.º 17
0
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″
}
Exemplo n.º 18
0
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
}
Exemplo n.º 19
0
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
}
Exemplo n.º 20
0
func ExampleEllipsoid_ParallaxConstants() {
	// Example 11.a, p 82.
	// phi = geographic latitude of Palomar
	φ := unit.NewAngle(' ', 33, 21, 22)
	s, c := globe.Earth76.ParallaxConstants(φ, 1706)
	fmt.Printf("ρ sin φ′ = %+.6f\n", s)
	fmt.Printf("ρ cos φ′ = %+.6f\n", c)
	// Output:
	// ρ sin φ′ = +0.546861
	// ρ cos φ′ = +0.836339
}
Exemplo n.º 21
0
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)
	}
}
Exemplo n.º 22
0
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
}
Exemplo n.º 23
0
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″
}
Exemplo n.º 24
0
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″
}
Exemplo n.º 25
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.
		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β")
	}
}
Exemplo n.º 26
0
func ExampleEllipsoid_Distance() {
	// Example 11.c p 85.
	c1 := globe.Coord{
		unit.NewAngle(' ', 48, 50, 11), // geographic latitude
		unit.NewAngle('-', 2, 20, 14),  // geographic longitude
	}
	c2 := globe.Coord{
		unit.NewAngle(' ', 38, 55, 17),
		unit.NewAngle(' ', 77, 3, 56),
	}
	fmt.Printf("%.2f km\n", globe.Earth76.Distance(c1, c2))
	cos := globe.ApproxAngularDistance(c1, c2)
	fmt.Printf("cos d = %.6f\n", cos)
	d := unit.Angle(math.Acos(cos))
	fmt.Printf("    d = %.5j\n", sexa.FmtAngle(d))
	fmt.Printf("    s = %.0f km\n", globe.ApproxLinearDistance(d))
	// Output:
	// 6181.63 km
	// cos d = 0.567146
	//     d = 55°.44855
	//     s = 6166 km
}
Exemplo n.º 27
0
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
}
Exemplo n.º 28
0
func TestDiurnalPathAtHorizon(t *testing.T) {
	φ := unit.AngleFromDeg(40)
	ε := unit.AngleFromDeg(23.44)
	J := parallactic.DiurnalPathAtHorizon(0, φ)
	Jexp := math.Pi/2 - φ
	if math.Abs((J-Jexp).Rad()/Jexp.Rad()) > 1e-15 {
		t.Fatal("0 dec:", sexa.FmtAngle(J))
	}
	J = parallactic.DiurnalPathAtHorizon(ε, φ)
	Jexp = unit.NewAngle(' ', 45, 31, 0)
	if math.Abs((J-Jexp).Rad()/Jexp.Rad()) > 1e-3 {
		t.Fatal("solstice:", sexa.FmtAngle(J))
	}
}
Exemplo n.º 29
0
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
}
Exemplo n.º 30
0
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
}