当前位置: 首页>>代码示例>>Python>>正文


Python Stream.write方法代码示例

本文整理汇总了Python中stream.Stream.write方法的典型用法代码示例。如果您正苦于以下问题:Python Stream.write方法的具体用法?Python Stream.write怎么用?Python Stream.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stream.Stream的用法示例。


在下文中一共展示了Stream.write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: StreamTestCase

# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream import write [as 别名]
class StreamTestCase(AsyncHTTPTestCase):
    def get_app(self):
        return Application([('/',HelloHandler)])

    def test_read(self):
        s = socket.socket(socket.AF_INET,socket.SOCK_STREAM,0)
        s.connect(("localhost",self.get_http_port()))
        self.stream = Stream(s,io_loop=self.io_loop)
        self.stream.write(b"GET / HTTP/1.0\r\n\r\n")
        self.stream.on("data",self.on_data1)
        self.wait()

    def on_data1(self,data):
        self.assertEquals(data.split("\r\n\r\n")[-1],"Hello")
        self.stop()
开发者ID:joshrtay,项目名称:tornado_redis,代码行数:17,代码来源:stream_test.py

示例2: main

# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream import write [as 别名]
def main():
  # Start interactive mode
  plt.ion()

  # Load sample
  wavfile  = sp.io.wavfile.read('sample.wav')
  wavdata  = np.float64(wavfile[1])
  wavdata /= np.float64(np.iinfo(wavfile[1].dtype).max)
  wavdata *= 10.0
  stream   = Stream(wavfile[0])
  stream.write(wavdata)

  # Search for training symbol
  training_spectrum = np.array([complex() for x in range(64)])
  training_spectrum[2      + 4*0] = complex(1, 0)
  training_spectrum[2      + 4*1] = complex(1, 0)
  training_spectrum[2      + 4*2] = complex(1, 0)
  training_spectrum[64 - 2 - 4*2] = complex(1, 0)
  training_spectrum[64 - 2 - 4*1] = complex(1, 0)
  training_spectrum[64 - 2 - 4*0] = complex(1, 0)
  training_signal = np.fft.ifft(training_spectrum)*40.0
  training_spectrum /= np.linalg.norm(training_spectrum)
  training_signal   /= np.linalg.norm(training_signal)
  for i in range(len(stream.buffer) - 64):
    window_signal  = stream.buffer[i: i + 64]
    window_signal /= np.linalg.norm(window_signal)
    #window_spectrum = np.fft.fft(window_signal)
    #window_spectrum /= np.linalg.norm(window_spectrum)
    corr = abs(np.correlate(training_signal, window_signal))
    print(corr)
    return
    if(corr > 0.9):
      print('Signal @ %s' % str(i/SAMPLE_RATE))
      stream.pop(i)
      break

  # Display signal
  spectrum = Spectrum(stream, COMPONENETS)
  waveform = Waveform(stream, COMPONENETS)
  spectrum.tick()
  waveform.tick()
  plt.show()
  while(True):
    plt.pause(0.10)
    stream.pop(1)
    spectrum.tick()
    waveform.tick()
开发者ID:d-b,项目名称:CSC372,代码行数:49,代码来源:modem.py


注:本文中的stream.Stream.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。