def get_data_and_trace_heads(self): if( self.f == None): raise Exception("File not open. Use open('path')") self.f.seek(3600,0) coef = self.check_coef() self.trace_bin_headers=None offset =self.bin_head.Samples*coef #print(offset) # all={}#pandas.DataFrame(index=np.arange(0,len(Heads.TraceBinHead().__dict__.keys())),columns=Heads.TraceBinHead().__dict__.keys()) all= np.zeros((self.count_trace, len(Heads.TraceBinHead().__dict__.keys())), dtype=np.int32) data = np.zeros((self.count_trace, self.bin_head.Samples), dtype=np.float32) trace_head = Heads.TraceBinHead() start_tp=time() for i in range(0,self.count_trace): # start=time() b=trace_head.get_all_trace(self.f.read(240), self.order) step_count = b["TRACE_SAMPLE_COUNT"] all[i]=list(b.values()) step_count=self.bin_head.Samples datas = (self.f.read(coef*step_count)) sample= self.__get_sample(coef,datas) data[i]=sample # print(time()-start) self.data=data strat = time() self.trace_bin_headers = pandas.DataFrame(data=all,columns=Heads.TraceBinHead().__dict__.keys())#,orient='index') return self.data ,self.trace_bin_headers
def get_step_count(self): self.f.seek(3600, 0) trace_head = Heads.TraceBinHead() b = trace_head.get_all_trace(self.f.read(240), self.order) step_count = b["TRACE_SAMPLE_COUNT"] self.f.seek(3600, 0) return step_count
def __get_step_count(self): """ inner function don't call """ trace_head = Heads.TraceBinHead() b = trace_head.get_all_trace(self.f.read(240), self.order) step_count = b["TRACE_SAMPLE_COUNT"] return step_count
def get_null_trace(): """ inner function """ ar = Heads.TraceBinHead() for i,k in ar.__dict__.items(): ar.__dict__[i]=0 return ar
def create_data_frame(self,series): """ create dataFrame with input series, where columns is Trace Heads input series with data for Trace Head return res = dataFrame """ res = pandas.DataFrame.from_dict(data=series,columns=Heads.TraceBinHead().__dict__.keys(),orient='index') return res
def read_bin_trace_specefic(self, param): self.f.seek(3600, 0) all=[] trace_head = Heads.TraceBinHead() for i in range(0, self.count_trace): cur = self.f.tell() all.append(trace_head.get_specific_trace(self.f,self.order,cur,param)) self.f.seek(cur+240,0) step_count = self.bin_head.Samples self.f.seek(step_count*self.check_coef(),1) return pandas.DataFrame(all)
def get_step_count(self): """ return sample count input - return: step count - Trace Sample Count """ self.f.seek(3600, 0) trace_head = Heads.TraceBinHead() b = trace_head.get_all_trace(self.f.read(240), self.order) step_count = b["TRACE_SAMPLE_COUNT"] self.f.seek(3600, 0) return step_count
def get_data_and_trace_heads(self): if (self.f == None): raise Exception("File not open. Use open('path')") self.f.seek(3600, 0) coef = self.check_coef() self.trace_bin_headers = None offset = self.bin_head.Samples * coef #print(offset) all = { } #pandas.DataFrame(index=np.arange(0,len(Heads.TraceBinHead().__dict__.keys())),columns=Heads.TraceBinHead().__dict__.keys()) data = [] trace_head = Heads.TraceBinHead() start_tp = time() for i in range(0, self.count_trace): start = time() b = trace_head.get_all_trace(self.f.read(240), self.order) step_count = b["TRACE_SAMPLE_COUNT"] all[i] = b.values() step_count = self.bin_head.Samples datas = (self.f.read(coef * step_count)) sample = self.__get_sample(coef, datas) data.append(sample) #print(time()-start_tp) self.data = np.array(data) # strat = time() self.trace_bin_headers = pandas.DataFrame.from_dict( data=all, columns=Heads.TraceBinHead().__dict__.keys(), orient='index') self.trace_bin_headers["IDX"] = np.arange(len(self.trace_bin_headers)) # print(time() -strat) self.trace_bin_headers = self.delete_rows_cols(self.trace_bin_headers) self.trace_bin_headers = self.trace_bin_headers.drop(["spare"], axis=1) return self.data, self.trace_bin_headers
def get_null_trace(): ar = Heads.TraceBinHead() for i, k in ar.__dict__.items(): ar.__dict__[i] = 0 return ar
def create_data_frame(self, series): res = pandas.DataFrame.from_dict( data=series, columns=Heads.TraceBinHead().__dict__.keys(), orient='index') return res
def __get_step_count(self): trace_head = Heads.TraceBinHead() b = trace_head.get_all_trace(self.f.read(240), self.order) step_count = b["TRACE_SAMPLE_COUNT"] return step_count