Coverage for /opt/obspy/update-docs/src/obspy/obspy/earthworm/waveserver : 77%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*- Low-level Earthworm Wave Server tools.
:copyright: The ObsPy Development Team (devs@obspy.org) & Victor Kress :license: GNU General Public License (GPLv2) (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) """
'F': 'success', 'FR': 'requested data right (later) than tank contents', 'FL': 'requested data left (earlier) than tank contents', 'FG': 'requested data lie in tank gap', 'FB': 'syntax error in request', 'FC': 'data tank corrupt', 'FN': 'requested tank not found', 'FU': 'unknown error' }
't4': '>f4', 't8': '>f8', 's4': '>i4', 's2': '>i2', 'f4': '<f4', 'f8': '<f8', 'i4': '<i4', 'i2': '<i2' }
""" given a tracebuf2 type string from header, return appropriate numpy.dtype object """
""" """
""" Reads single tracebuf2 packet from beginning of input byte array tb. returns number of bytes read or 0 on read fail. """ return 0 # not enough array to hold header return 0 # not enough array to hold data specified in header
""" Parse tracebuf header into class variables """ endian = '>' else: raise ValueError self.chan, self.loc, self.version, tp, self.qual, _pad) = \ struct.unpack(endian + packStr, head) print 'Error parsing header: %s!=%s' % (dtype, tp)
""" Parse tracebuf char array data into self.data """ print 'data count in header (%d) != data count (%d)' % (self.nsamp, ndat) self.ndata = ndat
""" Return class contents as obspy.Trace object """ else: stat.location = location
""" Sets up socket to server and port, sends reqStr to socket and returns open socket """ else: s.send(reqStr + '\n')
""" Retrieves one newline terminated string from input open socket """ # see http://obspy.org/ticket/383 # indat = sock.recv(8192) except socket.timeout: print 'socket timeout in getSockCharLine()' return None else: return None
""" Listens for nbytes from open socket. Returns byte array as python string or None if timeout """ sock.settimeout(timeout) except socket.timeout: print 'socket timeout in getSockBytes()' return None else: return None
""" Return list of tanks on server """ # only works on regular waveservers (not winston) getstr = 'MENUSCNL: %s %s %s %s %s\n' % (rid, scnl[0], scnl[1], scnl[2], scnl[3]) else: # added SCNL not documented but required print 'request returned %s - %s' % (flag, RETURNFLAG_KEY[flag]) return [] elif tokens[6] in DATATYPE_KEY: elen = 7 # length of return entry if location omitted else: print 'no type token found in getMenu' return [] float(l[5]), float(l[6]), l[7])) else: outlist.append((int(l[0]), l[1], l[2], l[3], '--', float(l[4]), float(l[5]), l[6])) return []
""" Reads data for specified time interval and scnl on specified waveserverV.
Returns list of tracebuf2 objects """ return [] msg = 'readWaveServerV returned flag %s - %s' print msg % (flag, RETURNFLAG_KEY[flag]) return []
""" Returns obspy.Stream object from input list of tracebuf2 objects """ if not tbuflist: return None tlist = [] for tb in tbuflist: tlist.append(tb.getObspyTrace()) strm = Stream(tlist) return strm |