Example #1
0
    def to_trace(self):

        assert self.iftype == SacFile.header_name2num['itime']
        assert self.leven == True

        tmin = self.get_ref_time()
        tmax = tmin + self.delta * (self.npts - 1)

        data = None
        if self.data:
            data = self.data[0]

        meta = {}
        exclude = ('b', 'e', 'knetwk', 'kstnm', 'khole', 'kcmpnm', 'delta',
                   'nzyear', 'nzjday', 'nzhour', 'nzmin', 'nzsec', 'nzmsec')
        for k in SacFile.header_keys:
            if k in exclude: continue
            v = self.__dict__[k]
            if v is not None:
                meta[reuse(k)] = v

        return trace.Trace(nonetoempty(self.knetwk)[:2],
                           nonetoempty(self.kstnm)[:5],
                           nonetoempty(self.khole)[:2],
                           nonetoempty(self.kcmpnm)[:3],
                           tmin,
                           tmax,
                           self.delta,
                           data,
                           meta=meta)
Example #2
0
 def to_trace(self):
     
     assert self.iftype == SacFile.header_name2num['itime']
     assert self.leven == True
     
     tmin = self.get_ref_time()
     tmax = tmin + self.delta*(self.npts-1)
     
     data =None
     if self.data:
         data = self.data[0]
         
     meta = {}
     exclude = ('b', 'e', 'knetwk', 'kstnm', 'khole', 'kcmpnm', 'delta', 'nzyear', 'nzjday', 'nzhour', 'nzmin', 'nzsec', 'nzmsec')
     for k in SacFile.header_keys:
         if k in exclude: continue
         v = self.__dict__[k]
         if v is not None:
             meta[reuse(k)] = v
             
     return trace.Trace(nonetoempty(self.knetwk)[:2],
                               nonetoempty(self.kstnm)[:5],
                               nonetoempty(self.khole)[:2],
                               nonetoempty(self.kcmpnm)[:3],
                               tmin,
                               tmax,
                               self.delta,
                               data,
                               meta=meta)
Example #3
0
 def _convert_small_sets_to_tuples(self):
     if len(self.networks) < 32:
         self.networks = reuse(tuple(self.networks))
         self.have_tuples = True
     if len(self.stations) < 32:
         self.stations = reuse(tuple(self.stations))
         self.have_tuples = True
     if len(self.locations) < 32:
         self.locations = reuse(tuple(self.locations))
         self.have_tuples = True
     if len(self.channels) < 32:
         self.channels = reuse(tuple(self.channels))
         self.have_tuples = True
     if len(self.nslc_ids) < 32:
         self.nslc_ids = reuse(tuple(self.nslc_ids))
         self.have_tuples = True
Example #4
0
def load(filename, getdata=True):

    mtime = os.stat(filename)[8]
    traces = []
    for tr in mseed_ext.get_traces(filename, getdata):
        network, station, location, channel = tr[1:5]
        tmin = float(tr[5]) / float(HPTMODULUS)
        tmax = float(tr[6]) / float(HPTMODULUS)
        try:
            deltat = reuse(float(1.0) / float(tr[7]))
        except ZeroDivisionError, e:
            raise MSeedError('Trace in file %s has a sampling rate of zero.' %
                             filename)
        ydata = tr[8]

        traces.append(
            trace.Trace(network,
                        station,
                        location,
                        channel,
                        tmin,
                        tmax,
                        deltat,
                        ydata,
                        mtime=mtime))
Example #5
0
 def _convert_small_sets_to_tuples(self):
     if len(self.networks) < 32:
         self.networks = reuse(tuple(self.networks))
         self.have_tuples = True
     if len(self.stations) < 32:
         self.stations = reuse(tuple(self.stations))
         self.have_tuples = True
     if len(self.locations) < 32:
         self.locations = reuse(tuple(self.locations))
         self.have_tuples = True
     if len(self.channels) < 32:
         self.channels = reuse(tuple(self.channels))
         self.have_tuples = True
     if len(self.nslc_ids) < 32:
         self.nslc_ids = reuse(tuple(self.nslc_ids))
         self.have_tuples = True
Example #6
0
def load(filename, getdata=True):

    mtime = os.stat(filename)[8]
    traces = []
    for tr in mseed_ext.get_traces(filename, getdata):
        network, station, location, channel = tr[1:5]
        tmin = float(tr[5]) / float(HPTMODULUS)
        tmax = float(tr[6]) / float(HPTMODULUS)
        try:
            deltat = reuse(float(1.0) / float(tr[7]))
        except ZeroDivisionError, e:
            raise MSeedError("Trace in file %s has a sampling rate of zero." % filename)
        ydata = tr[8]

        traces.append(trace.Trace(network, station, location, channel, tmin, tmax, deltat, ydata, mtime=mtime))