def updateAll(self, file): self.currentFile = file segy = pssegy.Segy(file) self.setSegy(segy) self.xComponentToolButton.setChecked(False) self.yComponentToolButton.setChecked(False) self.zComponentToolButton.setChecked(True) self.initPlot()
def saveSegy(filename, trace, dt = 1000): ## prepare SEGY header ns, ntr = trace.shape SH = pssegy.getDefaultSegyHeader(ntr, ns) STH = pssegy.getDefaultSegyTraceHeaders(ntr, ns, dt) STH['TraceIdentificationCode'][0:ntr:3] = 14.0 STH['TraceIdentificationCode'][1:ntr:3] = 13.0 STH['TraceIdentificationCode'][2:ntr:3] = 12.0 rcvlist = [1] STH['Inline3D'][0:int(ntr/3)] = np.array(rcvlist) STH['Inline3D'][int(ntr/3): 2*int(ntr/3)] = np.array(rcvlist) STH['Inline3D'][2*int(ntr/3): 3*int(ntr/3)] = np.array(rcvlist) # deal with date time ns_start = 0 #int(istart/1000) # delayed seconds # delay_hour = (ns_start/1000/60)//60 # delay_min = floor(ns_start/1000/60)%60) # delay_sec = (ns_start/1000/60)%60 - delay_min) * 60 # timestamp = 0 # d = datetime.timedelta(seconds=ns_start) # new_timestamp = timestamp+d # record_day = datetime.datetime(2018,12,1) # day_of_year = (record_day - datetime.datetime(record_day.year, 1, 1)).days + 1 # #print(day_of_year) # STH['YearDataRecorded'] = np.ones((ntr,), dtype = np.float) * 2018.0 # STH['DayOfYear'] = np.ones((ntr,), dtype = np.float) * day_of_year # STH['HourOfDay'] = np.ones((ntr,), dtype = np.float) * new_timestamp.hour # STH['MinuteOfHour'] = np.ones((ntr,), dtype = np.float) * new_timestamp.minute # STH['SecondOfMinute'] = np.ones((ntr,), dtype = np.float) * new_timestamp.second # base_name = new_timestamp.strftime("%Y%m%d_%H%M%S") # write SEG-Y file to disk segy = pssegy.Segy(trace, SH, STH) segy.toSegyFile(filename)
def convert2segy(outfile, filelist, rcvlist, args): i = 0 data = None inds = [0] # rcvlist effective for filename, rcvname in zip(filelist, rcvlist): with open(filename, 'rb') as f: traces = parseDataBuffer(f, dsf=args['dsf']) #print(traces.shape) if i == 0: data = traces.copy() else: ld = data.shape[0] lt = traces.shape[0] if ld == lt: data = np.concatenate((data, traces), axis=1) inds.append(i) i += 1 ## prepare SEGY header dt = args['dt'] ns, ntr = data.shape rcvs = np.array(rcvlist)[inds] SH = pssegy.getDefaultSegyHeader(ntr, ns, dt) STH = pssegy.getDefaultSegyTraceHeaders(ntr, ns, dt) STH['TraceIdentificationCode'][0:ntr:3] = 14.0 STH['TraceIdentificationCode'][1:ntr:3] = 13.0 STH['TraceIdentificationCode'][2:ntr:3] = 12.0 STH['Inline3D'] = np.repeat(rcvs, 3) # STH['Inline3D'][0:int(ntr/3)] = rcvs # STH['Inline3D'][int(ntr/3): 2*int(ntr/3)] = rcvs # STH['Inline3D'][2*int(ntr/3): 3*int(ntr/3)] = rcvs # deal with date time # basename = os.path.basename(outfile) # fname = os.path.splitext(basename)[0] fname = '20191126_000000' ymd_hms = fname.split('_') ymd = ymd_hms[0] hms = ymd_hms[1] yy = int(float(ymd[:4])) mm = int(float(ymd[4:6])) dd = int(float(ymd[6:])) hour = int(float(hms[:2])) minute = int(float(hms[2:4])) second = 0 record_day = datetime.datetime(yy, mm, dd) day_of_year = (record_day - datetime.datetime(record_day.year, 1, 1)).days + 1 #print(day_of_year) STH['YearDataRecorded'] = np.ones((ntr, ), dtype=np.float) * 2018.0 STH['DayOfYear'] = np.ones((ntr, ), dtype=np.float) * day_of_year STH['HourOfDay'] = np.ones((ntr, ), dtype=np.float) * hour STH['MinuteOfHour'] = np.ones((ntr, ), dtype=np.float) * minute STH['SecondOfMinute'] = np.ones((ntr, ), dtype=np.float) * second # write SEG-Y file to disk segy = pssegy.Segy(data, SH, STH) segy.toSegyFile(outfile) print(outfile, ' written[OK].')
self.fileComboBox.currentIndexChanged.connect(self.selectionChanged) def selectionChanged(self): self.currentIndex = self.fileComboBox.currentIndex() self.currentFile = self.fileList[self.currentIndex] self.parent.updateAll(self.currentFile) def onPrevious(self): if self.currentFile != 0: self.currentIndex -= 1 self.fileComboBox.setCurrentIndex(self.currentIndex) def onNext(self): if self.currentFile != self.indexMax: self.currentIndex += 1 self.fileComboBox.setCurrentIndex(self.currentIndex) if __name__ == "__main__": qapp = QApplication(sys.argv) app = EventPicker() filename = 'xx' # replace this with your .sgy file segy = pssegy.Segy(filename) app.setSegy(segy) app.initPlot() app.show() qapp.exec_()