File: hmstodeg

package info (click to toggle)
astrometry.net 0.76%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 18,120 kB
  • sloc: ansic: 161,636; python: 19,915; makefile: 1,439; awk: 159; cpp: 78; pascal: 67; sh: 61; perl: 9
file content (40 lines) | stat: -rwxr-xr-x 1,251 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#! /usr/bin/env python3
# This file is part of the Astrometry.net suite.
# Licensed under a 3-clause BSD style license - see LICENSE
from __future__ import print_function
from __future__ import absolute_import
import sys

# Assume this script is in $(INSTALL_DIR)/bin/ and the
# python base directory is in $(INSTALL_DIR)/lib/python/ .
try:
    # If the PYTHONPATH is already set up, don't mess with it.
    import astrometry.util.starutil_numpy
except:
    import os
    sys.path.insert(1, os.path.normpath(os.path.join(os.path.dirname(__file__), '..', 'lib', 'python')))

from astrometry.util.starutil_numpy import (hmsstring2ra, dmsstring2dec,
                                            ra2hmsstring, dec2dmsstring)

if __name__ == '__main__':
    args = sys.argv[1:]
    if len(args) != 2:
        print('Usage: %s <h:m:s> <d:m:s>' % sys.argv[0])
        sys.exit(-1)

    hms = args[0]
    dms = args[1]

    ra = hmsstring2ra(hms)
    rastr = ra2hmsstring(ra)

    dec = dmsstring2dec(dms)
    decstr = dec2dmsstring(dec)

    print('            %-20s   %-20s' % ('RA', 'Dec'))
    print('in:         %-20s   %-20s' % (hms, dms))
    print('parsed as:  %-20s   %-20s' % (rastr, decstr))
    print('deg:        %-20f   %-20f' % (ra, dec))