geomag/model_to_include.py
author A.M. Thurnherr <athurnherr@yahoo.com>
Thu, 18 Jul 2013 04:16:14 +0000
changeset 6 875d0c0f6ab2
parent 5 033a169071de
permissions -rw-r--r--
before fixing bug submitted by Dan Torres July 17

#!/usr/bin/env python

"""
Quick script to generate an include file from a model coefficient file,
so we can include the current set of models in the compiled program.
"""

lines = open("IGRF11.COF").readlines()
outfile = open("igrf11.h", "w")

outfile.write("char *model_lines[] = {\n")

for line in lines:
    line = line.rstrip()
    outfile.write('"%s",\n' % (line,))

outfile.write('""};\n')  # empty line as a terminator

outfile.close()