Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions isrpy/readpack/JROfileread.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ def nextdatablock(self): # method to read headaer and data block by block
self.dh=dh
self.hts=h0+dh*arange(nsa)

if nTaus !=0:
tauH=fid.read(nTaus) # tau's header
self.tauH=tauH

if CodeType != 0: # dynamic header info about codes

codeH=fid.read(8)
numCodes,numBauds=unpack('<ii',codeH)
self.numCodes=numCodes
self.numBauds=numBauds

Codes=[]
for ic in range(numCodes):
tmpc=fromfile(fid,'u1',4*int(ceil(numBauds/32.)))
Codes+=[unpackbits(tmpc[::-1])[-1*numBauds:]]
self.Codes=Codes

fid.seek(hlength,0) # now go to data block

self.datablock=datablock # read data block after here
Expand All @@ -53,9 +70,8 @@ def nextdatablock(self): # method to read headaer and data block by block
allsamples=self.nSamples*self.nChannels*2
data2read=self.nCycles*allsamples
data=fid.read(data2read*2) # read and unpack data block
data=array(unpack('h'*data2read,data))

data=reshape(data,(self.nCycles,self.nSamples,self.nChannels,2))
data=ndarray(buffer=data,dtype='<h',order='C',shape=(self.nCycles,self.nSamples,self.nChannels,2))
data=data[:,:,:,0]+1j*data[:,:,:,1] # complex voltage array of [cycles,samples,channels] dimensions

return data