Tuple, List
'undefined', 'waveform', 'station', 'channel', 'response', 'event', 'waveform_promise']
UNDEFINED, WAVEFORM, STATION, CHANNEL, RESPONSE, EVENT, WAVEFORM_PROMISE) = range(len(g_content_kinds))
return [g_content_kinds[kind_id] for kind_id in kind_ids]
else:
else:
else:
else:
else:
else:
else:
else:
if x is None: return '...'.ljust(17) else: return util.time_to_str(x)
return None, 0.0
return None
return util.hpfloat(seconds) + util.hpfloat(offset) else:
# 0 <= x < tscale_edges[1]: 0 # tscale_edges[1] <= x < tscale_edges[2]: 1 # ... # tscale_edges[len(tscale_edges)-1] <= x: len(tscale_edges)
''' Base class for content types in the Squirrel framework. '''
def str_codes(self): return '.'.join(self.codes)
def str_time_span(self): tmin, tmax = self.time_span if tmin == tmax: return '%s' % time_or_none_to_str(tmin) else: return '%s - %s' % ( time_or_none_to_str(tmin), time_or_none_to_str(tmax))
def summary(self): return '%s %-16s %s' % ( self.__class__.__name__, self.str_codes, self.str_time_span)
return self.__key__() < other.__key__()
return self.codes, self.time_span_g_clipped
def time_span_g_clipped(self): tmin, tmax = self.time_span return ( tmin if tmin is not None else g_tmin, tmax if tmax is not None else g_tmax)
''' A continuous seismic waveform snippet. '''
optional=True, shape=(None,), serialize_as='base64+meta', help='numpy array with data samples')
network=self.network, station=self.station, location=self.location, channel=self.channel, tmin=self.tmin, tmax=self.tmax, deltat=self.deltat, ydata=self.data)
def codes(self): return ( self.agency, self.network, self.station, self.location, self.channel, self.extra)
def time_span(self): return (self.tmin, self.tmax)
''' Information about a waveform potentially available at a remote site. '''
def codes(self): return ( self.agency, self.network, self.station, self.location, self.channel, self.extra)
def time_span(self): return (self.tmin, self.tmax)
def client(self): return self.source_id.split(':')[1]
return '%s:%s %s [%s - %s]' % ( self.client, site, '.'.join(self.codes), util.time_to_str(self.tmin), util.time_to_str(self.tmax))
if tr.ydata.size == 0: raise InvalidWaveform( 'waveform with zero data samples')
if tr.deltat != self.deltat: raise InvalidWaveform( 'incorrect sampling interval - waveform: %g s, ' 'meta-data: %g s' % ( tr.deltat, self.deltat))
if not num.all(num.isfinite(tr.ydata)): raise InvalidWaveform('waveform has NaN values')
codes = sorted(set(order.codes[1:-1] for order in orders)) if len(codes) >= 2: return '%i orders, %s - %s' % ( len(orders), '.'.join(codes[0]), '.'.join(codes[-1]))
else: return '%i orders, %s' % ( len(orders), '.'.join(codes[0]))
''' A seismic station. '''
def codes(self): return ( self.agency, self.network, self.station, self.location if self.location is not None else '*')
def time_span(self): return (self.tmin, self.tmax)
from pyrocko import model return model.Station( network=self.network, station=self.station, location=self.location if self.location is not None else '*', lat=self.lat, lon=self.lon, elevation=self.elevation, depth=self.depth)
return ( '*', self.network, self.station, self.location if self.location is not None else '*', self.lat, self.lon, self.elevation, self.depth)
''' A channel of a seismic station. '''
def codes(self): return ( self.agency, self.network, self.station, self.location, self.channel)
def time_span(self): return (self.tmin, self.tmax)
from pyrocko import model return model.Channel( name=self.channel, azimuth=self.azimuth, dip=self.dip)
return ( self.channel, self.network, self.station, self.location, self.lat, self.lon, self.elevation, self.depth)
return ( '*', self.channel, self.azimuth, self.dip)
''' The instrument response of a seismic station channel. '''
''' A seismic event. '''
from pyrocko import model model.Event( name=self.name, time=self.time, lat=self.lat, lon=self.lon, depth=self.depth, magnitude=self.magnitude, duration=self.duration)
def time_span(self): return (self.time, self.time)
''' Index entry referencing an elementary piece of content.
So-called *nuts* are used in Pyrocko's Squirrel framework to hold common meta-information about individual pieces of waveforms, stations, channels, etc. together with the information where it was found or generated. '''
self, file_path=None, file_format=None, file_mtime=None, file_size=None, file_segment=None, file_element=None, kind_id=0, codes='', tmin_seconds=None, tmin_offset=0.0, tmax_seconds=None, tmax_offset=0.0, deltat=None, content=None, tmin=None, tmax=None, values_nocheck=None):
self.file_size, self.file_segment, self.file_element, self.kind_id, self.codes, self.tmin_seconds, self.tmin_offset, self.tmax_seconds, self.tmax_offset, self.deltat) = values_nocheck
else:
self.equality_values == other.equality_values)
return ehash(','.join(str(x) for x in self.key))
return not (self == other)
!= (self.file_mtime, self.file_size)
def dkey(self):
def key(self): self.file_path, self.file_segment, self.file_element, self.file_mtime)
def equality_values(self): self.file_segment, self.file_element, self.kind_id, self.codes, self.tmin_seconds, self.tmin_offset, self.tmax_seconds, self.tmax_offset, self.deltat)
def tmin(self):
def tmax(self):
def kscale(self): return 0
def waveform_kwargs(self): self.codes.split(separator)
agency=agency, network=network, station=station, location=location, channel=channel, extra=extra, tmin=self.tmin, tmax=self.tmax, deltat=self.deltat)
def waveform_promise_kwargs(self): self.codes.split(separator)
agency=agency, network=network, station=station, location=location, channel=channel, tmin=self.tmin, tmax=self.tmax, deltat=self.deltat)
def station_kwargs(self): agency=agency, network=network, station=station, location=location if location != '*' else None, tmin=tmin_or_none(self.tmin), tmax=tmax_or_none(self.tmax))
def channel_kwargs(self): = self.codes.split(separator)
agency=agency, network=network, station=station, location=location, channel=channel, tmin=tmin_or_none(self.tmin), tmax=tmax_or_none(self.tmax), deltat=self.deltat)
def event_kwargs(self): name=self.codes, time=self.tmin, duration=(self.tmax - self.tmin) or None)
def trace_kwargs(self): self.codes.split(separator)
network=network, station=station, location=location, channel=channel, tmin=self.tmin, tmax=self.tmax, deltat=self.deltat)
def dummy_trace(self): return DummyTrace(self)
def codes_tuple(self): return tuple(self.codes.split(separator))
return '%s, %s, %s - %s' % ( to_kind(self.kind_id), '.'.join(self.codes.split(separator)), util.time_to_str(self.tmin), util.time_to_str(self.tmax))
agency='', network='', station='', location='', channel='', extra='', **kwargs):
(agency, network, station, location, channel, extra))
kind_id=WAVEFORM, codes=codes, **kwargs)
agency='', network='', station='', location='', channel='', extra='', **kwargs):
(agency, network, station, location, channel, extra))
kind_id=WAVEFORM_PROMISE, codes=codes, **kwargs)
agency='', network='', station='', location='', **kwargs):
kind_id=STATION, codes=codes, **kwargs)
agency='', network='', station='', location='', channel='', **kwargs):
kind_id=CHANNEL, codes=codes, **kwargs)
kind_id=EVENT, codes=codes, **kwargs)
by_ansl = {} for nut in nuts: if nut.kind_id != CHANNEL: continue
ansl = nut.codes[:4]
if ansl not in by_ansl: by_ansl[ansl] = {}
group = by_ansl[ansl]
k = nut.codes[4][:-1], nut.deltat, nut.tmin, nut.tmax
if k not in group: group[k] = set()
group.add(nut.codes[4])
return by_ansl
self.nut = nut self._nslc = None
def tmin(self): return self.nut.tmin
def tmax(self): return self.nut.tmax
def deltat(self): return self.nut.deltat
def nslc_id(self): if self._nslc is None: self._nslc = self.nut.codes_tuple[1:5]
return self._nslc
def network(self): return self.nslc_id[0]
def station(self): return self.nslc_id[1]
def location(self): return self.nslc_id[2]
def channel(self): return self.nslc_id[3]
return not (tmax < self.nut.tmin or self.nut.tmax < tmin)
'to_kind', 'to_kinds', 'to_kind_id', 'to_kind_ids', 'Content', 'Waveform', 'WaveformPromise', 'Station', 'Channel', 'Nut', ] |