Skip to content

Commit

Permalink
feat: add getCorrectionToEquatorialForAberration to aberration module…
Browse files Browse the repository at this point in the history
… in @observerly/astrometry

feat: add getCorrectionToEquatorialForAberration to aberration module in @observerly/astrometry
  • Loading branch information
michealroberts committed Jan 22, 2025
1 parent bcb3101 commit 82682aa
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
31 changes: 31 additions & 0 deletions src/aberration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,34 @@ export const getCorrectionToEquatorialForDiurnalAberration = (
}

/*****************************************************************************************************************/

/**
*
* getCorrectionToEquatorialForAberration()
*
* Corrects the equatorial coordinate of a target for aberration in
* longitude and obliquity due to the apparent motion of the Earth.
*
* @param date - The date to correct the equatorial coordinate for.
* @param target - The equatorial J2000 coordinate of the target.
* @returns The corrected equatorial coordinate of the target.
*
*/
export const getCorrectionToEquatorialForAberration = (
datetime: Date,
observer: GeographicCoordinate,
target: EquatorialCoordinate
): EquatorialCoordinate => {
// Get the annual aberration correction:
const annual = getCorrectionToEquatorialForAnnualAberration(datetime, target)

// Get the diurnal aberration correction:
const diurnal = getCorrectionToEquatorialForDiurnalAberration(datetime, observer, target)

return {
ra: annual.ra + diurnal.ra,
dec: annual.dec + diurnal.dec
}
}

/*****************************************************************************************************************/
37 changes: 36 additions & 1 deletion tests/aberration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import { describe, expect, it } from 'vitest'

/*****************************************************************************************************************/

import { type EquatorialCoordinate, getCorrectionToEquatorialForAnnualAberration, getCorrectionToEquatorialForDiurnalAberration } from '../src'
import {
type EquatorialCoordinate,
getCorrectionToEquatorialForAberration,
getCorrectionToEquatorialForAnnualAberration,
getCorrectionToEquatorialForDiurnalAberration,
} from '../src'

/*****************************************************************************************************************/

Expand Down Expand Up @@ -80,4 +85,34 @@ describe('getCorrectionToEquatorialForDiurnalAberration', () => {
})
})

/*****************************************************************************************************************/

describe('getCorrectionToEquatorialForAberration', () => {
it('should be defined', () => {
expect(getCorrectionToEquatorialForAberration).toBeDefined()
})

it('should return the correct aberration correction for the J2000 default epoch', () => {
const { ra, dec } = getCorrectionToEquatorialForAberration(
new Date('2000-01-01T00:00:00+00:00'),
{
latitude,
longitude
},
betelgeuse
)
expect(ra + betelgeuse.ra).toBe(88.79875665605677)
expect(dec + betelgeuse.dec).toBe(7.406836962857944)
})

it('should return the correct aberration correction for the designated epoch', () => {
const { ra, dec } = getCorrectionToEquatorialForAberration(datetime, {
latitude,
longitude
}, betelgeuse)
expect(ra + betelgeuse.ra).toBe(88.78844263611573)
expect(dec + betelgeuse.dec).toBe(7.4061425995174766)
})
})

/*****************************************************************************************************************/

0 comments on commit 82682aa

Please sign in to comment.