Created
April 17, 2014 13:12
-
-
Save jrleeman/10982324 to your computer and use it in GitHub Desktop.
Readers For Laboratory Acoustic Data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function[seismo,size] = ReadBinSeismo(fname) | |
fid = fopen(fname,'rb'); | |
size = fread(fid,2,'int'); | |
size(2) | |
seismo = fread(fid,size(2),'double') | |
fclose(fid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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