File: get_geoid_table.py

package info (click to toggle)
gpsd 3.27-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 44,056 kB
  • sloc: ansic: 74,438; python: 16,521; sh: 890; cpp: 848; php: 225; makefile: 197; perl: 111; javascript: 26; xml: 11
file content (40 lines) | stat: -rwxr-xr-x 1,087 bytes parent folder | download | duplicates (2)
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

"""Simple program to exact 5x5 geoid separations in EGM2008.

Use the GeoidEval program from:
    https://geographiclib.sourceforge.io

Maybe someday use their python?
from GeoidEval for use in geoidc
"""

import sys
import subprocess


for lat in range(-90, 91, 5):
    if -90 != lat:
        sys.stdout.write("},")

    sys.stdout.write("\n    /* %d */\n    { " % lat)

    cnt = 0
    for lon in range(-180, 181, 5):
        ge = subprocess.Popen(["GeoidEval",
                                "-n", "egm2008-1"],
                                stdin=subprocess.PIPE,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE,
                                bufsize=0)
        out, err = ge.communicate(b"%d %d\n" % (lat, lon))
        # round to even cm
        val = round(float(out) * 100)
        sys.stdout.write("%5d" % val)
        cnt += 1
        if 0 == (cnt % 10):
            sys.stdout.write(",\n      ")
        elif 73 != cnt:
            sys.stdout.write(", ")

sys.stdout.write("}\n};\n")