|
|
|
|
@ -1,11 +1,12 @@
|
|
|
|
|
import pandas as pd
|
|
|
|
|
import os
|
|
|
|
|
import numpy
|
|
|
|
|
import json
|
|
|
|
|
import datetime
|
|
|
|
|
import warnings
|
|
|
|
|
|
|
|
|
|
warnings.filterwarnings ('ignore')
|
|
|
|
|
|
|
|
|
|
InterDis = 155
|
|
|
|
|
TH_N = 10
|
|
|
|
|
f_stat = "./exata.stat"
|
|
|
|
|
f_dir = '.\\jammerDetect'
|
|
|
|
|
|
|
|
|
|
@ -48,6 +49,8 @@ def readall(path):
|
|
|
|
|
if f.endswith('00_0.stat'):
|
|
|
|
|
df = read_stat(statfile)
|
|
|
|
|
out_file = f[:-7]+'-r.csv'
|
|
|
|
|
lr_file = f[:-7]+'-model.csv'
|
|
|
|
|
res_file = f[:-10]
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
if df is None:
|
|
|
|
|
@ -56,7 +59,12 @@ def readall(path):
|
|
|
|
|
df = read_stat(statfile, df)
|
|
|
|
|
|
|
|
|
|
df.to_csv(out_file)
|
|
|
|
|
return df
|
|
|
|
|
df.to_csv(out_file)
|
|
|
|
|
|
|
|
|
|
ndf = divide(out_file)
|
|
|
|
|
tagging(ndf, res_file)
|
|
|
|
|
ndf.to_csv(lr_file)
|
|
|
|
|
return ndf
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def divide(csvf):
|
|
|
|
|
@ -80,8 +88,47 @@ def divide(csvf):
|
|
|
|
|
return ndf
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def tagging(df, rf):
|
|
|
|
|
lend = len(df)
|
|
|
|
|
assert lend % 2 == 0
|
|
|
|
|
#print(len(df))
|
|
|
|
|
with open(rf, 'r', encoding='utf-8') as f:
|
|
|
|
|
result = json.load(f)
|
|
|
|
|
lenr = len(result)
|
|
|
|
|
assert 4*(lenr-2) == lend
|
|
|
|
|
df['flag'] = 0
|
|
|
|
|
df['isDetect'] = 0
|
|
|
|
|
for i in range(lenr-2):
|
|
|
|
|
res = result[i+2][1:]
|
|
|
|
|
print(res)
|
|
|
|
|
if res[0]['d25'] <= InterDis:
|
|
|
|
|
df['flag'][4*i+2] = 1
|
|
|
|
|
if res[0]['d45'] <= InterDis:
|
|
|
|
|
df['flag'][4*i+3] = 1
|
|
|
|
|
|
|
|
|
|
if res[1][0] > TH_N:
|
|
|
|
|
if res[1][1] >= 2*res[1][0]/3: # node4 探测到
|
|
|
|
|
df['isDetect'][4*i+1] = 1
|
|
|
|
|
elif res[1][1] <= res[1][0]/3: # node2 探测到
|
|
|
|
|
df['isDetect'][4 * i] = 1
|
|
|
|
|
else: # 都探测到
|
|
|
|
|
df['isDetect'][4 * i] = 1
|
|
|
|
|
df['isDetect'][4 * i + 1] = 1
|
|
|
|
|
|
|
|
|
|
if res[2][0] > TH_N:
|
|
|
|
|
if res[1][1] >= 2*res[1][0]/3: # node4 探测到
|
|
|
|
|
df['isDetect'][4*i+3] = 1
|
|
|
|
|
elif res[1][1] <= res[1][0]/3: # node2 探测到
|
|
|
|
|
df['isDetect'][4 * i + 2] = 1
|
|
|
|
|
else: # 都探测到
|
|
|
|
|
df['isDetect'][4 * i + 2] = 1
|
|
|
|
|
df['isDetect'][4 * i + 3] = 1
|
|
|
|
|
print(df)
|
|
|
|
|
return(df)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
#df = readall(f_dir)
|
|
|
|
|
#print(df)
|
|
|
|
|
divide('20220930-09_11-00-r.csv')
|
|
|
|
|
df = readall(f_dir)
|
|
|
|
|
print(df)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|