Skip to content

Commit ece2e6b

Browse files
Merge pull request #409 from observerly/feature/abberation/getCorrectionToEquatorialForDiurnalAbberation
feat: add getCorrectionToEquatorialForDiurnalAbberation to abberation module in @observerly/astrometry
2 parents 43f6a73 + cef8e9c commit ece2e6b

File tree

2 files changed

+83
-6
lines changed

2 files changed

+83
-6
lines changed

src/abberation.ts

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
// @author Michael Roberts <[email protected]>
44
// @package @observerly/astrometry/abberation
5-
// @license Copyright © 2021-2023 observerly
5+
// @license Copyright © 2021-2025 observerly
66

77
/*****************************************************************************************************************/
88

9-
import { getObliquityOfTheEcliptic } from './astrometry'
9+
import { getHourAngle, getObliquityOfTheEcliptic } from './astrometry'
1010

11-
import type { EquatorialCoordinate } from './common'
11+
import type { EquatorialCoordinate, GeographicCoordinate } from './common'
12+
13+
import { EARTH_RADIUS, c } from './constants'
1214

1315
import { getEccentricityOfOrbit } from './earth'
1416

@@ -82,14 +84,14 @@ export const getCorrectionToEquatorialForAnnualAbberation = (
8284
// Get the true geometric longitude of the sun (in degrees):
8385
const S = radians(getSolarTrueGeometricLongitude(datetime))
8486

85-
// Calculate the abberation correction in right ascension (in degrees):
87+
// Calculate the abberation correction in right ascension (in radians):
8688
const Δra =
8789
-κ * (Math.cos(ra) * Math.cos(S) * Math.cos(ε) + (Math.sin(ra) * Math.sin(S)) / Math.cos(dec)) +
8890
e *
8991
κ *
9092
(Math.cos(ra) * Math.cos(ϖ) * Math.cos(ε) + (Math.sin(ra) * Math.sin(ϖ)) / Math.cos(dec))
9193

92-
// Calculate the abberation correction in declination (in degrees):
94+
// Calculate the abberation correction in declination (in radians):
9395
const Δdec =
9496
-κ *
9597
(Math.cos(S) * Math.cos(ε) * (Math.tan(ε) * Math.cos(dec) - Math.sin(ra) * Math.sin(dec)) +
@@ -106,3 +108,48 @@ export const getCorrectionToEquatorialForAnnualAbberation = (
106108
}
107109

108110
/*****************************************************************************************************************/
111+
112+
/**
113+
*
114+
* getCorrectionToEquatorialForDiurnalAbberation()
115+
*
116+
* Corrects the equatorial coordinate of a target for abberation in
117+
* longitude and obliquity due to the apparent motion of the Earth.
118+
*
119+
* @param date - The date to correct the equatorial coordinate for.
120+
* @param target - The equatorial J2000 coordinate of the target.
121+
* @returns The corrected equatorial coordinate of the target.
122+
*
123+
*/
124+
export const getCorrectionToEquatorialForDiurnalAbberation = (
125+
datetime: Date,
126+
observer: GeographicCoordinate,
127+
target: EquatorialCoordinate
128+
): EquatorialCoordinate => {
129+
const dec = radians(target.dec)
130+
131+
const phi = radians(observer.latitude)
132+
133+
// Get the hour angle for the target:
134+
const ha = getHourAngle(datetime, observer.longitude, target.ra)
135+
136+
// Earth's angular velocity (in rad/s):
137+
const Ω = 7.292115e-5
138+
139+
// Calculate the observer's tangential velocity due to Earth's rotation (in m/s):
140+
const v = Ω * EARTH_RADIUS * Math.cos(phi)
141+
142+
// Calculate the abberation correction in right ascension (in radians):
143+
const Δra = ((v / c) * (Math.cos(phi) * Math.sin(ha))) / Math.cos(dec)
144+
145+
// Calculate the abberation correction in declination (in radians):
146+
const Δdec =
147+
(v / c) * (Math.sin(phi) * Math.cos(dec) - Math.cos(phi) * Math.sin(dec) * Math.cos(ha))
148+
149+
return {
150+
ra: degrees(Δra),
151+
dec: degrees(Δdec)
152+
}
153+
}
154+
155+
/*****************************************************************************************************************/

tests/abberation.spec.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { describe, expect, it } from 'vitest'
1010

1111
/*****************************************************************************************************************/
1212

13-
import { type EquatorialCoordinate, getCorrectionToEquatorialForAnnualAbberation } from '../src'
13+
import { type EquatorialCoordinate, getCorrectionToEquatorialForAnnualAbberation, getCorrectionToEquatorialForDiurnalAbberation } from '../src'
1414

1515
/*****************************************************************************************************************/
1616

@@ -51,3 +51,33 @@ describe('getCorrectionToEquatorialForAnnualAbberation', () => {
5151
})
5252

5353
/*****************************************************************************************************************/
54+
55+
describe('getCorrectionToEquatorialForDiurnalAbberation', () => {
56+
it('should be defined', () => {
57+
expect(getCorrectionToEquatorialForDiurnalAbberation).toBeDefined()
58+
})
59+
60+
it('should return the correct abberation correction for the J2000 default epoch', () => {
61+
const { ra, dec } = getCorrectionToEquatorialForDiurnalAbberation(
62+
new Date('2000-01-01T00:00:00+00:00'),
63+
{
64+
latitude,
65+
longitude
66+
},
67+
betelgeuse
68+
)
69+
expect(ra + betelgeuse.ra).toBe(88.79302762705086)
70+
expect(dec + betelgeuse.dec).toBe(7.407096948283444)
71+
})
72+
73+
it('should return the correct abberation correction for the designated epoch', () => {
74+
const { ra, dec } = getCorrectionToEquatorialForDiurnalAbberation(datetime, {
75+
latitude,
76+
longitude
77+
}, betelgeuse)
78+
expect(ra + betelgeuse.ra).toBe(88.79302581496998)
79+
expect(dec + betelgeuse.dec).toBe(7.407097343455078)
80+
})
81+
})
82+
83+
/*****************************************************************************************************************/

0 commit comments

Comments
 (0)