UNPKG

3.25 kBJavaScriptView Raw
1/**
2 * @copyright 2013 Sonia Keys
3 * @copyright 2016 commenthol
4 * @license MIT
5 * @module refraction
6 */
7/**
8 * Refraction: Chapter 16: Atmospheric Refraction.
9 *
10 * Functions here assume atmospheric pressure of 1010 mb, temperature of
11 * 10°C, and yellow light.
12 */
13import sexa from './sexagesimal';
14var sin = Math.sin,
15 tan = Math.tan;
16
17var D2R = Math.PI / 180;
18
19var gt15true1 = new sexa.Angle(false, 0, 0, 58.294).rad();
20var gt15true2 = new sexa.Angle(false, 0, 0, 0.0668).rad();
21var gt15app1 = new sexa.Angle(false, 0, 0, 58.276).rad();
22var gt15app2 = new sexa.Angle(false, 0, 0, 0.0824).rad();
23
24/**
25 * gt15True returns refraction for obtaining true altitude when altitude
26 * is greater than 15 degrees (about 0.26 radians.)
27 *
28 * h0 must be a measured apparent altitude of a celestial body in radians.
29 *
30 * Result is refraction to be subtracted from h0 to obtain the true altitude
31 * of the body. Unit is radians.
32 */
33export function gt15True(h0) {
34 // (h0 float64) float64
35 // (16.1) p. 105
36 var t = tan(Math.PI / 2 - h0);
37 return gt15true1 * t - gt15true2 * t * t * t;
38}
39
40/**
41 * gt15Apparent returns refraction for obtaining apparent altitude when
42 * altitude is greater than 15 degrees (about 0.26 radians.)
43 *
44 * h must be a computed true "airless" altitude of a celestial body in radians.
45 *
46 * Result is refraction to be added to h to obtain the apparent altitude
47 * of the body. Unit is radians.
48 */
49export function gt15Apparent(h) {
50 // (h float64) float64
51 // (16.2) p. 105
52 var t = tan(Math.PI / 2 - h);
53 return gt15app1 * t - gt15app2 * t * t * t;
54}
55
56/**
57 * Bennett returns refraction for obtaining true altitude.
58 *
59 * h0 must be a measured apparent altitude of a celestial body in radians.
60 *
61 * Results are accurate to 0.07 arc min from horizon to zenith.
62 *
63 * Result is refraction to be subtracted from h0 to obtain the true altitude
64 * of the body. Unit is radians.
65 */
66export function bennett(h0) {
67 // (h0 float64) float64
68 // (16.3) p. 106
69 var c1 = D2R / 60;
70 var c731 = 7.31 * D2R * D2R;
71 var c44 = 4.4 * D2R;
72 return c1 / tan(h0 + c731 / (h0 + c44));
73}
74
75/**
76 * Bennett2 returns refraction for obtaining true altitude.
77 *
78 * Similar to Bennett, but a correction is applied to give a more accurate
79 * result.
80 *
81 * Results are accurate to 0.015 arc min. Result unit is radians.
82 */
83export function bennett2(h0) {
84 // (h0 float64) float64
85 var cMin = 60 / D2R;
86 var c06 = 0.06 / cMin;
87 var c147 = 14.7 * cMin * D2R;
88 var c13 = 13 * D2R;
89 var R = bennett(h0);
90 return R - c06 * sin(c147 * R + c13);
91}
92
93/**
94 * Saemundsson returns refraction for obtaining apparent altitude.
95 *
96 * h must be a computed true "airless" altitude of a celestial body in radians.
97 *
98 * Result is refraction to be added to h to obtain the apparent altitude
99 * of the body.
100 *
101 * Results are consistent with Bennett to within 4 arc sec.
102 * Result unit is radians.
103 */
104export function saemundsson(h) {
105 // (h float64) float64
106 // (16.4) p. 106
107 var c102 = 1.02 * D2R / 60;
108 var c103 = 10.3 * D2R * D2R;
109 var c511 = 5.11 * D2R;
110 return c102 / tan(h + c103 / (h + c511));
111}
112
113export default {
114 gt15True: gt15True,
115 gt15Apparent: gt15Apparent,
116 bennett: bennett,
117 bennett2: bennett2,
118 saemundsson: saemundsson
119};
\No newline at end of file