def fin(size,signal):
fil = sp.zeros(size,sp.float32)
for i in xrange(size):
ratio=sp.log10((i+1)/float(size)*10+1.0)
if ratio>1.0:
ratio=1.0
fil[i] = ratio
return fil*signal
python类log10()的实例源码
def fout(size,signal):
fil = sp.zeros(size,sp.float32)
for i in xrange(size):
ratio = sp.log10((size-i)/float(size)*10+1.0)
if ratio>1.0:
ratio = 1.0
fil[i] = ratio
return fil*signal
def create_labeled_data(aud_sample, nasal=0):
num_windows = (len(aud_sample) - WINDOW_SIZE)/WINDOW_STRIDE
features = np.zeros((num_windows, WINDOW_SIZE))
labels = np.zeros(num_windows)
idx = 0
for i in range(0, len(aud_sample), WINDOW_STRIDE):
window = aud_sample[i:i+WINDOW_SIZE]
for j in range(len(window), WINDOW_SIZE):
window = np.append(window,0)
if is_periodic(window) is False:
continue
# FFT to shift to frequency domain - use frequency spectrum as features
fft_values = abs(fft(window))
feat = 20*scipy.log10(fft_values)
features[idx:, ] = feat
labels[idx] = nasal
idx += 1
return features[0:idx, ], labels[0:idx]
def get_price_paid_coords():
postcodes = load_postcodes()
price_paid = load_price_paid()[['price', 'date', 'postcode']]
merged = pd.merge(price_paid, postcodes, left_on='postcode', right_index=True)
london = filter_to_london(merged).copy()
london['price'] = sp.log10(london['price'])
return london.drop('postcode', 1)
def get_base(unit ='bit'):
if unit == 'bit':
log = sp.log2
elif unit == 'nat':
log = sp.log
elif unit in ('digit', 'dit'):
log = sp.log10
else:
raise ValueError('The "unit" "%s" not understood' % unit)
return log
def svpice( t) :
'''
Returns saturation vapor pressure over ice, in hPa, given temperature in K.
The Goff-Gratch equation (Smithsonian Met. Tables, 5th ed., pp. 350, 1984)
'''
a = 273.16 / t
exponent = -9.09718 * (a - 1.) - 3.56654 * log10(a) + 0.876793 * (1. - 1./a) + log10(6.1071)
return 10.0**exponent
def plot_resid(d,savename='resfig1.png'):
"""
Plots the residual frequency after the first wipe using the TLE velocity.
"""
flim = [-2.e3, 2.e3]
t = d['tvec']
dates = [dt.datetime.fromtimestamp(ts) for ts in t]
datenums = md.date2num(dates)
xfmt = md.DateFormatter('%Y-%m-%d %H:%M:%S')
fig1 = plt.figure(figsize=(7, 9))
doppler_residual = sp.interpolate.interp1d(d['tvec'],d['dopfit'])
fvec = d["fvec"]
res0 = d["res0"]
res1 = d["res1"]
plt.subplot(211)
mesh = plt.pcolormesh(datenums, fvec, sp.transpose(10.*sp.log10(res0+1e-12)), vmin=-5, vmax=25)
plt.plot(datenums, (150.0/400.0)*doppler_residual(t), "r--", label="doppler resid")
ax = plt.gca()
ax.xaxis.set_major_formatter(xfmt)
plt.ylim(flim)
plt.subplots_adjust(bottom=0.2)
plt.xticks(rotation=25)
plt.xlabel("UTC")
plt.ylabel("Frequency (Hz)")
plt.title("Power ch0 (dB) %1.2f MHz"%(150.012))
plt.legend()
plt.colorbar(mesh, ax=ax)
# quicklook spectra of residuals spectra along with measured Doppler residual from second channel.
plt.subplot(212)
mesh = plt.pcolormesh(datenums, fvec, sp.transpose(10.*sp.log10(res1+1e-12)), vmin=-5, vmax=25)
plt.plot(datenums, doppler_residual(t), "r--", label="doppler resid")
ax = plt.gca()
ax.xaxis.set_major_formatter(xfmt)
plt.ylim(flim)
plt.xlabel("UTC")
plt.ylabel("Frequency (Hz)")
plt.title("Power ch1 (dB), %1.2f MHz"%(400.032))
plt.subplots_adjust(bottom=0.2)
plt.xticks(rotation=25)
plt.legend()
plt.colorbar(mesh, ax=ax)
plt.tight_layout()
print('Saving residual plots: '+savename)
plt.savefig(savename, dpi=300)
plt.close(fig1)