@@ -14,26 +14,28 @@ import { convertDegreesToRadians as radians } from './utilities'
1414
1515/**
1616 *
17- * getCorrectionToHorizontalForRefraction ()
17+ * getRefraction ()
1818 *
19- * The correct to the HorizontalCoordinate for refraction is an adjustment to the observed
20- * HorizontalCoordinate based on pressure and temperature effects.
19+ * The refraction correction to the observed object is an adjustment to the observed object
20+ * based on pressure and temperature effects.
21+ *
22+ * N.B. There is no correction for the azimuthal angle.
2123 *
2224 * @param target - The horizontal coordinate of the observed object.
2325 * @param temperature - The temperature in Kelvin.
2426 * @param pressure - The pressure in Pascals.
25- * @returns The horizontal coordinate of the observed object corrected for atmospheric refraction .
27+ * @returns The refraction correction to the observed object (in degrees) .
2628 *
2729 */
28- export const getCorrectionToHorizontalForRefraction = (
30+ export const getRefraction = (
2931 target : HorizontalCoordinate ,
3032 temperature : number = 283.15 ,
3133 pressure : number = 101325
32- ) : HorizontalCoordinate => {
33- const { alt, az } = target
34+ ) : number => {
35+ const { alt } = target
3436
3537 if ( alt < 0 ) {
36- return target
38+ return Number . POSITIVE_INFINITY
3739 }
3840
3941 // The pressure, in Pascals:
@@ -45,6 +47,38 @@ export const getCorrectionToHorizontalForRefraction = (
4547 // Get the atmospheric refraction in degrees, corrected for temperature and pressure:
4648 const R = ( 1.02 / Math . tan ( radians ( alt + 10.3 / ( alt + 5.11 ) ) ) / 60 ) * ( P / 101325 ) * ( 283.15 / T )
4749
50+ return R
51+ }
52+
53+ /*****************************************************************************************************************/
54+
55+ /**
56+ *
57+ * getCorrectionToHorizontalForRefraction()
58+ *
59+ * The correction to the HorizontalCoordinate for refraction is an adjustment to the observed
60+ * HorizontalCoordinate based on pressure and temperature effects.
61+ *
62+ * @param target - The horizontal coordinate of the observed object.
63+ * @param temperature - The temperature in Kelvin.
64+ * @param pressure - The pressure in Pascals.
65+ * @returns The horizontal coordinate of the observed object corrected for atmospheric refraction.
66+ *
67+ */
68+ export const getCorrectionToHorizontalForRefraction = (
69+ target : HorizontalCoordinate ,
70+ temperature : number = 283.15 ,
71+ pressure : number = 101325
72+ ) : HorizontalCoordinate => {
73+ const { alt, az } = target
74+
75+ if ( alt < 0 ) {
76+ return target
77+ }
78+
79+ // Get the atmospheric refraction in degrees, corrected for temperature and pressure:
80+ const R = getRefraction ( target , temperature , pressure )
81+
4882 return {
4983 alt : alt + R ,
5084 az : az
0 commit comments