Esempio n. 1
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. 2
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)
		}
	}
}
Esempio n. 3
0
// test example epochs on p. 133 that are not constants in meeus/julian.go
func TestEpoch(t *testing.T) {
	if math.Abs(base.BesselianYearToJDE(1950)-2433282.4235) > 1e-4 {
		t.Fatal("B1950")
	}
	if math.Abs((base.JulianYearToJDE(2050)-2469807.5)/2469807.5) > 1e-15 {
		t.Fatal("J2050")
	}
}
Esempio n. 4
0
// Position computes the apparent position of an object.
//
// Position is computed for equatorial coordinates in eqFrom, considering
// proper motion, precession, nutation, and aberration.  Result is in
// eqTo.  EqFrom and eqTo must be non-nil, but may point to the same struct.
func Position(eqFrom, eqTo *coord.Equatorial, epochFrom, epochTo float64, mα sexa.HourAngle, mδ sexa.Angle) *coord.Equatorial {
	precess.Position(eqFrom, eqTo, epochFrom, epochTo, mα, mδ)
	jd := base.JulianYearToJDE(epochTo)
	Δα1, Δδ1 := Nutation(eqTo.RA, eqTo.Dec, jd)
	Δα2, Δδ2 := Aberration(eqTo.RA, eqTo.Dec, jd)
	eqTo.RA += Δα1 + Δα2
	eqTo.Dec += Δδ1 + Δδ2
	return eqTo
}
Esempio n. 5
0
func eqProperMotionToEcl(mα, mδ, epoch float64, pos *coord.Ecliptic) (mλ, mβ float64) {
	ε := nutation.MeanObliquity(base.JulianYearToJDE(epoch))
	sε, cε := math.Sincos(ε)
	α, δ := coord.EclToEq(pos.Lon, pos.Lat, sε, cε)
	sα, cα := math.Sincos(α)
	sδ, cδ := math.Sincos(δ)
	cβ := math.Cos(pos.Lat)
	mλ = (mδ*sε*cα + mα*cδ*(cε*cδ+sε*sδ*sα)) / (cβ * cβ)
	mβ = (mδ*(cε*cδ+sε*sδ*sα) - mα*sε*cα*cδ) / cβ
	return
}
Esempio n. 6
0
func eqProperMotionToEcl(mα unit.HourAngle, mδ unit.Angle, epoch float64, pos *coord.Ecliptic) (mλ, mβ unit.Angle) {
	ε := nutation.MeanObliquity(base.JulianYearToJDE(epoch))
	sε, cε := ε.Sincos()
	α, δ := coord.EclToEq(pos.Lon, pos.Lat, sε, cε)
	sα, cα := α.Sincos()
	sδ, cδ := δ.Sincos()
	cβ := pos.Lat.Cos()
	mλ = (mδ.Mul(sε*cα) + unit.Angle(mα).Mul(cδ*(cε*cδ+sε*sδ*sα))).Div(cβ * cβ)
	mβ = (mδ.Mul(cε*cδ+sε*sδ*sα) - unit.Angle(mα).Mul(sε*cα*cδ)).Div(cβ)
	return
}
Esempio n. 7
0
// PositionRonVondrak computes the apparent position of an object using
// the Ron-Vondrák expression for aberration.
//
// Position is computed for equatorial coordinates in eqFrom, considering
// proper motion, aberration, precession, and nutation.  Result is in
// eqTo.  EqFrom and eqTo must be non-nil, but may point to the same struct.
//
// Note the Ron-Vondrák expression is only valid for the epoch J2000.
// EqFrom must be coordinates at epoch J2000.
func PositionRonVondrak(eqFrom, eqTo *coord.Equatorial, epochTo float64, mα sexa.HourAngle, mδ sexa.Angle) *coord.Equatorial {
	t := epochTo - 2000
	eqTo.RA = eqFrom.RA + mα.Rad()*t
	eqTo.Dec = eqFrom.Dec + mδ.Rad()*t
	jd := base.JulianYearToJDE(epochTo)
	Δα, Δδ := AberrationRonVondrak(eqTo.RA, eqTo.Dec, jd)
	eqTo.RA += Δα
	eqTo.Dec += Δδ
	precess.Position(eqTo, eqTo, 2000, epochTo, 0, 0)
	Δα1, Δδ1 := Nutation(eqTo.RA, eqTo.Dec, jd)
	eqTo.RA += Δα1
	eqTo.Dec += Δδ1
	return eqTo
}
Esempio n. 8
0
// PositionRonVondrak computes the apparent position of an object using
// the Ron-Vondrák expression for aberration.
//
// Position is computed for equatorial coordinates in eqFrom, considering
// proper motion, aberration, precession, and nutation.  Result is in
// eqTo.  EqFrom and eqTo must be non-nil, but may point to the same struct.
//
// Note the Ron-Vondrák expression is only valid for the epoch J2000.
// EqFrom must be coordinates at epoch J2000.
func PositionRonVondrak(eqFrom, eqTo *coord.Equatorial, epochTo float64, mα unit.HourAngle, mδ unit.Angle) *coord.Equatorial {
	t := epochTo - 2000
	eqTo.RA = eqFrom.RA.Add(mα.Mul(t))
	eqTo.Dec = eqFrom.Dec + mδ.Mul(t)
	jd := base.JulianYearToJDE(epochTo)
	Δα, Δδ := AberrationRonVondrak(eqTo.RA, eqTo.Dec, jd)
	eqTo.RA = eqTo.RA.Add(Δα)
	eqTo.Dec += Δδ
	precess.Position(eqTo, eqTo, 2000, epochTo, 0, 0)
	Δα1, Δδ1 := Nutation(eqTo.RA, eqTo.Dec, jd)
	eqTo.RA = eqTo.RA.Add(Δα1)
	eqTo.Dec += Δδ1
	return eqTo
}