NoPaste

Markus Feldmann 2009-05-27 extrahierePeaks2

von Anonymous

SNIPPET_TEXT:
  1. def extrahierePeaks(self,starttime,endtime,timescale,nitems):
  2.         print "\n",time.ctime(),": Binary File will be read and extracted..."
  3.         f_p_1 = open('../../../peakdetektor1.hex','rb')
  4.         f_p_2 = open('../../../peakdetektor2.hex','rb')
  5.         f_p_3 = open('../../../peakdetektor3.hex','rb')
  6.         f_pv_1 = open('../../../peakband1.hex','rb')
  7.         f_pv_2 = open('../../../peakband2.hex','rb')
  8.         f_pv_3 = open('../../../peakband3.hex','rb')
  9.         a_p_1 = numpy.fromfile(f_p_1,dtype='b')
  10.         a_p_2 = numpy.fromfile(f_p_2,dtype='b')
  11.         a_p_3 = numpy.fromfile(f_p_3,dtype='b')
  12.         a_pv_1 = numpy.fromfile(f_pv_1,dtype=numpy.complex64)
  13.         a_pv_2 = numpy.fromfile(f_pv_2,dtype=numpy.complex64)
  14.         a_pv_3 = numpy.fromfile(f_pv_3,dtype=numpy.complex64)
  15.         """There is a Bug which lets the arrays not to be the same shape size."""    
  16.         upper_limit = numpy.amin([len(a_pv_1),len(a_pv_2),len(a_pv_3)])
  17.         a_p_1.resize((upper_limit,))
  18.         a_p_2.resize((upper_limit,))
  19.         a_p_3.resize((upper_limit,))
  20.         a_pv_1.resize((upper_limit,))
  21.         a_pv_2.resize((upper_limit,))
  22.         a_pv_3.resize((upper_limit,))
  23.         criterion = (a_p_1==1) | (a_p_2==1) | (a_p_3==1)
  24.         a_time = numpy.array(numpy.arange(0.0,upper_limit*timescale,
  25.                                           timescale),dtype='f')
  26.         """Is the data still saved at the last analysis ?"""
  27.         print "a_time ist",a_time
  28.         print "len(a_time[criterion]) ist",len(a_time[criterion])
  29.         print "a_time[criterion] ist",a_time[criterion]
  30.         print "a_p_1 ist",a_p_1
  31.         print "len(a_p_1[criterion]) ist",len(a_p_1[criterion])
  32.         print "a_p_1[criterion] ist",a_p_1[criterion]
  33.         print "a_pv_1 ist",a_pv_1
  34.         print "len(a_pv_1[criterion]) ist",len(a_pv_1[criterion])
  35.         print "a_pv_1[criterion] ist",a_pv_1[criterion]
  36.         try:
  37.             f_input = open('../../../peakswerteundzeit.dat','rb')
  38.             a_time_old,a_p_1_old,a_p_2_old,\
  39.                 a_p_3_old,a_pv_1_old,a_pv_2_old,\
  40.                 a_pv_3_old = cPickle.load(f_input)
  41.             if len(a_time_old) == len(a_time[criterion]):
  42.                 print time.ctime(),"Data seems to be the same as the data before, therefore\n",\
  43.                     "i do not save this data again.","\n...finished.\n"
  44.             else:
  45.                 print time.ctime(),"...i am going to save the data ..."
  46.                 f_output = open('../../../peakswerteundzeit.dat','wb')
  47.                 cPickle.dump((a_time[criterion],
  48.                               a_p_1[criterion],
  49.                               a_p_2[criterion],
  50.                               a_p_3[criterion],
  51.                               a_pv_1[criterion],
  52.                               a_pv_2[criterion],
  53.                               a_pv_3[criterion]),f_output)
  54.                 f_output.close()
  55.                 print time.ctime(),"...finished!\n"
  56.             f_input.close()
  57.         except:
  58.             print time.ctime(),"...i am going to save the data ..."
  59.             f_output = open('../../../peakswerteundzeit.dat','wb')
  60.             cPickle.dump((a_time[criterion],
  61.                           a_p_1[criterion],
  62.                           a_p_2[criterion],
  63.                           a_p_3[criterion],
  64.                           a_pv_1[criterion],
  65.                           a_pv_2[criterion],
  66.                           a_pv_3[criterion]),f_output)
  67.             f_output.close()
  68.             print time.ctime(),"...finished!\n"
  69.         f_p_1.close()
  70.         f_p_2.close()
  71.         f_p_3.close()
  72.         f_pv_1.close()
  73.         f_pv_2.close()
  74.         f_pv_3.close()

Quellcode

Hier kannst du den Code kopieren und ihn in deinen bevorzugten Editor einfügen. PASTEBIN_DOWNLOAD_SNIPPET_EXPLAIN