Skip to content

Instantly share code, notes, and snippets.

@jrleeman
Created April 17, 2014 13:12
Show Gist options
  • Save jrleeman/10982324 to your computer and use it in GitHub Desktop.
Save jrleeman/10982324 to your computer and use it in GitHub Desktop.
Readers For Laboratory Acoustic Data
function[seismo,size] = ReadBinSeismo(fname)
fid = fopen(fname,'rb');
size = fread(fid,2,'int');
size(2)
seismo = fread(fid,size(2),'double')
fclose(fid)
import numpy as np
def ReadBinSeismo(fname):
"""
Takes filename and returns the seismogram data and
size of the seismogram. JRL 8/1/13
"""
f = open(fname,'rb')
seismo = np.fromfile(f,dtype='<i4',count=-1,sep='')
# For array, size information is encoded in 2 4-byte integers
size = seismo[0:2]
# After grabbing the size, take the remaining data and re-interpret as
# doubles
seismo = seismo[2:]
seismo.dtype = '<d'
return seismo.reshape(size[1]),size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment