def convert(size, srcunit, trgunit): value = size if srcunit != trgunit: sizeinbytes = size * Factor[srcunit] trgfact = Factor[trgunit] value = round(float(sizeinbytes) / trgfact, int(log10(trgfact))) return value
def getHumanUnit(size, unit="B"): size = convert(size, unit, "B") hu = "B" for u in Factor.keys(): if size > 10**(int(log10(Factor[u]))): if Factor[u] > Factor[hu]: hu = u return hu
"""Load Nicolet BMSI data.""" if tmin < 0: tmin = 0 fh = file(filename, 'rb') indmin = Fs * tmin numsamples = os.path.getsize(filename) / (channels * 2) indmax = min(numsamples, Fs * tmax) byte0 = int(indmin * channels * 2) numbytes = int((indmax - indmin) * channels * 2) fh.seek(byte0) data = fromstring(fh.read(numbytes), Int16).astype(Float) data.shape = -1, channels t = (1 / Fs) * arange(indmin, indmax) return t, data t, data = read_nicolet(0, 10) x = data[:, 5] Pxx, freqs, t = specgram(x, NFFT=512, Fs=Fs, noverlap=412) T, F = meshgrid(t, freqs) pcolor(T, F, 10 * log10(Pxx), shading='flat') set(gca(), 'ylim', [0, 100]) #print Pxx.shape, freqs.shape, t.shape show()
indmax = min(numsamples, Fs*tmax) byte0 = int(indmin*channels*2) numbytes = int( (indmax-indmin)*channels*2 ) fh.seek(byte0) data = fromstring(fh.read(numbytes), Int16).astype(Float) data.shape = -1, channels t = (1/Fs)*arange(indmin, indmax) return t, data t, data = read_nicolet(0,10) x = data[:,5] Pxx, freqs, t = specgram(x, NFFT=512, Fs=Fs, noverlap=412) T, F = meshgrid(t,freqs) pcolor(T, F, 10*log10(Pxx), shading='flat') set(gca(), 'ylim', [0,100]) #print Pxx.shape, freqs.shape, t.shape show()
def log10Image(self): if self.fname == '': return from Numeric import log10 data = self.data da = log10(data) self.createImage(da)