Esempio n. 1
0
 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
Esempio n. 2
0
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)
Esempio n. 3
0
    def set_ext_header_pas(self):
        ext = {}
        self.extended_header = segy_h.Passcal()

        cor_low, cor_high, sort_start_time = self._cor()
        if cor_high < -MAX_16 or cor_high > MAX_16:
            #print cor_high
            cor_high = int(MAX_16)

        ext['totalStaticHi'] = cor_high
        ext['num_samps'] = int(self.length_points)
        ext['max'] = numpy.max(self.data)
        ext['min'] = numpy.min(self.data)
        ext['samp_rate'] = int((1.0 / self.sample_rate) * 1000000.0)
        ext['data_form'] = 1  #   32 bit
        #   *XXX*  Is this also set where the trace is written?
        ext['scale_fac'] = float(self.response_t['bit_weight/value_d'])
        #ext['scale_fac'] = 1. / 184128195.173

        corrected_start_time = self.cut_start_epoch + (cor_low / 1000.0)
        m_secs = int(math.modf(corrected_start_time)[0] * 1000.0)
        ext['m_secs'] = m_secs

        try:
            ttuple = time.gmtime([self.event_t['time/epoch_l']])
            ext['trigyear'] = ttuple[0]
            ext['trigday'] = ttuple[7]
            ext['trighour'] = ttuple[3]
            ext['trigminute'] = ttuple[4]
            ext['trigsecond'] = ttuple[5]
            ext['trigmills'] = int(self.event_t['time/micro_seconds_i'] /
                                   1000.0)
        except:
            pass

        try:
            try:
                ext['inst_no'] = int(
                    self.array_t['das/serial_number_s']) & 0xFFFF
            except ValueError:
                ext['inst_no'] = int(self.array_t['das/serial_number_s'], 16)
        except:
            ext['inst_no'] = 0

        try:
            ext['station_name'] = string.ljust(
                string.strip(self.array_t['id_s']), 6)
        except:
            ext['station_name'] = string.ljust(
                string.strip(self.array_t['das/serial_number_s']), 6)

        return ext
Esempio n. 4
0
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)