def extrahierePeaks(self,starttime,endtime,timescale,nitems): print "\n",time.ctime(),": Binary File will be read and extracted..." f_p_1 = open('../../../peakdetektor1.hex','rb') f_p_2 = open('../../../peakdetektor2.hex','rb') f_p_3 = open('../../../peakdetektor3.hex','rb') f_pv_1 = open('../../../peakband1.hex','rb') f_pv_2 = open('../../../peakband2.hex','rb') f_pv_3 = open('../../../peakband3.hex','rb') a_p_1 = numpy.fromfile(f_p_1,dtype='b') a_p_2 = numpy.fromfile(f_p_2,dtype='b') a_p_3 = numpy.fromfile(f_p_3,dtype='b') a_pv_1 = numpy.fromfile(f_pv_1,dtype=numpy.complex64) a_pv_2 = numpy.fromfile(f_pv_2,dtype=numpy.complex64) a_pv_3 = numpy.fromfile(f_pv_3,dtype=numpy.complex64) """There is a Bug which lets the arrays not to be the same shape size.""" upper_limit = numpy.amin([len(a_pv_1),len(a_pv_2),len(a_pv_3)]) a_p_1.resize((upper_limit,)) a_p_2.resize((upper_limit,)) a_p_3.resize((upper_limit,)) a_pv_1.resize((upper_limit,)) a_pv_2.resize((upper_limit,)) a_pv_3.resize((upper_limit,)) criterion = (a_p_1==1) | (a_p_2==1) | (a_p_3==1) a_time = numpy.array(numpy.arange(0.0,upper_limit*timescale, timescale),dtype='f') """Is the data still saved at the last analysis ?""" print "a_time ist",a_time print "len(a_time[criterion]) ist",len(a_time[criterion]) print "a_time[criterion] ist",a_time[criterion] print "a_p_1 ist",a_p_1 print "len(a_p_1[criterion]) ist",len(a_p_1[criterion]) print "a_p_1[criterion] ist",a_p_1[criterion] print "a_pv_1 ist",a_pv_1 print "len(a_pv_1[criterion]) ist",len(a_pv_1[criterion]) print "a_pv_1[criterion] ist",a_pv_1[criterion] try: f_input = open('../../../peakswerteundzeit.dat','rb') a_time_old,a_p_1_old,a_p_2_old,\ a_p_3_old,a_pv_1_old,a_pv_2_old,\ a_pv_3_old = cPickle.load(f_input) if len(a_time_old) == len(a_time[criterion]): print time.ctime(),"Data seems to be the same as the data before, therefore\n",\ "i do not save this data again.","\n...finished.\n" else: print time.ctime(),"...i am going to save the data ..." f_output = open('../../../peakswerteundzeit.dat','wb') cPickle.dump((a_time[criterion], a_p_1[criterion], a_p_2[criterion], a_p_3[criterion], a_pv_1[criterion], a_pv_2[criterion], a_pv_3[criterion]),f_output) f_output.close() print time.ctime(),"...finished!\n" f_input.close() except: print time.ctime(),"...i am going to save the data ..." f_output = open('../../../peakswerteundzeit.dat','wb') cPickle.dump((a_time[criterion], a_p_1[criterion], a_p_2[criterion], a_p_3[criterion], a_pv_1[criterion], a_pv_2[criterion], a_pv_3[criterion]),f_output) f_output.close() print time.ctime(),"...finished!\n" f_p_1.close() f_p_2.close() f_p_3.close() f_pv_1.close() f_pv_2.close() f_pv_3.close()