Skip to content

Commit 19d6242

Browse files
mindauglcclauss
andauthored
Add physics script for the light aberration calculation. (#12686)
* Add physics script for the light abberation calculation. * updating DIRECTORY.md --------- Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: cclauss <cclauss@users.noreply.github.com>
1 parent 8b64460 commit 19d6242

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

DIRECTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,7 @@
10261026
* [In Static Equilibrium](physics/in_static_equilibrium.py)
10271027
* [Kinetic Energy](physics/kinetic_energy.py)
10281028
* [Lens Formulae](physics/lens_formulae.py)
1029+
* [Light Aberration](physics/light_aberration.py)
10291030
* [Lorentz Transformation Four Vector](physics/lorentz_transformation_four_vector.py)
10301031
* [Magnetic Flux](physics/magnetic_flux.py)
10311032
* [Malus Law](physics/malus_law.py)

physics/light_aberration.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""
2+
Title : Calculate Light Aberration (astronomy)
3+
4+
Description :
5+
The below algorithm calculates astronomical light aberration as obtained
6+
using Special Relativity.
7+
8+
"""
9+
10+
from math import atan, sqrt, tan
11+
12+
13+
def get_aberration_angle(angle_rest: float, velocity_over_c: float) -> float:
14+
"""
15+
This method calculates astronomical light aberration.
16+
The angle at rest 'angle_rest' is given in radians [rad]
17+
and is in the range (-pi, pi).
18+
The relative velocity of observer w.r.t. to the light emitting object is
19+
expressed by 'velocity_over_c' that is given as ratio for velocity
20+
w.r.t. the speed of light c and is in the range (0, 1).
21+
22+
https://en.wikipedia.org/wiki/Aberration_(astronomy)
23+
24+
tan(phi/2) = sqrt((1 - v/c)/(1 + v/c)) * tan(theta/2)
25+
26+
Where v is the relative velocity, phi is the observed angle with respect to the
27+
velocity vector (affected by light aberration), and theta is the angle observed
28+
angle in the limit of veclocity being equal to 0.
29+
30+
Examples:
31+
>>> get_aberration_angle(0.2, 0.1)
32+
0.18102
33+
>>> get_aberration_angle(0.2, 0)
34+
0.2
35+
>>> get_aberration_angle(0, 0.2)
36+
0.0
37+
>>> get_aberration_angle(-1.5707963267948966, 0.7)
38+
-0.7954
39+
"""
40+
41+
factor = sqrt((1 - velocity_over_c) / (1 + velocity_over_c))
42+
angle_ab = 2 * atan(factor * tan(angle_rest / 2))
43+
44+
return round(angle_ab, 5)
45+
46+
47+
if __name__ == "__main__":
48+
import doctest
49+
50+
doctest.testmod()

0 commit comments

Comments
 (0)