Exemplo n.º 1
0
func ExampleMean_a() {
	// Example 12.a, p. 88.
	jd := 2446895.5
	s := sidereal.Mean(jd)
	sa := sidereal.Apparent(jd)
	fmt.Printf("%.4d\n", base.NewFmtTime(s))
	fmt.Printf("%.4d\n", base.NewFmtTime(sa))
	// Output:
	// 13ʰ10ᵐ46ˢ.3668
	// 13ʰ10ᵐ46ˢ.1351
}
Exemplo n.º 2
0
func ExampleTime() {
	// Example 19.a, p. 121.

	// convert degree data to radians
	r1 := 113.56833 * math.Pi / 180
	d1 := 31.89756 * math.Pi / 180
	r2 := 116.25042 * math.Pi / 180
	d2 := 28.03681 * math.Pi / 180
	r3 := make([]float64, 5)
	for i, ri := range []float64{
		118.98067, 119.59396, 120.20413, 120.81108, 121.41475} {
		r3[i] = ri * math.Pi / 180
	}
	d3 := make([]float64, 5)
	for i, di := range []float64{
		21.68417, 21.58983, 21.49394, 21.39653, 21.29761} {
		d3[i] = di * math.Pi / 180
	}
	// use JD as time to handle month boundary
	jd, err := line.Time(r1, d1, r2, d2, r3, d3,
		julian.CalendarGregorianToJD(1994, 9, 29),
		julian.CalendarGregorianToJD(1994, 10, 3))
	if err != nil {
		fmt.Println(err)
		return
	}
	y, m, d := julian.JDToCalendar(jd)
	dInt, dFrac := math.Modf(d)
	fmt.Printf("%d %s %.4f\n", y, time.Month(m), d)
	fmt.Printf("%d %s %d, at %.64s TD(UT)\n", y, time.Month(m), int(dInt),
		base.NewFmtTime(dFrac*24*3600))
	// Output:
	// 1994 October 1.2233
	// 1994 October 1, at 5ʰ TD(UT)
}
Exemplo n.º 3
0
func ExampleLen3_Zero() {
	// Example 3.c, p. 26.
	x1 := 26.
	x3 := 28.
	// the y unit doesn't matter.  working in degrees is fine
	yTable := []float64{
		base.DMSToDeg(true, 0, 28, 13.4),
		base.DMSToDeg(false, 0, 6, 46.3),
		base.DMSToDeg(false, 0, 38, 23.2),
	}
	d3, err := interp.NewLen3(x1, x3, yTable)
	if err != nil {
		fmt.Println(err)
		return
	}
	x, err := d3.Zero(false)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("February %.5f\n", x)
	i, frac := math.Modf(x)
	fmt.Printf("February %d, at %.62s TD",
		int(i), base.NewFmtTime(frac*24*3600))
	// Output:
	// February 26.79873
	// February 26, at 19ʰ10ᵐ TD
}
Exemplo n.º 4
0
func ExampleLen3_Extremum() {
	// Example 3.b, p. 26.
	d3, err := interp.NewLen3(12, 20, []float64{
		1.3814294,
		1.3812213,
		1.3812453,
	})
	if err != nil {
		fmt.Println(err)
		return
	}
	x, y, err := d3.Extremum()
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("distance:  %.7f AU\n", y)
	fmt.Printf("date:     %.4f\n", x)
	i, frac := math.Modf(x)
	fmt.Printf("1992 May %d, at %.64s TD",
		int(i), base.NewFmtTime(frac*24*3600))
	// Output:
	// distance:  1.3812030 AU
	// date:     17.5864
	// 1992 May 17, at 14ʰ TD
}
Exemplo n.º 5
0
func ExampleMean_b() {
	// Example 12.b, p. 89.
	jd := julian.TimeToJD(time.Date(1987, 4, 10, 19, 21, 0, 0, time.UTC))
	fmt.Printf("%.4d\n", base.NewFmtTime(sidereal.Mean(jd)))
	// Output:
	// 8ʰ34ᵐ57ˢ.0896
}
Exemplo n.º 6
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
}
Exemplo n.º 7
0
func ExampleApogee() {
	// Example 50.a, p. 357.
	j := apsis.Apogee(1988.75)
	fmt.Printf("JDE = %.4f\n", j)
	y, m, d := julian.JDToCalendar(j)
	d, f := math.Modf(d)
	fmt.Printf("%d %s %d, at %.62d TD\n", y, time.Month(m), int(d),
		base.NewFmtTime(f*24*3600))
	// Output:
	// JDE = 2447442.3543
	// 1988 October 7, at 20ʰ30ᵐ TD
}
Exemplo n.º 8
0
func ExampleStellar() {
	// Exercise, p. 119.
	day1 := 7.
	day5 := 27.
	r2 := []float64{
		base.NewRA(15, 3, 51.937).Rad(),
		base.NewRA(15, 9, 57.327).Rad(),
		base.NewRA(15, 15, 37.898).Rad(),
		base.NewRA(15, 20, 50.632).Rad(),
		base.NewRA(15, 25, 32.695).Rad(),
	}
	d2 := []float64{
		base.NewAngle(true, 8, 57, 34.51).Rad(),
		base.NewAngle(true, 9, 9, 03.88).Rad(),
		base.NewAngle(true, 9, 17, 37.94).Rad(),
		base.NewAngle(true, 9, 23, 16.25).Rad(),
		base.NewAngle(true, 9, 26, 01.01).Rad(),
	}
	jd := julian.CalendarGregorianToJD(1996, 2, 17)
	dt := jd - base.J2000
	dy := dt / base.JulianYear
	dc := dy / 100
	fmt.Printf("%.2f years\n", dy)
	fmt.Printf("%.4f century\n", dc)

	pmr := -.649 // sec/cen
	pmd := -1.91 // sec/cen
	r1 := base.NewRA(15, 17, 0.421+pmr*dc).Rad()
	// Careful with quick and dirty way of applying correction to seconds
	// component before converting to radians.  The dec here is negative
	// so correction must be subtracted.  Alternative, less error-prone,
	// way would be to convert both to radians, then add.
	d1 := base.NewAngle(true, 9, 22, 58.54-pmd*dc).Rad()
	fmt.Printf("α′ = %.3d, δ′ = %.2d\n",
		base.NewFmtRA(r1), base.NewFmtAngle(d1))

	day, dd, err := conjunction.Stellar(day1, day5, r1, d1, r2, d2)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(base.NewFmtAngle(dd))
	dInt, dFrac := math.Modf(day)
	fmt.Printf("1996 February %d at %s TD\n", int(dInt),
		base.NewFmtTime(dFrac*24*3600))

	// Output:
	// -3.87 years
	// -0.0387 century
	// α′ = 15ʰ17ᵐ0ˢ.446, δ′ = -9°22′58″.47
	// 3′38″
	// 1996 February 18 at 6ʰ36ᵐ55ˢ TD
}
Exemplo n.º 9
0
func ExampleAscending() {
	// Example 51.a, p. 365.
	j := moonnode.Ascending(1987.37)
	fmt.Printf("%.5f\n", j)
	y, m, d := julian.JDToCalendar(j)
	d, f := math.Modf(d)
	fmt.Printf("%d %s %d, at %d TD\n", y, time.Month(m), int(d),
		base.NewFmtTime(f*24*3600))
	// Output:
	// 2446938.76803
	// 1987 May 23, at 6ʰ25ᵐ58ˢ TD
}
Exemplo n.º 10
0
func ExampleJune2() {
	// Example 27.b, p. 180.
	e, err := pp.LoadPlanet(pp.Earth, "")
	if err != nil {
		fmt.Println(err)
		return
	}
	j := solstice.June2(1962, e)
	t := j - 2437836.5 // 0h 1962 June 21
	// result is VSOP87 result given in example 27.a, p. 180
	fmt.Println(base.NewFmtTime(t * 24 * 60 * 60))
	// Output:
	// 21ʰ24ᵐ42ˢ
}
Exemplo n.º 11
0
func ExampleTimes() {
	// Example 15.a, p. 103.
	jd := julian.CalendarGregorianToJD(1988, 3, 20)
	p := globe.Coord{
		Lon: base.NewAngle(false, 71, 5, 0).Rad(),
		Lat: base.NewAngle(false, 42, 20, 0).Rad(),
	}
	// Meeus gives us the value of 11h 50m 58.1s but we have a package
	// function for this:
	Th0 := sidereal.Apparent0UT(jd)
	α3 := []float64{
		base.NewRA(2, 42, 43.25).Rad(),
		base.NewRA(2, 46, 55.51).Rad(),
		base.NewRA(2, 51, 07.69).Rad(),
	}
	δ3 := []float64{
		base.NewAngle(false, 18, 02, 51.4).Rad(),
		base.NewAngle(false, 18, 26, 27.3).Rad(),
		base.NewAngle(false, 18, 49, 38.7).Rad(),
	}
	h0 := rise.Stdh0Stellar
	// Similarly as with Th0, Meeus gives us the value of 56 for ΔT but
	// let's use our package function.
	ΔT := deltat.Interp10A(jd)
	rise, transit, set, err := rise.Times(p, ΔT, h0, Th0, α3, δ3)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println("rising: ", base.NewFmtTime(rise))
	fmt.Println("transit:", base.NewFmtTime(transit))
	fmt.Println("seting: ", base.NewFmtTime(set))
	// Output:
	// rising:  12ʰ26ᵐ9ˢ
	// transit: 19ʰ40ᵐ30ˢ
	// seting:  2ʰ54ᵐ26ˢ
}
Exemplo n.º 12
0
func ExampleNorth_c() {
	// Example 52.c, p. 370.
	j, δ := moonmaxdec.North(-3.8)
	fmt.Printf("JDE = %.4f\n", j)
	y, m, d := julian.JDToCalendar(j)
	d, f := math.Modf(d)
	fmt.Printf("%d %s %d at %0.64d TD\n", y, time.Month(m), int(d),
		base.NewFmtTime(f*24*3600))
	fmt.Printf("δ = %.4f\n", δ*180/math.Pi)
	fmt.Printf("%+0.62d\n", base.NewFmtAngle(δ))
	// Output:
	// JDE = 1719672.1412
	// -4 March 16 at 15ʰ TD
	// δ = 28.9739
	// +28°58′
}
Exemplo n.º 13
0
func ExampleSouth() {
	// Example 52.b, p. 370.
	j, δ := moonmaxdec.South(2049.3)
	fmt.Printf("JDE = %.4f\n", j)
	y, m, d := julian.JDToCalendar(j)
	d, f := math.Modf(d)
	fmt.Printf("%d %s %d at %0.64d TD\n", y, time.Month(m), int(d),
		base.NewFmtTime(f*24*3600))
	fmt.Printf("δ = %.4f\n", δ*180/math.Pi)
	fmt.Printf("%+0.62d\n", base.NewFmtAngle(δ))
	// Output:
	// JDE = 2469553.0834
	// 2049 April 21 at 14ʰ TD
	// δ = -22.1384
	// -22°08′
}
Exemplo n.º 14
0
func ExampleNorth() {
	// Example 52.a, p. 370.
	j, δ := moonmaxdec.North(1988.95)
	fmt.Printf("JDE = %.4f\n", j)
	y, m, d := julian.JDToCalendar(j)
	d, f := math.Modf(d)
	fmt.Printf("%d %s %d at %0.62d TD\n", y, time.Month(m), int(d),
		base.NewFmtTime(f*24*3600))
	fmt.Printf("δ = %.4f\n", δ*180/math.Pi)
	fmt.Printf("%+0d\n", base.NewFmtAngle(δ))
	// Output:
	// JDE = 2447518.3346
	// 1988 December 22 at 20ʰ02ᵐ TD
	// δ = 28.1562
	// +28°09′22″
}
Exemplo n.º 15
0
func ExampleLen5_Zero() {
	// Exercise, p. 30.
	x1 := 25.
	x5 := 29.
	yTable := []float64{
		base.DMSToDeg(true, 1, 11, 21.23),
		base.DMSToDeg(true, 0, 28, 12.31),
		base.DMSToDeg(false, 0, 16, 07.02),
		base.DMSToDeg(false, 1, 01, 00.13),
		base.DMSToDeg(false, 1, 45, 46.33),
	}
	d5, err := interp.NewLen5(x1, x5, yTable)
	if err != nil {
		fmt.Println(err)
		return
	}
	z, err := d5.Zero(false)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("1988 January %.6f\n", z)
	zInt, zFrac := math.Modf(z)
	fmt.Printf("1988 January %d at %.62s TD\n", int(zInt),
		base.NewFmtTime(zFrac*24*3600))

	// compare result to that from just three central values
	d3, err := interp.NewLen3(26, 28, yTable[1:4])
	if err != nil {
		fmt.Println(err)
		return
	}
	z3, err := d3.Zero(false)
	if err != nil {
		fmt.Println(err)
		return
	}
	dz := z - z3
	fmt.Printf("%.6f day\n", dz)
	fmt.Printf("%.1f minute\n", dz*24*60)
	// Output:
	// 1988 January 26.638587
	// 1988 January 26 at 15ʰ20ᵐ TD
	// 0.000753 day
	// 1.1 minute
}
Exemplo n.º 16
0
func ExamplePlanetary() {
	// Example 18.a, p. 117.

	// Day of month is sufficient for a time scale.
	day1 := 5.
	day5 := 9.

	// Text asks for Mercury-Venus conjunction, so r1, d1 is Venus ephemeris,
	// r2, d2 is Mercury ephemeris.

	// Venus
	r1 := []float64{
		base.NewRA(10, 27, 27.175).Rad(),
		base.NewRA(10, 26, 32.410).Rad(),
		base.NewRA(10, 25, 29.042).Rad(),
		base.NewRA(10, 24, 17.191).Rad(),
		base.NewRA(10, 22, 57.024).Rad(),
	}
	d1 := []float64{
		base.NewAngle(false, 4, 04, 41.83).Rad(),
		base.NewAngle(false, 3, 55, 54.66).Rad(),
		base.NewAngle(false, 3, 48, 03.51).Rad(),
		base.NewAngle(false, 3, 41, 10.25).Rad(),
		base.NewAngle(false, 3, 35, 16.61).Rad(),
	}
	// Mercury
	r2 := []float64{
		base.NewRA(10, 24, 30.125).Rad(),
		base.NewRA(10, 25, 00.342).Rad(),
		base.NewRA(10, 25, 12.515).Rad(),
		base.NewRA(10, 25, 06.235).Rad(),
		base.NewRA(10, 24, 41.185).Rad(),
	}
	d2 := []float64{
		base.NewAngle(false, 6, 26, 32.05).Rad(),
		base.NewAngle(false, 6, 10, 57.72).Rad(),
		base.NewAngle(false, 5, 57, 33.08).Rad(),
		base.NewAngle(false, 5, 46, 27.07).Rad(),
		base.NewAngle(false, 5, 37, 48.45).Rad(),
	}
	// compute conjunction
	day, dd, err := conjunction.Planetary(day1, day5, r1, d1, r2, d2)
	if err != nil {
		fmt.Println(err)
		return
	}
	// time of conjunction
	fmt.Printf("1991 August %.5f\n", day)

	// more useful clock format
	dInt, dFrac := math.Modf(day)
	fmt.Printf("1991 August %d at %s TD\n", int(dInt),
		base.NewFmtTime(dFrac*24*3600))

	// deltat func needs jd
	jd := julian.CalendarGregorianToJD(1991, 8, day)
	// compute UT = TD - ΔT, and separate back into calendar components.
	// (we could use our known calendar components, but this illustrates
	// the more general technique that would allow for rollovers.)
	y, m, d := julian.JDToCalendar(jd - deltat.Interp10A(jd)/(3600*24))
	// format as before
	dInt, dFrac = math.Modf(d)
	fmt.Printf("%d %s %d at %s UT\n", y, time.Month(m), int(dInt),
		base.NewFmtTime(dFrac*24*3600))

	// Δδ
	fmt.Printf("Δδ = %s\n", base.NewFmtAngle(dd))

	// Output:
	// 1991 August 7.23797
	// 1991 August 7 at 5ʰ42ᵐ41ˢ TD
	// 1991 August 7 at 5ʰ41ᵐ43ˢ UT
	// Δδ = 2°8′22″
}