Skip to content

Add physics script for the light aberration calculation.#12686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base:master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions physics/light_aberration.py
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
"""
Title : Calculate Light Aberration (astronomy)

Description :
The below algorithm calculates astronomical light aberration as obtained
using Special Relativity.

"""

from math import atan, sqrt, tan


def get_aberration_angle(angle_rest: float, velocity_over_c: float) -> float:
"""
This method calculates astronomical light aberration.
The angle at rest 'angle_rest' is given in radians [rad]
and is in the range (-pi, pi).
The relative velocity of observer w.r.t. to the light emitting object is
expressed by 'velocity_over_c' that is given as ratio for velocity
w.r.t. the speed of light c and is in the range (0, 1).

https://en.wikipedia.org/wiki/Aberration_(astronomy)

tan(phi/2) = sqrt((1 - v/c)/(1 + v/c)) * tan(theta/2)

Where v is the relative velocity, phi is the observed angle with respect to the
velocity vector (affected by light aberration), and theta is the angle observed
angle in the limit of veclocity being equal to 0.

Examples:
>>> get_aberration_angle(0.2, 0.1)
0.18102
>>> get_aberration_angle(0.2, 0)
0.2
>>> get_aberration_angle(0, 0.2)
0.0
>>> get_aberration_angle(-1.5707963267948966, 0.7)
-0.7954
"""

factor = sqrt((1 - velocity_over_c) / (1 + velocity_over_c))
angle_ab = 2 * atan(factor * tan(angle_rest / 2))

return round(angle_ab, 5)


if __name__ == "__main__":
import doctest

doctest.testmod()
close