import sys
import os
from glob import glob
from frappy_psi.calcurve import CalCurve

os.chdir('/Users/zolliker/gitpsi/calcurves')

if len(sys.argv) > 1:
    calib = sys.argv[1]
    c = CalCurve(calib)
else:
    for file in sorted(glob('*.*')):
        if file.endswith('.md') or file.endswith('.std'):
            continue
        try:
            c = CalCurve(file)
            xy = c.export()
            print('%9.4g %12.7g %9.4g %9.4g %s' % (tuple(c.extx) + tuple(c.exty) + (file,)))
        except Exception as e:
            print(file, e)
            calib = file

