geomag/model_to_include.py
author A.M. Thurnherr <ant@ldeo.columbia.edu>
Thu, 18 Jul 2013 04:12:24 -0400
changeset 10 d273b7bacb36
parent 5 033a169071de
permissions -rw-r--r--
after mege with laptop version

#!/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()