调用wave_function 函数, coef = [1j/np.sqrt(3), np.sqrt(2/3)] seqs = ['000', '100'] s = wave_func(coef, seqs) s 输出是波函数 |\Psi \rangle 在计算机内部的存储格式,其中 1j 是复数中虚数的基本单位 i。 matrix([[0. +0.57735027j], [0. +0.j ], [0. +0.j ], [0. +0...
wave_func(n=0) psi1 = dw_shro.wave_func(n=1) psi = 1 / np.sqrt(2) * (psi0 + psi1) with plt.style.context(['science', 'ieee']): plt.plot(dw_shro.x, psi0, 'r--', label=r'$|\Psi_{E_0} \rangle$') plt.plot(dw_shro.x, psi1, 'b:', label=r'$|\Psi_{E...
return w[idx_sorted], v[:, idx_sorted] def wave_func(self, n=0): return self.eigV[:, n] def eigen_value(self, n=0): return self.eigE[n] def check_eigen(self, n=7): '''check wheter H|psi> = E |psi> ''' with plt.style.context(['science', 'ieee']): HPsi = np....
Python 1 def func(self): 2 print 'hello ' 3 4 Foo = type('Foo',(object,), {'func': func}) 5 #type第一个参数:类名 6 #type第二个参数:当前类的基类 7 #type第三个参数:类的成员 1. 2. 3. 4. 5. 6. 7. 8. 由上面可以看出来 , Foo类是由type类实例而来,那么具体的创建的过程...
import wave import matplotlib.pyplot as plt import numpy as np import os filepath = "./data/" #添加路径 filename= os.listdir(filepath) #得到文件夹下的所有文件名称 f = wave.open(filepath+filename[1],'rb') params = f.getparams() nchannels, sampwidth, framerate, nframes = params[:4...
start和duration分别表示开始的时间和持续的时间,单位为秒.framerate是每秒帧率(采样数)。n代表采样的数量,而ts是采样时间的Numpy数组。为了计算ys,make_wave需要引入evaluate,它是由Sinusoid提供的: def evaluate(self,ts):phases=PI*self.freq*ts+self.offsetys=self.amp*self.func(phases)return ys ...
(1); this->pyFuncWave2MFCC = PyObject_GetAttrString(this->pyClassObj, "wave2MFCC"); this->pyArgsWave2MFCC = PyTuple_New(1); this->pyResWave2MFCC = PyTuple_New(1); } ResReadWave AudioPreprocess::readWave(char* wavePath) { //传入路径 PyTuple_SetItem(this->pyArgsReadWave,0,Py_...
# win=np.tile(winfunc(nw),(nf,1)) #window窗函数,这里默认取1 # return frames*win #返回帧信号矩阵 return frames def wavread(filename): f = wave.open(filename,'rb') params = f.getparams() nchannels, sampwidth, framerate, nframes = params[:4] strData = f.readframes(nframes)#读取...
#print(func(suffix)) # 根据每个文件分类,创建各自对应的文件夹。 ifnot os.path.exists(f"{path}\\{name}"): os.mkdir(f"{path}\\{name}") # 将文件复制到各自对应的文件夹中。 shutil.copy(file,f"{path}\\{name}") 结果如下: 展望 ...
anim = FuncAnimation(fig, animate, init_func=init, frames=200, interval=20, blit=True) anim.save('sine_wave.gif', writer='imagemagick') 在第(7-9)行中,我们只需在图中创建一个带有单个轴的图形窗口。然后创建一个空的行对象,它实际上是动画中要修改的对象。稍后将用数据对行对象进行填充。