File: angle_distance.py

package info (click to toggle)
pymap3d 2.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 436 kB
  • sloc: python: 2,729; ruby: 105; sh: 8; makefile: 7
file content (24 lines) | stat: -rwxr-xr-x 812 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python
from pymap3d.haversine import anglesep, anglesep_meeus
from argparse import ArgumentParser
from pytest import approx


def main():
    p = ArgumentParser(description="angular distance between two sky points")
    p.add_argument("r0", help="right ascension: first point [deg]", type=float)
    p.add_argument("d0", help="declination: first point [deg]", type=float)
    p.add_argument("r1", help="right ascension: 2nd point [deg]", type=float)
    p.add_argument("d1", help="declination: 2nd point [degrees]", type=float)
    a = p.parse_args()

    dist_deg = anglesep_meeus(a.r0, a.d0, a.r1, a.d1)
    dist_deg_astropy = anglesep(a.r0, a.d0, a.r1, a.d1)

    print("{:.6f} deg sep".format(dist_deg))

    assert dist_deg == approx(dist_deg_astropy)


if __name__ == "__main__":
    main()