def to_trace(self): assert self.iftype == SacFile.header_name2num['itime'] assert self.leven == True tmin = self.get_ref_time() + self.b 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)
def iload(filename, load_data=True): from pyrocko import mseed_ext have_zero_rate_traces = False try: traces = [] for tr in mseed_ext.get_traces(filename, load_data): network, station, location, channel = tr[1:5] tmin = float(tr[5]) / float(mseed_ext.HPTMODULUS) tmax = float(tr[6]) / float(mseed_ext.HPTMODULUS) try: deltat = reuse(1.0 / float(tr[7])) except ZeroDivisionError as e: have_zero_rate_traces = True continue ydata = tr[8] traces.append( trace.Trace(network, station, location, channel, tmin, tmax, deltat, ydata)) for tr in traces: yield tr except (OSError, mseed_ext.MSeedError) as e: raise FileLoadError(str(e) + ' (file: %s)' % filename) if have_zero_rate_traces: logger.warning('Ignoring traces with sampling rate of zero in file %s ' '(maybe LOG traces)' % filename)
def iload(filename, load_data=True): from pyrocko import mseed_ext have_zero_rate_traces = False try: traces = [] for tr in mseed_ext.get_traces(filename, load_data): network, station, location, channel = tr[1:5] tmin = float(tr[5])/float(mseed_ext.HPTMODULUS) tmax = float(tr[6])/float(mseed_ext.HPTMODULUS) try: deltat = reuse(1.0/float(tr[7])) except ZeroDivisionError as e: have_zero_rate_traces = True continue ydata = tr[8] traces.append(trace.Trace( network, station, location, channel, tmin, tmax, deltat, ydata)) for tr in traces: yield tr except (OSError, mseed_ext.MSeedError) as e: raise FileLoadError(str(e)+' (file: %s)' % filename) if have_zero_rate_traces: logger.warning( 'Ignoring traces with sampling rate of zero in file %s ' '(maybe LOG traces)' % filename)
def iload(filename, load_data=True): from pyrocko import mseed_ext try: traces = [] for tr in mseed_ext.get_traces( filename, load_data ): network, station, location, channel = tr[1:5] tmin = float(tr[5])/float(mseed_ext.HPTMODULUS) tmax = float(tr[6])/float(mseed_ext.HPTMODULUS) try: deltat = reuse(float(1.0)/float(tr[7])) except ZeroDivisionError, e: raise FileLoadError('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)) for tr in traces: yield tr
def iload(filename, load_data=True): from pyrocko import mseed_ext have_zero_rate_traces = False try: traces = [] for tr in mseed_ext.get_traces( filename, load_data ): network, station, location, channel = tr[1:5] tmin = float(tr[5])/float(mseed_ext.HPTMODULUS) tmax = float(tr[6])/float(mseed_ext.HPTMODULUS) try: deltat = reuse(float(1.0)/float(tr[7])) except ZeroDivisionError, e: have_zero_rate_traces = True continue ydata = tr[8] traces.append(trace.Trace(network, station, location, channel, tmin, tmax, deltat, ydata)) for tr in traces: yield tr
def iload(filename, load_data=True): from pyrocko import mseed_ext have_zero_rate_traces = False try: traces = [] for tr in mseed_ext.get_traces(filename, load_data): network, station, location, channel = tr[1:5] tmin = float(tr[5]) / float(mseed_ext.HPTMODULUS) tmax = float(tr[6]) / float(mseed_ext.HPTMODULUS) try: deltat = reuse(float(1.0) / float(tr[7])) except ZeroDivisionError, e: have_zero_rate_traces = True continue ydata = tr[8] traces.append( trace.Trace(network, station, location, channel, tmin, tmax, deltat, ydata)) for tr in traces: yield tr