Пример #1
0
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) +
			base.NewTime(false, 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) +
			base.NewTime(false, 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) +
			base.NewTime(false, 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) +
			base.NewTime(false, 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)
		}
	}
}
Пример #2
0
func ExamplePolyBefore948() {
	// Example 10.b, p. 80.
	ΔT := deltat.PolyBefore948(333.1)
	UT := base.NewTime(false, 6, 0, 0).Sec()
	TD := UT + ΔT
	fmt.Printf("%+.0f seconds\n", ΔT)
	fmt.Printf("333 February 6 at %.62s TD", base.NewFmtTime(TD))
	// Output:
	// +6146 seconds
	// 333 February 6 at 7ʰ42ᵐ TD
}
Пример #3
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 + base.NewTime(false, 4, 21, 0).Day() // 8th day at 4:21
	y := d3.InterpolateX(x)
	fmt.Printf("%.6f\n", y)
	// Output:
	// 0.876125
}