func Example() { // Example 16.a, p. 107. h0 := unit.AngleFromDeg(.5) // apparent lower limb of Sun R := refraction.Bennett(h0) fmt.Printf("R: %.3m\n", sexa.FmtAngle(R)) tL := h0 - R // true lower fmt.Printf("L: %.3m\n", sexa.FmtAngle(tL)) tU := tL + unit.AngleFromMin(32) // add true diameter of sun fmt.Printf("U: %.3m\n", sexa.FmtAngle(tU)) R = refraction.Saemundsson(tU) fmt.Printf("R: %.3m\n", sexa.FmtAngle(R)) // Output: // R: 28.754′ // L: 1.246′ // U: 33.246′ // R: 24.618′ }
import ( "errors" "math" "github.com/soniakeys/meeus/deltat" "github.com/soniakeys/meeus/elliptic" "github.com/soniakeys/meeus/globe" "github.com/soniakeys/meeus/interp" "github.com/soniakeys/meeus/julian" pp "github.com/soniakeys/meeus/planetposition" "github.com/soniakeys/meeus/sidereal" "github.com/soniakeys/unit" ) var meanRefraction = unit.AngleFromMin(34) // "Standard altitudes" for various bodies. // // The standard altitude is the geometric altitude of the center of body // at the time of apparent rising or setting. var ( Stdh0Stellar = unit.AngleFromMin(-34) Stdh0Solar = unit.AngleFromMin(-50) Stdh0LunarMean = unit.AngleFromDeg(.125) ) // Stdh0Lunar is the standard altitude of the Moon considering π, the // Moon's horizontal parallax. func Stdh0Lunar(π unit.Angle) unit.Angle { return π.Mul(.7275) - meanRefraction
// Copyright 2013 Sonia Keys // License MIT: http://www.opensource.org/licenses/MIT package base import "github.com/soniakeys/unit" // SmallAngle is threshold used by various routines for switching between // trigonometric functions and Pythagorean approximations. // // In chapter 17, p. 109, Meeus recommends 10′. var ( SmallAngle = unit.AngleFromMin(10) // about .003 radians CosSmallAngle = SmallAngle.Cos() // about .999996 ) // Hav implements the haversine trigonometric function. // // See https://en.wikipedia.org/wiki/Haversine_formula. func Hav(a unit.Angle) float64 { // (17.5) p. 115 return .5 * (1 - a.Cos()) } // Horner evaluates a polynomal with coefficients c at x. The constant // term is c[0]. The function panics with an empty coefficient list. func Horner(x float64, c ...float64) float64 { i := len(c) - 1 y := c[i] for i > 0 { i--
// Saemundsson returns refraction for obtaining apparent altitude. // // h must be a computed true "airless" altitude of a celestial body in radians. // // Result is refraction to be added to h to obtain the apparent altitude // of the body. // // Results are consistent with Bennett to within 4 arc sec. func Saemundsson(h unit.Angle) unit.Angle { // (16.4) p. 106 hd := h.Deg() return unit.AngleFromMin(1.02 / math.Tan((hd+10.3/(hd+5.11))*math.Pi/180)) }
// Bennett2 returns refraction for obtaining true altitude. // // Similar to Bennett, but a correction is applied to give a more accurate // result. // // Results are accurate to .015 arc min. Result unit is radians. func Bennett2(h0 unit.Angle) unit.Angle { R := Bennett(h0).Min() return unit.AngleFromMin(R - .06*math.Sin((14.7*R+13)*math.Pi/180)) }
// Bennett returns refraction for obtaining true altitude. // // h0 must be a measured apparent altitude of a celestial body in radians. // // Results are accurate to .07 arc min from horizon to zenith. // // Result is refraction to be subtracted from h0 to obtain the true altitude // of the body. func Bennett(h0 unit.Angle) unit.Angle { // (16.3) p. 106 hd := h0.Deg() return unit.AngleFromMin(1 / math.Tan((hd+7.31/(hd+4.4))*math.Pi/180)) }