示例#1
0
 def Waveform(self, td=None):
     """Computes the time-domain waveform using IDFT methods
     @param td (optional) instance of class TimeDescriptor declaring the time descriptor of the waveform to produce.
     @return wf instance of class Waveform corresponding to the frequency content.
     @note
     If td is None then the time descriptor corresponding to the frequency descriptor is used.\n
     The waveform produced is essentially the inverse process of class initialization.\n
     @see WaveformFromDefinition()
     """
     Keven = (self.td.K // 2) * 2 == self.td.K
     X = self.Values()
     X=[X[n]*self.td.K*\
         (1. if (n==0 or ((n==self.m_f.N) and Keven)) else 0.5)*\
         cmath.exp(1j*2.*math.pi*self.m_f[n]*self.td.H)
         for n in range(self.m_f.N+1)]
     if Keven:
         X2 = [X[self.m_f.N - n].conjugate() for n in range(1, self.m_f.N)]
     else:
         X2 = [
             X[self.m_f.N - n + 1].conjugate()
             for n in range(1, self.m_f.N + 1)
         ]
     X.extend(X2)
     x = [xk.real for xk in fft.ifft(X).tolist()]
     wf = Waveform(self.td, x)
     if not td is None:
         wf = wf.Adapt(td)
     return wf
示例#2
0
 def WaveformFromDefinition(self, td=None):
     """Computes the time-domain waveform using sums of cosines
     @param td instance of class TimeDescriptor declaring the time descriptor of the waveform to produce.
     @return wf instance of class Waveform corresponding to the frequency content.
     @note
     If td is None then the time descriptor corresponding to the frequency descriptor is used.\n
     The waveform produced is essentially the inverse process of __init__().\n
     This function should produce the exact same result as the Waveform() method, and is slow, but clearly
     written out to see how the waveform is produced by summing sinusoids.  It used to essentially document
     the class.\n
     @see Waveform().
     """
     absX = self.Values('mag')
     theta = self.Values('deg')
     wf = Waveform(self.td)
     for n in range(self.m_f.N + 1):
         wf = wf + SineWaveform(self.td,
                                Frequency=self.m_f[n],
                                Amplitude=absX[n],
                                Phase=theta[n] + 90)
     if not td is None:
         wf = wf.Adapt(td)
     return wf