#!/usr/bin/env python

import sys
import os
import numpy as np

labels = ["X1", "Y1", "FWHM1", "Flux1", "Back1", "Noise1", "SigXY1", "SNR1", "Strehl1", "X2", "Y2", "FWHM2", "Flux2", "Back2", "Noise2", "SigXY2", "SNR2", "Strehl2", "Sep", "Sig_Sep", "ExpTime"]

file = sys.argv[1]

outfile = file.split('.')[0] + ".stats"

date = file.split('.')[0].split('-')[0].split('_')[1]
time = file.split('.')[0].split('-')[1]

out = open(outfile, 'w')

data = np.loadtxt(file, unpack=True)

for i in range(len(data)):
    out.write( "%10s  %10.3f \t %7.3f\n" % (labels[i], np.mean(data[i]), np.std(data[i])) )
    file = "/Users/timdimm/MASSDIMM/timDIMM/data/" + labels[i] + ".dat"
    fp = open(file, 'a')
    fp.write("%s %s \t  %10.3f \t %7.3f\n" % (date, time, np.mean(data[i]), np.std(data[i])) )
    fp.close()

out.close()


@@ -800,16 +800,303 @@
 lose()%0A%0A
+f1 = data%5B3%5D%0Af2 = data%5B12%5D%0Ascin1 = ( (f1/f1.mean())**2 ).mean() - 1%0Ascin2 = ( (f2/f2.mean())**2 ).mean() - 1%0Ascin12 = ( (f1/f1.mean() - f2/f2.mean())**2 ).mean()%0A%0Afp = open(%22Scin.dat%22, 'a')%0Afp.write(%22%25s %25s %5Ct  %256.3f %5Ct %256.3f %5Ct %256.3f%5Cn%22 %25 (date, time, scin1, scin2, scin12))%0Afp.close()%0A%0A
 out.clos

add scintillation index to set of stats measured