Skip to content

Commit 8d1c4f4

Browse files
Merge pull request #411 from observerly/feature/aberration/getCorrectionToEquatorialForAberration
2 parents bcb3101 + 82682aa commit 8d1c4f4

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

src/aberration.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,34 @@ export const getCorrectionToEquatorialForDiurnalAberration = (
153153
}
154154

155155
/*****************************************************************************************************************/
156+
157+
/**
158+
*
159+
* getCorrectionToEquatorialForAberration()
160+
*
161+
* Corrects the equatorial coordinate of a target for aberration in
162+
* longitude and obliquity due to the apparent motion of the Earth.
163+
*
164+
* @param date - The date to correct the equatorial coordinate for.
165+
* @param target - The equatorial J2000 coordinate of the target.
166+
* @returns The corrected equatorial coordinate of the target.
167+
*
168+
*/
169+
export const getCorrectionToEquatorialForAberration = (
170+
datetime: Date,
171+
observer: GeographicCoordinate,
172+
target: EquatorialCoordinate
173+
): EquatorialCoordinate => {
174+
// Get the annual aberration correction:
175+
const annual = getCorrectionToEquatorialForAnnualAberration(datetime, target)
176+
177+
// Get the diurnal aberration correction:
178+
const diurnal = getCorrectionToEquatorialForDiurnalAberration(datetime, observer, target)
179+
180+
return {
181+
ra: annual.ra + diurnal.ra,
182+
dec: annual.dec + diurnal.dec
183+
}
184+
}
185+
186+
/*****************************************************************************************************************/

tests/aberration.spec.ts

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

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

13-
import { type EquatorialCoordinate, getCorrectionToEquatorialForAnnualAberration, getCorrectionToEquatorialForDiurnalAberration } from '../src'
13+
import {
14+
type EquatorialCoordinate,
15+
getCorrectionToEquatorialForAberration,
16+
getCorrectionToEquatorialForAnnualAberration,
17+
getCorrectionToEquatorialForDiurnalAberration,
18+
} from '../src'
1419

1520
/*****************************************************************************************************************/
1621

@@ -80,4 +85,34 @@ describe('getCorrectionToEquatorialForDiurnalAberration', () => {
8085
})
8186
})
8287

88+
/*****************************************************************************************************************/
89+
90+
describe('getCorrectionToEquatorialForAberration', () => {
91+
it('should be defined', () => {
92+
expect(getCorrectionToEquatorialForAberration).toBeDefined()
93+
})
94+
95+
it('should return the correct aberration correction for the J2000 default epoch', () => {
96+
const { ra, dec } = getCorrectionToEquatorialForAberration(
97+
new Date('2000-01-01T00:00:00+00:00'),
98+
{
99+
latitude,
100+
longitude
101+
},
102+
betelgeuse
103+
)
104+
expect(ra + betelgeuse.ra).toBe(88.79875665605677)
105+
expect(dec + betelgeuse.dec).toBe(7.406836962857944)
106+
})
107+
108+
it('should return the correct aberration correction for the designated epoch', () => {
109+
const { ra, dec } = getCorrectionToEquatorialForAberration(datetime, {
110+
latitude,
111+
longitude
112+
}, betelgeuse)
113+
expect(ra + betelgeuse.ra).toBe(88.78844263611573)
114+
expect(dec + betelgeuse.dec).toBe(7.4061425995174766)
115+
})
116+
})
117+
83118
/*****************************************************************************************************************/

0 commit comments

Comments
 (0)