Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 52 additions & 5 deletions src/abberation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

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

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

import { getObliquityOfTheEcliptic } from './astrometry'
import { getHourAngle, getObliquityOfTheEcliptic } from './astrometry'

import type { EquatorialCoordinate } from './common'
import type { EquatorialCoordinate, GeographicCoordinate } from './common'

import { EARTH_RADIUS, c } from './constants'

import { getEccentricityOfOrbit } from './earth'

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

// Calculate the abberation correction in right ascension (in degrees):
// Calculate the abberation correction in right ascension (in radians):
const Δra =
-κ * (Math.cos(ra) * Math.cos(S) * Math.cos(ε) + (Math.sin(ra) * Math.sin(S)) / Math.cos(dec)) +
e *
κ *
(Math.cos(ra) * Math.cos(ϖ) * Math.cos(ε) + (Math.sin(ra) * Math.sin(ϖ)) / Math.cos(dec))

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

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

/**
*
* getCorrectionToEquatorialForDiurnalAbberation()
*
* Corrects the equatorial coordinate of a target for abberation 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 getCorrectionToEquatorialForDiurnalAbberation = (
datetime: Date,
observer: GeographicCoordinate,
target: EquatorialCoordinate
): EquatorialCoordinate => {
const dec = radians(target.dec)

const phi = radians(observer.latitude)

// Get the hour angle for the target:
const ha = getHourAngle(datetime, observer.longitude, target.ra)

// Earth's angular velocity (in rad/s):
const Ω = 7.292115e-5

// Calculate the observer's tangential velocity due to Earth's rotation (in m/s):
const v = Ω * EARTH_RADIUS * Math.cos(phi)

// Calculate the abberation correction in right ascension (in radians):
const Δra = ((v / c) * (Math.cos(phi) * Math.sin(ha))) / Math.cos(dec)

// Calculate the abberation correction in declination (in radians):
const Δdec =
(v / c) * (Math.sin(phi) * Math.cos(dec) - Math.cos(phi) * Math.sin(dec) * Math.cos(ha))

return {
ra: degrees(Δra),
dec: degrees(Δdec)
}
}

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

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

import { type EquatorialCoordinate, getCorrectionToEquatorialForAnnualAbberation } from '../src'
import { type EquatorialCoordinate, getCorrectionToEquatorialForAnnualAbberation, getCorrectionToEquatorialForDiurnalAbberation } from '../src'

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

Expand Down Expand Up @@ -51,3 +51,33 @@ describe('getCorrectionToEquatorialForAnnualAbberation', () => {
})

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

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

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

it('should return the correct abberation correction for the designated epoch', () => {
const { ra, dec } = getCorrectionToEquatorialForDiurnalAbberation(datetime, {
latitude,
longitude
}, betelgeuse)
expect(ra + betelgeuse.ra).toBe(88.79302581496998)
expect(dec + betelgeuse.dec).toBe(7.407097343455078)
})
})

/*****************************************************************************************************************/
Loading