Browse Source

sac: fix handling of undefined values

master
Sebastian Heimann 1 month ago
parent
commit
b6baefb754
  1. 15
      src/io/sac.py

15
src/io/sac.py

@ -264,22 +264,15 @@ iqb1 iqb2 iqbx iqmt ieq ieq1 ieq2 ime iex inu inc io_ il ir it iu
hv = list(struct.unpack(format, filedata[:nbn]))
strings = str(filedata[nbn:nbh].decode('ascii'))
hv.append(strings[:8].rstrip())
hv.append(strings[8:24].rstrip())
hv.append(strings[:8].rstrip(' \x00'))
hv.append(strings[8:24].rstrip(' \x00'))
for i in range(len(strings[24:])//8):
hv.append(strings[24+i*8:24+(i+1)*8].rstrip())
hv.append(strings[24+i*8:24+(i+1)*8].rstrip(' \x00'))
self.header_vals = hv
for k, v in zip(SacFile.header_keys, self.header_vals):
vn = self.val_or_none(k, v)
if isinstance(vn, str):
ipos = vn.find('\x00')
if ipos != -1:
vn = vn[:ipos]
self.__dict__[k] = vn.rstrip()
else:
self.__dict__[k] = vn
self.__dict__[k] = vn
if self.leven == -12345:
self.leven = True

Loading…
Cancel
Save