Devuan fork of gpsd
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

35 lines
1.0 KiB

  1. #!/usr/bin/env python
  2. """Simple program to exact 5x5 magnetic variations in WMM2015
  3. from MagneticField for use in geoid.c"""
  4. import sys
  5. import subprocess
  6. for lat in range(-90, 91, 5):
  7. if -90 != lat:
  8. sys.stdout.write("},")
  9. sys.stdout.write("\n /* %d */\n { " % lat)
  10. cnt = 0
  11. for lon in range(-180, 181, 5):
  12. ge = subprocess.Popen(["MagneticField"],
  13. stdin=subprocess.PIPE,
  14. stdout=subprocess.PIPE,
  15. stderr=subprocess.PIPE,
  16. bufsize=0)
  17. # magnetic variation varies, pin at 1 Jan 2020
  18. out, err = ge.communicate(b"2020-01-01 %d %d\n" % (lat, lon))
  19. # round to even cm
  20. parts = out.split()
  21. val = round(float(parts[0]) * 100)
  22. sys.stdout.write("%6d" % val)
  23. cnt += 1
  24. if 0 == (cnt % 9):
  25. sys.stdout.write(",\n ")
  26. elif 73 != cnt:
  27. sys.stdout.write(", ")
  28. sys.stdout.write("}\n};\n")