Example #1
0
func ExampleCalendarJulianToJD() {
	// Example 7.b, p. 61.
	jd := julian.CalendarJulianToJD(333, 1, 27.5)
	fmt.Printf("%.1f\n", jd)
	// Output:
	// 1842713.0
}
Example #2
0
func ExampleEclipticPosition() {
	// Example 21.c, p. 137.
	eclFrom := &coord.Ecliptic{
		Lat: 1.76549 * math.Pi / 180,
		Lon: 149.48194 * math.Pi / 180,
	}
	eclTo := &coord.Ecliptic{}
	epochFrom := 2000.0
	epochTo := base.JDEToJulianYear(julian.CalendarJulianToJD(-214, 6, 30))
	precess.EclipticPosition(eclFrom, eclTo, epochFrom, epochTo, 0, 0)
	fmt.Printf("%.3f\n", eclTo.Lon*180/math.Pi)
	fmt.Printf("%+.3f\n", eclTo.Lat*180/math.Pi)
	// Output:
	// 118.704
	// +1.615
}
Example #3
0
func ExampleEclipticPosition() {
	// Example 21.c, p. 137.
	eclFrom := &coord.Ecliptic{
		Lat: unit.AngleFromDeg(1.76549),
		Lon: unit.AngleFromDeg(149.48194),
	}
	eclTo := &coord.Ecliptic{}
	epochFrom := 2000.0
	epochTo := base.JDEToJulianYear(julian.CalendarJulianToJD(-214, 6, 30))
	precess.EclipticPosition(eclFrom, eclTo, epochFrom, epochTo, 0, 0)
	fmt.Printf("%.3f\n", eclTo.Lon.Deg())
	fmt.Printf("%+.3f\n", eclTo.Lat.Deg())
	// Output:
	// 118.704
	// +1.615
}
Example #4
0
func TestJuli(t *testing.T) {
	for _, tp := range []struct {
		y, m  int
		d, jd float64
	}{
		{837, 4, 10.3, 2026871.8}, // more examples, p. 62
		{-123, 12, 31, 1676496.5},
		{-122, 1, 1, 1676497.5},
		{-1000, 7, 12.5, 1356001},
		{-1000, 2, 29, 1355866.5},
		{-1001, 8, 17.9, 1355671.4},
		{-4712, 1, 1.5, 0},
	} {
		dt := julian.CalendarJulianToJD(tp.y, tp.m, tp.d) - tp.jd
		if math.Abs(dt) > .1 {
			t.Logf("%#v", tp)
			t.Fatal("dt:", time.Duration(dt*24*float64(time.Hour)))
		}
	}
}
Example #5
0
	fmt.Printf("%d %s %d, at %dʰ\n", y, time.Month(m), int(d), int(f*24+.5))
	// Output:
	// 2450566.255
	// 1997 April 27, at 18ʰ
}

type tc struct {
	f    func(float64) float64
	jNom float64
	hour int
}

var td = []tc{
	{planetary.MercuryInfConj, julian.CalendarGregorianToJD(1631, 11, 7), 7},
	{planetary.VenusInfConj, julian.CalendarGregorianToJD(1882, 12, 6), 17},
	{planetary.MarsOpp, julian.CalendarGregorianToJD(2729, 9, 9), 3},
	{planetary.JupiterOpp, julian.CalendarJulianToJD(-6, 9, 15), 7},
	{planetary.SaturnOpp, julian.CalendarJulianToJD(-6, 9, 14), 9},
	{planetary.UranusOpp, julian.CalendarGregorianToJD(1780, 12, 17), 14},
	{planetary.NeptuneOpp, julian.CalendarGregorianToJD(1846, 8, 20), 4},
}

func Test255(t *testing.T) {
	for _, d := range td {
		_, f := math.Modf(.5 + d.f(base.JDEToJulianYear(d.jNom)))
		if int(f*24+.5) != d.hour {
			t.Errorf("got %d, expected %d", int(f*24+.5), d.hour)
		}
	}
}