def read_extended_header (self) : ret = {} buf = self.read_buf (60) e = segy_h.Seg (self.endianess) keys = segy_h.Seg ().__keys__ if self.ext_hdr_type == 'U' : e = segy_h.Menlo (self.endianess) keys = segy_h.Menlo ().__keys__ elif self.ext_hdr_type == 'S' : e = segy_h.Seg (self.endianess) keys = segy_h.Seg ().__keys__ elif self.ext_hdr_type == 'P' : e = segy_h.Passcal (self.endianess) keys = segy_h.Passcal ().__keys__ elif self.ext_hdr_type == 'I' : e = segy_h.Sioseis (self.endianess) keys = segy_h.Sioseis ().__keys__ elif self.ext_hdr_type == 'N' : e = segy_h.iNova (self.endianess) keys = segy_h.iNova ().__keys__ container = e.parse (buf) for k in keys : what = "container.{0}".format (k) ret[k] = eval (what) return ret
def print_extended_header(container): if TYPE == 'U': keys = segy_h.Menlo().__keys__ elif TYPE == 'S': keys = segy_h.Seg().__keys__ elif TYPE == 'P': keys = segy_h.Passcal().__keys__ elif TYPE == 'I': keys = segy_h.Sioseis().__keys__ elif TYPE == 'N': keys = segy_h.iNova().__keys__ else: return None tt = 180 print "---------- Extended Header ----------" for k in keys: what = "container.{0}".format(k) try: if tt == 9999: raise s = SIZEOF[k] / 8 if s < 1: raise foffset = "{0:<3} - {1:>3}".format(tt, tt + s - 1) tt += s except: tt = 9999 foffset = "{0:<3} - {1:>3}".format('_', '_') print "{2} {0:<20}\t---\t{1}".format(k, eval(what), foffset)
def read_extended_header(): buf = FH.read(60) if TYPE == 'U': e = segy_h.Menlo(ENDIAN) elif TYPE == 'S': e = segy_h.Seg(ENDIAN) elif TYPE == 'P': e = segy_h.Passcal(ENDIAN) elif TYPE == 'I': e = segy_h.Sioseis(ENDIAN) elif TYPE == 'N': e = segy_h.iNova(ENDIAN) else: return None return e.parse(buf)
def set_ext_header_menlo(self): ''' Use USGS Menlo's idea of extended trace header ''' ext = {} self.extended_header = segy_h.Menlo() # Start of trace cor_low, cor_high, sort_start_time = self._cor() corrected_start_time = self.cut_start_epoch + (cor_low / 1000.0) u_secs = int(math.modf(corrected_start_time)[0] * 1000000.0) ext['start_usec'] = u_secs # Shot size in Kg try: if self.event_t['size/units_s'][0] == 'k' or self.event_t[ 'size/units_s'][0] == 'K': ext['shot_size'] = self.event_t['size/value_d'] except: pass # Shot time try: ttuple = time.gmtime(float(self.event_t['time/epoch_l'])) ext['shot_year'] = ttuple[0] ext['shot_doy'] = ttuple[7] ext['shot_hour'] = ttuple[3] ext['shot_minute'] = ttuple[4] ext['shot_second'] = ttuple[5] ext['shot_us'] = self.event_t['time/micro_seconds_i'] except: pass # Always set to 0 ext['si_override'] = 0 # Azimuth and inclination, set to 0? ext['sensor_azimuth'] = 0 ext['sensor_inclination'] = 0 # Linear moveout static x/v ms ext['lmo_ms'] = 0 # LMO flag, 1 -> n ext['lmo_flag'] = 1 # Inst type, 16 == texan if self.array_t['das/model_s'].find('130') != -1: ext['inst_type'] = 13 # RT-130 else: ext['inst_type'] = 16 # texan # Always set to 0 ext['correction'] = 0 # Uphole azimuth set to zero ext['azimuth'] = 0 # Sensor type if self.array_t['sensor/model_s'].find('28') != -1: ext['sensor_type'] = 1 # L28 elif self.array_t['sensor/model_s'].find('22') != -1: ext['sensor_type'] = 2 # L22 elif self.array_t['sensor/model_s'].find('4') != -1: ext['sensor_type'] = 4 # L4 else: ext['sensor_type'] = 99 # Don't know, don't care # Sensor sn try: ext['sensor_sn'] = int(self.array_t['sensor/serial_number_s']) except: pass # DAS sn try: ext['das_sn'] = int(self.array_t['das/serial_number_s']) except ValueError: try: ext['das_sn'] = 0xFFFF & int( self.array_t['das/serial_number_s'], 16) except ValueError: pass # 16 free bits try: ext['empty1'] = self.array_t['channel_number_i'] except: pass # Number of samples ext['samples'] = self.length_points # 32 free bits try: ext['empty2'] = int(self.array_t['description_s']) except: pass # clock correction try: ext['clock_drift'] = self._cor()[0] if ext['clock_drift'] > MAX_16 or ext['clock_drift'] < -MAX_16: ext['clock_drift'] = int(MAX_16) except: pass # 16 free bits try: ext['empty3'] = int(self.event_t['description_s']) except: pass return ext