python批量ping返回时延_python 批量ping地址

#coding=utf-8

import easygui

import subprocess,os

class PingCmd(object):

def __init__(self):

self.msg = easygui.multenterbox("just compute one net","",["start","end"])

self.part_ip = ".".join(self.msg[0].split(".")[0:3])

self.start_point = self.msg[0].split(".")[-1]

self.end_point = self.msg[-1].split(".")[-1]

self.lis = []

def one_by_one(self):

for i in range(int(self.start_point),int(self.end_point)+1):

self.ip = self.part_ip +"." + str(i)

self.result = os.system("ping -n 1 -w 1 " + self.ip)

if not self.result:

self.lis.append(self.ip)

with open("1.txt","w") as file:

file.write(str("\n".join(self.lis)))

else:

pass

ping = PingCmd()

if __name__ == "__main__":

try:

ping.one_by_one()

except Exception,e:

print e

原文:http://www.cnblogs.com/yaxin1989/p/7719881.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
广义互相关时延估计是一种用于信号处理中时延测量的方法,主要用于声学信号处理、雷达系统等领域。在Python中,我们可以使用以下代码来进行广义互相关时延估计仿真: 首先,导入所需的库: ```python import numpy as np import matplotlib.pyplot as plt ``` 接着,生成模拟信号: ```python # 生成信号 fs = 1000 # 采样频率 A = 1 # 信号幅度 t = np.arange(0, 1, 1.0/fs) # 时间序列 f1 = 10 # 信号频率 f2 = 20 # 信号频率 s1 = A * np.sin(2*np.pi*f1*t) s2 = A * np.sin(2*np.pi*f2*t) s = np.concatenate((s1, s2)) ``` 其中,`fs`为采样频率,`A`为信号幅度,`t`为时间序列,`f1`和`f2`为信号频率,`s1`和`s2`为两个信号。这里,我们将两个信号串联在一起,便于后续的广义互相关分析。 接下来,添加一定程度的噪声: ```python # 添加噪声 np.random.seed(0) # 随机种子 noise = np.random.normal(0, 0.5, len(s)) s = s + noise ``` 其中,我们使用正态分布来生成随机噪声,加到之前生成的信号`s`中。 然后,我们使用相关函数计算相互关系,并绘制相关系数随时间的变化曲线: ```python # 相关系数计算 r = np.correlate(s, s, mode='full') / np.max(np.correlate(s, s, mode='full')) # 绘制图像 plt.plot(np.arange(-len(s)+1,len(s)),r) plt.title('Cross-Correlation') plt.xlabel('Lag') plt.ylabel('Correlation Coefficient') plt.show() ``` 在上面代码中,我们使用`np.correlate()`函数计算信号`s`自相关,然后用自相关值除以最大自相关值的结果即为信号的相互关系。接着,我们利用`plt.plot()`函数绘制相关系数随时延(Lag)的变化,以此来进行广义互相关分析。 通过以上代码,我们可以仿真得到一个广义互相关时延估计的过程,并在图像上观察到相关系数随时间呈现出的变化关系。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值