geomag/model_to_include.py
author A.M. Thurnherr <athurnherr@yahoo.com>
Mon, 23 Feb 2015 09:19:46 +0000
changeset 15 3746197831db
parent 5 033a169071de
permissions -rw-r--r--
IX11beta for CLIVAR P16

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