pyrocko.io.sac

SAC IO library for Python

fixdoublefloat(x)[source]
exception SacError[source]
nonetoempty(s)[source]
class SacFile(*args, **kwargs)[source]
nbytes_header = 632
header_num_format = {'big': '>70f40i', 'little': '<70f40i'}
header_keys = ['delta', 'depmin', 'depmax', 'scale', 'odelta', 'b', 'e', 'o', 'a', 'internal0', 't0', 't1', 't2', 't3', 't4', 't5', 't6', 't7', 't8', 't9', 'f', 'resp0', 'resp1', 'resp2', 'resp3', 'resp4', 'resp5', 'resp6', 'resp7', 'resp8', 'resp9', 'stla', 'stlo', 'stel', 'stdp', 'evla', 'evlo', 'evel', 'evdp', 'mag', 'user0', 'user1', 'user2', 'user3', 'user4', 'user5', 'user6', 'user7', 'user8', 'user9', 'dist', 'az', 'baz', 'gcarc', 'internal1', 'internal2', 'depmen', 'cmpaz', 'cmpinc', 'xminimum', 'xmaximum', 'yminimum', 'ymaximum', 'unused0', 'unused1', 'unused2', 'unused3', 'unused4', 'unused5', 'unused6', 'nzyear', 'nzjday', 'nzhour', 'nzmin', 'nzsec', 'nzmsec', 'nvhdr', 'norid', 'nevid', 'npts', 'internal3', 'nwfid', 'nxsize', 'nysize', 'unused7', 'iftype', 'idep', 'iztype', 'unused8', 'iinst', 'istreg', 'ievreg', 'ievtyp', 'iqual', 'isynth', 'imagtyp', 'imagsrc', 'unused9', 'unused10', 'unused11', 'unused12', 'unused13', 'unused14', 'unused15', 'unused16', 'leven', 'lpspol', 'lovrok', 'lcalda', 'unused17', 'kstnm', 'kevnm', 'khole', 'ko', 'ka', 'kt0', 'kt1', 'kt2', 'kt3', 'kt4', 'kt5', 'kt6', 'kt7', 'kt8', 'kt9', 'kf', 'kuser0', 'kuser1', 'kuser2', 'kcmpnm', 'knetwk', 'kdatrd', 'kinst']
header_enum_symbols = ['itime', 'irlim', 'iamph', 'ixy', 'iunkn', 'idisp', 'ivel', 'iacc', 'ib', 'iday', 'io', 'ia', 'it0', 'it1', 'it2', 'it3', 'it4', 'it5', 'it6', 'it7', 'it8', 'it9', 'iradnv', 'itannv', 'iradev', 'itanev', 'inorth', 'ieast', 'ihorza', 'idown', 'iup', 'illlbb', 'iwwsn1', 'iwwsn2', 'ihglp', 'isro', 'inucl', 'ipren', 'ipostn', 'iquake', 'ipreq', 'ipostq', 'ichem', 'iother', 'igood', 'iglch', 'idrop', 'ilowsn', 'irldta', 'ivolts', 'ixyz', 'imb', 'ims', 'iml', 'imw', 'imd', 'imx', 'ineic', 'ipde', 'iisc', 'ireb', 'iusgs', 'ibrk', 'icaltech', 'illnl', 'ievloc', 'ijsop', 'iuser', 'iunknown', 'iqb', 'iqb1', 'iqb2', 'iqbx', 'iqmt', 'ieq', 'ieq1', 'ieq2', 'ime', 'iex', 'inu', 'inc', 'io_', 'il', 'ir', 'it', 'iu']
enum_header_vars = ['iftype', 'idep', 'iztype', 'imagtype', 'imagsrc', 'ievtyp', 'iqual', 'isynth']
header_num2name = {1: 'itime', 2: 'irlim', 3: 'iamph', 4: 'ixy', 5: 'iunkn', 6: 'idisp', 7: 'ivel', 8: 'iacc', 9: 'ib', 10: 'iday', 11: 'io', 12: 'ia', 13: 'it0', 14: 'it1', 15: 'it2', 16: 'it3', 17: 'it4', 18: 'it5', 19: 'it6', 20: 'it7', 21: 'it8', 22: 'it9', 23: 'iradnv', 24: 'itannv', 25: 'iradev', 26: 'itanev', 27: 'inorth', 28: 'ieast', 29: 'ihorza', 30: 'idown', 31: 'iup', 32: 'illlbb', 33: 'iwwsn1', 34: 'iwwsn2', 35: 'ihglp', 36: 'isro', 37: 'inucl', 38: 'ipren', 39: 'ipostn', 40: 'iquake', 41: 'ipreq', 42: 'ipostq', 43: 'ichem', 44: 'iother', 45: 'igood', 46: 'iglch', 47: 'idrop', 48: 'ilowsn', 49: 'irldta', 50: 'ivolts', 51: 'ixyz', 52: 'imb', 53: 'ims', 54: 'iml', 55: 'imw', 56: 'imd', 57: 'imx', 58: 'ineic', 59: 'ipde', 60: 'iisc', 61: 'ireb', 62: 'iusgs', 63: 'ibrk', 64: 'icaltech', 65: 'illnl', 66: 'ievloc', 67: 'ijsop', 68: 'iuser', 69: 'iunknown', 70: 'iqb', 71: 'iqb1', 72: 'iqb2', 73: 'iqbx', 74: 'iqmt', 75: 'ieq', 76: 'ieq1', 77: 'ieq2', 78: 'ime', 79: 'iex', 80: 'inu', 81: 'inc', 82: 'io_', 83: 'il', 84: 'ir', 85: 'it', 86: 'iu'}
header_name2num = {'ia': 12, 'iacc': 8, 'iamph': 3, 'ib': 9, 'ibrk': 63, 'icaltech': 64, 'ichem': 43, 'iday': 10, 'idisp': 6, 'idown': 30, 'idrop': 47, 'ieast': 28, 'ieq': 75, 'ieq1': 76, 'ieq2': 77, 'ievloc': 66, 'iex': 79, 'iglch': 46, 'igood': 45, 'ihglp': 35, 'ihorza': 29, 'iisc': 60, 'ijsop': 67, 'il': 83, 'illlbb': 32, 'illnl': 65, 'ilowsn': 48, 'imb': 52, 'imd': 56, 'ime': 78, 'iml': 54, 'ims': 53, 'imw': 55, 'imx': 57, 'inc': 81, 'ineic': 58, 'inorth': 27, 'inu': 80, 'inucl': 37, 'io': 11, 'io_': 82, 'iother': 44, 'ipde': 59, 'ipostn': 39, 'ipostq': 42, 'ipren': 38, 'ipreq': 41, 'iqb': 70, 'iqb1': 71, 'iqb2': 72, 'iqbx': 73, 'iqmt': 74, 'iquake': 40, 'ir': 84, 'iradev': 25, 'iradnv': 23, 'ireb': 61, 'irldta': 49, 'irlim': 2, 'isro': 36, 'it': 85, 'it0': 13, 'it1': 14, 'it2': 15, 'it3': 16, 'it4': 17, 'it5': 18, 'it6': 19, 'it7': 20, 'it8': 21, 'it9': 22, 'itanev': 26, 'itannv': 24, 'itime': 1, 'iu': 86, 'iunkn': 5, 'iunknown': 69, 'iup': 31, 'iuser': 68, 'iusgs': 62, 'ivel': 7, 'ivolts': 50, 'iwwsn1': 33, 'iwwsn2': 34, 'ixy': 4, 'ixyz': 51}
header_types = 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiilllllkkkkkkkkkkkkkkkkkkkkkkk'
undefined_value = {'f': -12345.0, 'i': -12345, 'k': '-12345', 'l': None}
ldefaults = {'lcalda': 1, 'leven': 1, 'lovrok': 1, 'lpspol': 0, 'unused17': 0}
t_lookup = {'a': 'f', 'az': 'f', 'b': 'f', 'baz': 'f', 'cmpaz': 'f', 'cmpinc': 'f', 'delta': 'f', 'depmax': 'f', 'depmen': 'f', 'depmin': 'f', 'dist': 'f', 'e': 'f', 'evdp': 'f', 'evel': 'f', 'evla': 'f', 'evlo': 'f', 'f': 'f', 'gcarc': 'f', 'idep': 'i', 'ievreg': 'i', 'ievtyp': 'i', 'iftype': 'i', 'iinst': 'i', 'imagsrc': 'i', 'imagtyp': 'i', 'internal0': 'f', 'internal1': 'f', 'internal2': 'f', 'internal3': 'i', 'iqual': 'i', 'istreg': 'i', 'isynth': 'i', 'iztype': 'i', 'ka': 'k', 'kcmpnm': 'k', 'kdatrd': 'k', 'kevnm': 'k', 'kf': 'k', 'khole': 'k', 'kinst': 'k', 'knetwk': 'k', 'ko': 'k', 'kstnm': 'k', 'kt0': 'k', 'kt1': 'k', 'kt2': 'k', 'kt3': 'k', 'kt4': 'k', 'kt5': 'k', 'kt6': 'k', 'kt7': 'k', 'kt8': 'k', 'kt9': 'k', 'kuser0': 'k', 'kuser1': 'k', 'kuser2': 'k', 'lcalda': 'l', 'leven': 'l', 'lovrok': 'l', 'lpspol': 'l', 'mag': 'f', 'nevid': 'i', 'norid': 'i', 'npts': 'i', 'nvhdr': 'i', 'nwfid': 'i', 'nxsize': 'i', 'nysize': 'i', 'nzhour': 'i', 'nzjday': 'i', 'nzmin': 'i', 'nzmsec': 'i', 'nzsec': 'i', 'nzyear': 'i', 'o': 'f', 'odelta': 'f', 'resp0': 'f', 'resp1': 'f', 'resp2': 'f', 'resp3': 'f', 'resp4': 'f', 'resp5': 'f', 'resp6': 'f', 'resp7': 'f', 'resp8': 'f', 'resp9': 'f', 'scale': 'f', 'stdp': 'f', 'stel': 'f', 'stla': 'f', 'stlo': 'f', 't0': 'f', 't1': 'f', 't2': 'f', 't3': 'f', 't4': 'f', 't5': 'f', 't6': 'f', 't7': 'f', 't8': 'f', 't9': 'f', 'unused0': 'f', 'unused1': 'f', 'unused10': 'i', 'unused11': 'i', 'unused12': 'i', 'unused13': 'i', 'unused14': 'i', 'unused15': 'i', 'unused16': 'i', 'unused17': 'l', 'unused2': 'f', 'unused3': 'f', 'unused4': 'f', 'unused5': 'f', 'unused6': 'f', 'unused7': 'i', 'unused8': 'i', 'unused9': 'i', 'user0': 'f', 'user1': 'f', 'user2': 'f', 'user3': 'f', 'user4': 'f', 'user5': 'f', 'user6': 'f', 'user7': 'f', 'user8': 'f', 'user9': 'f', 'xmaximum': 'f', 'xminimum': 'f', 'ymaximum': 'f', 'yminimum': 'f'}
u_lookup = {'a': -12345.0, 'az': -12345.0, 'b': -12345.0, 'baz': -12345.0, 'cmpaz': -12345.0, 'cmpinc': -12345.0, 'delta': -12345.0, 'depmax': -12345.0, 'depmen': -12345.0, 'depmin': -12345.0, 'dist': -12345.0, 'e': -12345.0, 'evdp': -12345.0, 'evel': -12345.0, 'evla': -12345.0, 'evlo': -12345.0, 'f': -12345.0, 'gcarc': -12345.0, 'idep': -12345, 'ievreg': -12345, 'ievtyp': -12345, 'iftype': -12345, 'iinst': -12345, 'imagsrc': -12345, 'imagtyp': -12345, 'internal0': -12345.0, 'internal1': -12345.0, 'internal2': -12345.0, 'internal3': -12345, 'iqual': -12345, 'istreg': -12345, 'isynth': -12345, 'iztype': -12345, 'ka': '-12345', 'kcmpnm': '-12345', 'kdatrd': '-12345', 'kevnm': '-12345', 'kf': '-12345', 'khole': '-12345', 'kinst': '-12345', 'knetwk': '-12345', 'ko': '-12345', 'kstnm': '-12345', 'kt0': '-12345', 'kt1': '-12345', 'kt2': '-12345', 'kt3': '-12345', 'kt4': '-12345', 'kt5': '-12345', 'kt6': '-12345', 'kt7': '-12345', 'kt8': '-12345', 'kt9': '-12345', 'kuser0': '-12345', 'kuser1': '-12345', 'kuser2': '-12345', 'lcalda': None, 'leven': None, 'lovrok': None, 'lpspol': None, 'mag': -12345.0, 'nevid': -12345, 'norid': -12345, 'npts': -12345, 'nvhdr': -12345, 'nwfid': -12345, 'nxsize': -12345, 'nysize': -12345, 'nzhour': -12345, 'nzjday': -12345, 'nzmin': -12345, 'nzmsec': -12345, 'nzsec': -12345, 'nzyear': -12345, 'o': -12345.0, 'odelta': -12345.0, 'resp0': -12345.0, 'resp1': -12345.0, 'resp2': -12345.0, 'resp3': -12345.0, 'resp4': -12345.0, 'resp5': -12345.0, 'resp6': -12345.0, 'resp7': -12345.0, 'resp8': -12345.0, 'resp9': -12345.0, 'scale': -12345.0, 'stdp': -12345.0, 'stel': -12345.0, 'stla': -12345.0, 'stlo': -12345.0, 't0': -12345.0, 't1': -12345.0, 't2': -12345.0, 't3': -12345.0, 't4': -12345.0, 't5': -12345.0, 't6': -12345.0, 't7': -12345.0, 't8': -12345.0, 't9': -12345.0, 'unused0': -12345.0, 'unused1': -12345.0, 'unused10': -12345, 'unused11': -12345, 'unused12': -12345, 'unused13': -12345, 'unused14': -12345, 'unused15': -12345, 'unused16': -12345, 'unused17': None, 'unused2': -12345.0, 'unused3': -12345.0, 'unused4': -12345.0, 'unused5': -12345.0, 'unused6': -12345.0, 'unused7': -12345, 'unused8': -12345, 'unused9': -12345, 'user0': -12345.0, 'user1': -12345.0, 'user2': -12345.0, 'user3': -12345.0, 'user4': -12345.0, 'user5': -12345.0, 'user6': -12345.0, 'user7': -12345.0, 'user8': -12345.0, 'user9': -12345.0, 'xmaximum': -12345.0, 'xminimum': -12345.0, 'ymaximum': -12345.0, 'yminimum': -12345.0}
ndatablocks()[source]

Get number of data blocks for this file’s type.

val_or_none(k, v)[source]

Replace SAC undef flags with None.

get_ref_time()[source]

Get reference time as standard Unix timestamp.

set_ref_time(timestamp)[source]

Set all header values defining reference time based on standard Unix timestamp.

val_for_file(k, v)[source]

Convert attribute value to the form required when writing it to the SAC file.

clear()[source]

Empty file record.

check()[source]

Check the required header variables to have reasonable values.

read(filename, load_data=True, byte_sex='try')[source]

Read SAC file.

filename – Name of SAC file. load_data – If True, the data is read, otherwise only read headers. byte_sex – Endianness: ‘try’, ‘little’ or ‘big’

write(filename, byte_sex='little')[source]

Write SAC file.

to_trace()[source]
k = 'kinst'
iload(filename, load_data=True)[source]
detect(first512)[source]