#!/usr/bin/python3
import random
import numpy as np
from numpy import linalg as lalg
import math
from sklearn.preprocessing import MultiLabelBinarizer
import doatools.estimation as estimation
from sklearn.metrics import mean_absolute_error
class DataGen:
"""
Class for generating incoming signal data for sensor array processing
"""
def __init__(self):
""" __init__
Arguments:
None
Returns:
None
"""
pass
def generate_random_directions(self, lower_bound, upper_bound, size, scale=None):
""" Returns randomly generated signals between a given interval,
usually the visible spectrum of the sensor array.
Arguments:
lower_bound (int) : defines the lower bound for a random signals
upper_bound (int) : defines the upper bound for a random signals
size (int) : defines the number of signals
Returns:
Randomly generated signals between an azimuthal interval
"""
visible_spectrum = (lower_bound + upper_bound)/2
if scale is None:
scale = (upper_bound-lower_bound)/2
results = []
while len(results) < size:
signal_dirs = np.random.normal(loc=visible_spectrum, scale=scale, size=size-len(results))
signal_dirs = np.round(signal_dirs,1)
results += [sample for sample in signal_dirs if lower_bound <= sample <= upper_bound]
return np.array(results )
def hermitian(self, A, **kwargs): ##define hermitian
""" hermitian
Arguments:
A (complex) : Complex valued matrix
Returns:
Conjugate transpose of the input matrix
"""
return np.transpose(A, **kwargs).conj()
def convert_to_rad(self, value_degree):
""" convert_to_rad
Arguments:
value_degree (float) : angles in degrees
Returns:
angles in radians
"""
return value_degree * math.pi/180
def generate_qpsk_signals(self, signal_dir_rad, sensor_position, NUMBER_OF_SENSORS, NOISE_VARIANCE, NUMBER_OF_SNAPSHOTS, NUMBER_OF_SOURCES, CARRIER_WAVELENGTH):
phi = 2*math.pi*np.sin(np.tile(signal_dir_rad,[NUMBER_OF_SENSORS, 1]))
D_u = np.tile(sensor_position, [1, NUMBER_OF_SOURCES])
steervec_u = np.exp(1j * phi * (D_u/CARRIER_WAVELENGTH)) #uniform steering vectors
symbols = np.sign(np.random.randn(NUMBER_OF_SNAPSHOTS, NUMBER_OF_SOURCES)) + 1j*np.sign(np.random.randn(NUMBER_OF_SNAPSHOTS, NUMBER_OF_SOURCES)) #QPSK symbols
x_u = np.zeros(([NUMBER_OF_SENSORS, NUMBER_OF_SNAPSHOTS]), dtype=complex)
for i in range(NUMBER_OF_SNAPSHOTS):
x_u[:,i] = np.sum(np.tile(symbols[i,:],[NUMBER_OF_SENSORS, 1])*steervec_u,1) #uniformly sampled data
noise = NOISE_VARIANCE * np.random.randn(x_u.shape[0],x_u.shape[1]) + 1j * NOISE_VARIANCE * np.random.randn(x_u.shape[0],x_u.shape[1])
x_u = x_u + noise
return x_u
def get_rootmusic_estimate(self, input_data, frequency, sources):
estimator = estimation.music.RootMUSIC1D(frequency)
covariance_matrix = input_data.dot(self.hermitian(input_data))
resolved, estimates = estimator.estimate(covariance_matrix, sources, unit='deg')
angle_estimate = estimates.locations
return angle_estimate
def splitandweave_complex_input(self, input_real, input_imag, output_tensor, iteration, number_sensor):
""" splitandweave_complex_input
Arguments:
input_real (float) : real part of the matrix (size: M * N * L)
input_imag (float) : imaginary part of the matrix (size: M * N * L)
Returns:
split and interweaved tensor for (size: N * 2L)
"""
for i in range(iteration):
p=0
for k in range(number_sensor): #WAS L
output_tensor[i,:,p] = input_real[i,:,k]
p=p+1
output_tensor[i,:,p] = input_imag[i,:,k]
p=p+1
return output_tensor
class AmpPhaseFeatureExtract(DataGen):
def __init__(self):
pass
def get_parsed_amplitude(self, input_real,input_imag): #start here
""" get_parsed_amplitude
Arguments:
input_real (float) : real part of the matrix (size: N * L)
input_imag (float) : imaginary part of the matrix (size: N * 2L)
Returns:
computed magnitude marix of the complex input matrix (size: N * L)
"""
x_amp = np.sqrt(np.square(input_real)+np.square(input_imag))
return x_amp
def get_parsed_phase(self, input_real,input_imag):
""" get_parsed_amplitude
Arguments:
input_real (float) : real part of the matrix (size: N * L)
input_imag (float) : imaginary part of the matrix (size: N * 2L)
Returns:
computed phase marix of the complex input matrix (size: N * L)
"""
div = input_imag/input_real
x_phase = np.arctan(div)
return x_phase
class UpperTriFeatureExtract(DataGen):
def __init__(self):
pass
def get_upper_tri(self, covmat,number_sensors):
""" get_upper_tri
Arguments:
covmat (float) : covariance matrix
number_sensors (int) : number of sensors in the array
Returns:
right upper triangle of the square matix
"""
upper_tri = covmat[np.triu_indices(number_sensors)]
return upper_tri
def get_parse_upper_tri(self,norm_upperd_r,norm_upperd_i):
""" parseinput
Arguments:
norm_upperd_r (float) : real part of the input data (square matrix)
norm_upperd_i (float) : imaginary part of the input data (square matrix)
Returns:
upper triangle of the square matrix including the diagonal
"""
output_shape = 2 * len(norm_upperd_r)
output_vector = np.zeros(output_shape,)
p=0
for k in range(len(norm_upperd_i)):
output_vector[p] = norm_upperd_r[k]
p=p+1
output_vector[p] = norm_upperd_i[k]
p=p+1
return output_vector
def get_normalized_input(self, input_data):
""" parseamplitude
Arguments:
None
Returns:
None
"""
l1_norm = lalg.norm(input_data,1)
norm_input = input_data/l1_norm
return norm_input
def get_off_uppertri(self, covmat, number_sensors): # TODO: fix naming
""" get_uppertri
Arguments:
covmat (float) : covariance matrix
number_sensors (int) : number of sensors in the array
Returns:
one off right upper triangle of the square matix (no diagonal)
"""
off_upper_tri = covmat[np.triu_indices(number_sensors, k=1)]
return off_upper_tri
class DiscreteTargetSpectrum(DataGen):
def __init__(self):
pass
def get_integize_target(self, target):
""" get_integize_target
Arguments:
target (float) : degress of incoming signals
Returns:
integized target values
"""
target = [v*10 for v in target]
return target
def get_encoded_target(self, spectrum, target):
""" get_encoded_target
Arguments:
target (float) : degress of incoming signals
Returns:
one hot encoded target vector with respect to the spectrum
"""
encoder = MultiLabelBinarizer()
encoder.fit([spectrum])
没有合适的资源?快使用搜索试试~ 我知道了~
基于随机传感器位置的深度学习DOA估计
共75个文件
profile-empty:18个
desktop:18个
trace:18个
需积分: 1 5 下载量 40 浏览量
2023-10-07
22:26:17
上传
评论
收藏 228.71MB ZIP 举报
温馨提示
基于随机传感器位置的深度学习DOA估计
资源推荐
资源详情
资源评论
收起资源包目录
Deep-Learning-for-DOA-Estimation-WIth-Random-Sensor-Positions-master.zip (75个子文件)
Deep-Learning-for-DOA-Estimation-WIth-Random-Sensor-Positions-master
LICENSE 34KB
CNNforRegression
CNN_DOA_def.py 2KB
CNN_DOA.py 2KB
modified-architecture-optimization.py 4KB
Datagen-CNN-new.py 3KB
Datagen_ULA.py 3KB
alexnet-AOA.py 2KB
datagen.py 8KB
EnsemleNetwork
[2]-dense-128-layersize-run3-1579084490.hdf5 716KB
exp2
learn_randsignal.py 6KB
randomsignal_datagen.py 5KB
[2]-dense-128-layersize-run3-1579167359.hdf5 716KB
Y_data_randsig_aps.pickle 45.78MB
logs
[2]-dense-128-layersize-run3-1579162819
events.out.tfevents.1579162820.Desktop.profile-empty 40B
plugins
profile
2020-01-16_01-20-20
local.trace 21KB
events.out.tfevents.1579162819.Desktop 1.49MB
[2]-dense-128-layersize-run3-1579162332
plugins
profile
2020-01-16_01-12-13
local.trace 21KB
events.out.tfevents.1579162333.Desktop.profile-empty 40B
events.out.tfevents.1579162332.Desktop 821KB
[2]-dense-128-layersize-run3-1579162720
plugins
profile
2020-01-16_01-18-41
local.trace 17KB
events.out.tfevents.1579162721.Desktop.profile-empty 40B
events.out.tfevents.1579162720.Desktop 1.26MB
[2]-dense-128-layersize-run3-1579161794
events.out.tfevents.1579161795.Desktop 222KB
plugins
profile
2020-01-16_01-03-15
local.trace 20KB
events.out.tfevents.1579161795.Desktop.profile-empty 40B
[2]-dense-128-layersize-run3-1579161886
events.out.tfevents.1579161887.Desktop.profile-empty 40B
plugins
profile
2020-01-16_01-04-47
local.trace 16KB
events.out.tfevents.1579161886.Desktop 407KB
[2]-dense-128-layersize-run3-1579162931
plugins
profile
2020-01-16_01-22-12
local.trace 21KB
events.out.tfevents.1579162932.Desktop.profile-empty 40B
events.out.tfevents.1579162931.Desktop 1.84MB
[2]-dense-128-layersize-run3-1579162616
events.out.tfevents.1579162617.Desktop 1.08MB
plugins
profile
2020-01-16_01-16-57
local.trace 26KB
events.out.tfevents.1579162617.Desktop.profile-empty 40B
[2]-dense-128-layersize-run3-1579162145
plugins
profile
2020-01-16_01-09-06
local.trace 17KB
events.out.tfevents.1579162145.Desktop 587KB
events.out.tfevents.1579162146.Desktop.profile-empty 40B
[2]-dense-128-layersize-run3-1579167359
events.out.tfevents.1579167360.Desktop 2.29MB
plugins
profile
2020-01-16_02-36-02
local.trace 22KB
events.out.tfevents.1579167362.Desktop.profile-empty 40B
positions-nu_randsig_aps.pickle 237B
X_data_randsig_aps.pickle 45.78MB
randomsignal_datagen.py 5KB
Y_data_randsig_aps.pickle 76.29MB
logs
[2]-dense-128-layersize-run3-1579084347
events.out.tfevents.1579084354.Desktop.profile-empty 40B
plugins
profile
2020-01-15_03-32-34
local.trace 22KB
events.out.tfevents.1579084348.Desktop 10.73MB
[2]-dense-128-layersize-run3-1579084490
plugins
profile
2020-01-15_03-34-58
local.trace 22KB
events.out.tfevents.1579084498.Desktop.profile-empty 40B
events.out.tfevents.1579084492.Desktop 11.48MB
[2]-dense-128-layersize-run3-1579084194
events.out.tfevents.1579084196.Desktop 10.49MB
plugins
profile
2020-01-15_03-30-02
local.trace 27KB
events.out.tfevents.1579084202.Desktop.profile-empty 40B
[2]-dense-128-layersize-run3-1579078742
events.out.tfevents.1579078744.Desktop 9.5MB
plugins
profile
2020-01-15_01-59-09
local.trace 23KB
events.out.tfevents.1579078749.Desktop.profile-empty 40B
[2]-dense-128-layersize-run3-1579083989
events.out.tfevents.1579083990.Desktop 10.2MB
plugins
profile
2020-01-15_03-26-36
local.trace 22KB
events.out.tfevents.1579083996.Desktop.profile-empty 40B
2-dense-128-layersize-run3-1579076853
plugins
profile
2020-01-15_01-27-39
local.trace 17KB
events.out.tfevents.1579076859.Desktop.profile-empty 40B
events.out.tfevents.1579076854.Desktop 9.04MB
[2]-dense-128-layersize-run3-1579078351
plugins
profile
2020-01-15_01-52-38
local.trace 22KB
events.out.tfevents.1579078353.Desktop 9.26MB
events.out.tfevents.1579078358.Desktop.profile-empty 40B
[2]-dense-128-layersize-run3-1579078913
events.out.tfevents.1579078915.Desktop 9.74MB
plugins
profile
2020-01-15_02-02-00
local.trace 22KB
events.out.tfevents.1579078920.Desktop.profile-empty 40B
[2]-dense-128-layersize-run3-1579080621
plugins
profile
2020-01-15_02-30-28
local.trace 22KB
events.out.tfevents.1579080628.Desktop.profile-empty 40B
events.out.tfevents.1579080623.Desktop 9.99MB
positions-nu_randsig_aps.pickle 237B
train_interpolator.py 3KB
datagen.py 8KB
X_data_randsig_aps.pickle 76.29MB
共 75 条
- 1
资源评论
Older司机渣渣威
- 粉丝: 6
- 资源: 202
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功