from glob import glob
import numpy as np
from sys import argv

affix = argv[1]
v = 1
col0=3
col1=4
col2=5
fchip=0.44
kchip=0.56
offset=1000
start = 35000

files = glob('*%s*' % affix)
#print files
queueueues = []
for names in files:
	vout,tot,qfast,qslow = np.loadtxt(names,unpack=True,usecols=[v,col0,col1,col2])
	dv = np.diff(vout,n=1,prepend=-40)
	edge = np.argmax(dv) # index where hyperpolarization is released
	check = edge+offset # index at end of thing
	totm = np.amax(tot[start:])
	summ = np.sum(tot[edge:check])/offset
	post = tot[check]
	qfm = np.amax(qfast[start:])
	qsm = np.amax(qslow[start:])
	queueueues.append([totm,post,summ,qfm,qsm])
	#print names
	

queueueues.sort()
j=1
for things in queueueues:
	print 25*j, 
	for i in things:
		print i,
	print
	j+=1
	
