Ejemplo n.º 1
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{
		unit.FromSexa('-', 0, 28, 13.4),
		unit.FromSexa(' ', 0, 6, 46.3),
		unit.FromSexa(' ', 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 %m TD",
		int(i), sexa.FmtTime(unit.TimeFromDay(frac)))
	// Output:
	// February 26.79873
	// February 26, at 19ʰ10ᵐ TD
}
Ejemplo n.º 2
0
func ExampleTime() {
	// Example 19.a, p. 121.
	r1 := unit.AngleFromDeg(113.56833)
	d1 := unit.AngleFromDeg(31.89756)
	r2 := unit.AngleFromDeg(116.25042)
	d2 := unit.AngleFromDeg(28.03681)
	r3 := make([]unit.Angle, 5)
	for i, ri := range []float64{
		118.98067, 119.59396, 120.20413, 120.81108, 121.41475} {
		r3[i] = unit.AngleFromDeg(ri)
	}
	d3 := make([]unit.Angle, 5)
	for i, di := range []float64{
		21.68417, 21.58983, 21.49394, 21.39653, 21.29761} {
		d3[i] = unit.AngleFromDeg(di)
	}
	// 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 %h TD(UT)\n", y, time.Month(m), int(dInt),
		sexa.FmtTime(unit.TimeFromDay(dFrac)))
	// Output:
	// 1994 October 1.2233
	// 1994 October 1, at 5ʰ TD(UT)
}
Ejemplo n.º 3
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 %h TD",
		int(i), sexa.FmtTime(unit.TimeFromDay(frac)))
	// Output:
	// distance:  1.3812030 AU
	// date:     17.5864
	// 1992 May 17, at 14ʰ TD
}
Ejemplo n.º 4
0
// Apparent0UT returns apparent sidereal time at Greenwich at 0h UT
// on the given JD.
//
// The result is in the range [0,86400).
func Apparent0UT(jd float64) unit.Time {
	j0, f := math.Modf(jd + .5)
	cen := (j0 - .5 - base.J2000) / 36525
	s := unit.Time(base.Horner(cen, iau82...)) +
		unit.TimeFromDay(f*1.00273790935)
	n := nutation.NutationInRA(j0) // HourAngle
	return (s + n.Time()).Mod1()
}
Ejemplo n.º 5
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 %m TD\n", y, time.Month(m), int(d),
		sexa.FmtTime(unit.TimeFromDay(f)))
	// Output:
	// JDE = 2447442.3543
	// 1988 October 7, at 20ʰ30ᵐ TD
}
Ejemplo n.º 6
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),
		sexa.FmtTime(unit.TimeFromDay(f)))
	// Output:
	// 2446938.76803
	// 1987 May 23, at 6ʰ25ᵐ58ˢ TD
}
Ejemplo n.º 7
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(sexa.FmtTime(unit.TimeFromDay(t)))
	// Output:
	// 21ʰ24ᵐ42ˢ
}
Ejemplo n.º 8
0
func ExampleStellar() {
	// Exercise, p. 119.
	day1 := 7.
	day5 := 27.
	r2 := []unit.Angle{
		unit.NewRA(15, 3, 51.937).Angle(),
		unit.NewRA(15, 9, 57.327).Angle(),
		unit.NewRA(15, 15, 37.898).Angle(),
		unit.NewRA(15, 20, 50.632).Angle(),
		unit.NewRA(15, 25, 32.695).Angle(),
	}
	d2 := []unit.Angle{
		unit.NewAngle('-', 8, 57, 34.51),
		unit.NewAngle('-', 9, 9, 03.88),
		unit.NewAngle('-', 9, 17, 37.94),
		unit.NewAngle('-', 9, 23, 16.25),
		unit.NewAngle('-', 9, 26, 01.01),
	}
	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 := unit.NewRA(15, 17, 0.421) + unit.RAFromSec(pmr*dc)
	d1 := unit.NewAngle('-', 9, 22, 58.54) + unit.AngleFromSec(pmd*dc)
	fmt.Printf("α′ = %.3d, δ′ = %.2d\n", sexa.FmtRA(r1), sexa.FmtAngle(d1))

	day, dd, err := conjunction.Stellar(day1, day5, r1.Angle(), d1, r2, d2)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(sexa.FmtAngle(dd))
	dInt, dFrac := math.Modf(day)
	fmt.Printf("1996 February %d at %s TD\n", int(dInt),
		sexa.FmtTime(unit.TimeFromDay(dFrac)))

	// 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
}
Ejemplo n.º 9
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 %0h TD\n", y, time.Month(m), int(d),
		sexa.FmtTime(unit.TimeFromDay(f)))
	fmt.Printf("δ = %.4f\n", δ.Deg())
	fmt.Printf("%+0m\n", sexa.FmtAngle(δ))
	// Output:
	// JDE = 1719672.1412
	// -4 March 16 at 15ʰ TD
	// δ = 28.9739
	// +28°58′
}
Ejemplo n.º 10
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 %0h TD\n", y, time.Month(m), int(d),
		sexa.FmtTime(unit.TimeFromDay(f)))
	fmt.Printf("δ = %.4f\n", δ.Deg())
	fmt.Printf("%+0m\n", sexa.FmtAngle(δ))
	// Output:
	// JDE = 2469553.0834
	// 2049 April 21 at 14ʰ TD
	// δ = -22.1384
	// -22°08′
}
Ejemplo n.º 11
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 %0m TD\n", y, time.Month(m), int(d),
		sexa.FmtTime(unit.TimeFromDay(f)))
	fmt.Printf("δ = %.4f\n", δ.Deg())
	fmt.Printf("%+0d\n", sexa.FmtAngle(δ))
	// Output:
	// JDE = 2447518.3346
	// 1988 December 22 at 20ʰ02ᵐ TD
	// δ = 28.1562
	// +28°09′22″
}
Ejemplo n.º 12
0
func ExampleLen5_Zero() {
	// Exercise, p. 30.
	x1 := 25.
	x5 := 29.
	yTable := []float64{
		unit.FromSexa('-', 1, 11, 21.23),
		unit.FromSexa('-', 0, 28, 12.31),
		unit.FromSexa(' ', 0, 16, 07.02),
		unit.FromSexa(' ', 1, 01, 00.13),
		unit.FromSexa(' ', 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 %m TD\n", int(zInt),
		sexa.FmtTime(unit.TimeFromDay(zFrac)))

	// 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
}
Ejemplo n.º 13
0
func mean0UT(jd float64) (sidereal, dayFrac unit.Time) {
	cen, f := jdToCFrac(jd)
	// (12.2) p. 87
	return unit.Time(base.Horner(cen, iau82...)), unit.TimeFromDay(f)
}
Ejemplo n.º 14
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 := []unit.Angle{
		unit.NewRA(10, 27, 27.175).Angle(),
		unit.NewRA(10, 26, 32.410).Angle(),
		unit.NewRA(10, 25, 29.042).Angle(),
		unit.NewRA(10, 24, 17.191).Angle(),
		unit.NewRA(10, 22, 57.024).Angle(),
	}
	d1 := []unit.Angle{
		unit.NewAngle(' ', 4, 04, 41.83),
		unit.NewAngle(' ', 3, 55, 54.66),
		unit.NewAngle(' ', 3, 48, 03.51),
		unit.NewAngle(' ', 3, 41, 10.25),
		unit.NewAngle(' ', 3, 35, 16.61),
	}
	// Mercury
	r2 := []unit.Angle{
		unit.NewRA(10, 24, 30.125).Angle(),
		unit.NewRA(10, 25, 00.342).Angle(),
		unit.NewRA(10, 25, 12.515).Angle(),
		unit.NewRA(10, 25, 06.235).Angle(),
		unit.NewRA(10, 24, 41.185).Angle(),
	}
	d2 := []unit.Angle{
		unit.NewAngle(' ', 6, 26, 32.05),
		unit.NewAngle(' ', 6, 10, 57.72),
		unit.NewAngle(' ', 5, 57, 33.08),
		unit.NewAngle(' ', 5, 46, 27.07),
		unit.NewAngle(' ', 5, 37, 48.45),
	}
	// 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),
		sexa.FmtTime(unit.TimeFromDay(dFrac)))

	// 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).Day())
	// format as before
	dInt, dFrac = math.Modf(d)
	fmt.Printf("%d %s %d at %s UT\n", y, time.Month(m), int(dInt),
		sexa.FmtTime(unit.TimeFromDay(dFrac)))

	// Δδ
	fmt.Printf("Δδ = %s\n", sexa.FmtAngle(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″
}