def plotdfmienc(): cTCA = None chs=[] ### Make list of lists to for i in range(13): chs+=[[]] ### hold Clk & counters fyle = open('dfmienc_v2_110215_162959.tab') ### Open the file fyle.readline() ### Skip 1 line (HEADER) for row in fyle.readlines(): ### Loop over TABLE rows toks = row.split(',') ### Split row at commas if toks[0]<'"2011-02-15T04:37:42': continue ### Skip before TCA-90s if toks[0]>'"2011-02-15T04:40:42': continue ### Skip after TCA+90s for i,iCol in enumerate([2]+range(8,20)): ### Loop Clock+count COLs val = max( 0.1 ,float(toks[iCol]) ) ### Extract COLUMN value, chs[i] += [val] ### append to inner list if cTCA is None and \ toks[0][1:20]=='2011-02-15T04:39:12': ### At TCA, cTCA = float(toks[2]) ### save DFMI Clock fyle.close() ### Close the file ### At this point: ### chs[0] is a list of the DFMI clock values; ### chs[1] is a list of the A1a values; ### chs[2] is a list of the A1b values; ### ... ### chs[5] is a list of the M1 values; ### ... ### chs[9] is a list of the m1 values; ### ... import matplotlib.pyplot as plt ### Import plot module plt.plot(chs[0],chs[5],'r',label='M1') ### Plot DFMI clock vs M1 plt.plot(chs[0],chs[9],'g',label='m1') ### Plot DFMI clock vs m1 plt.plot([cTCA,cTCA],[.1,max(chs[5]+chs[9])] ,'b',label='TCA') ### Plot vert line at TCA plt.semilogy() ### Plot on log Y scale plt.legend(loc='best') ### Draw legend plt.xlabel('DFMI Clock, s') ### Draw X label plt.ylabel('Threshold counter') ### Draw Y label plt.show() ### Show plot