# http://pyrocko.org - GPLv3 # # The Pyrocko Developers, 21st Century # ---|P------/S----------~Lg----------
global g_guralp_zero
'Header', ''' block_type system_id stream_id instrument_type time gain ttl sample_rate compression nrecords '''.split())
raise EOF()
raise GCFLoadError('Unexpected end of file')
system_id = util.base36encode(isystem_id & (2**21 - 1)) else:
else:
system_id = util.base36encode(isystem_id) instrument_type = None gain = None
raise FileLoadError('Header indicates too many records in block.')
if compression == 4 and stream_id[-2:] == '00': block_type = 'status_block'
elif compression == 4 and stream_id[-2:] == '01': block_type = 'unified_status_block'
elif compression == 4 and stream_id[-2:] == 'SM': block_type = 'strong_motion_block'
elif stream_id[-2:] == 'CD': block_type = 'cd_status_block'
elif compression == 4 and stream_id[-2:] == 'BP': block_type = 'byte_pipe_block'
elif stream_id[-2:] == 'IB': block_type = 'information_block'
else: raise FileLoadError('Unexpected block type found.')
return Header(block_type, system_id, stream_id, instrument_type, time, gain, ittl, 0.0, compression, nrecords) else:
raise FileLoadError('Unexpected data stream ID')
157: (0.1, None), 161: (0.125, None), 162: (0.2, None), 164: (0.25, None), 167: (0.5, None), 171: (400., 8), 174: (500., 2), 176: (1000., 4), 179: (2000., 8), 181: (4000., 16)}
sample_rate, tfod = sample_rate_tab[israte] else:
toff = (compression >> 4) // tfod compression = compression & 0b1111 time += toff
raise GCFLoadError( 'Unsupported compression code: %i' % compression)
time, gain, ittl, sample_rate, compression, nrecords)
raise GCFLoadError('Unsupported compression code: %i' % h.compression)
count=nsamples) raise GCFLoadError('Checksum error occured')
data = read(f, 1024 - 16) return data[:h.nrecords*4]
else: f.seek(1024 - 16, 1) samples = None tmax = h.time + ( h.nrecords * h.compression - 1) * deltat
else: tr.tmax = tmax
else: del traces[nslc] yield tr
*nslc, tmin=h.time, deltat=deltat, ydata=samples, tmax=tmax)
else: f.seek(1024 - 16, 1)
# does not work properly, produces too many false positives # difficult to improve due to the very compact GCF header try: if len(first512) < 512: return False
f = StringIO(first512) read_header(f) return True
except Exception: return False
if __name__ == '__main__': util.setup_logging('warn')
all_traces = [] for fn in sys.argv[1:]: if detect(open(fn, 'rb').read(512)): print(fn) all_traces.extend(iload(fn))
trace.snuffle(all_traces) |