Пример #1
0
def calculate_TDOA_Matrix(signals, array_params):
    #array_params = array_parameters.ArrayParameters(positions)
    array_params = array_default.ArrayDefault()
    Tdoa = basic_tdoa.BasicTDOA(signals, 200, 0.5, array_params)
    
    #calculate TDOA matrix
    n = len(signals.measurements)
    TDOA_mat = np.zeros((n,n))
    for mic1 in range(0,n):
        for mic2 in range(0,n):
            delta_sample = (Tdoa.gcc_phat(signals.measurements[mic1], signals.measurements[mic2]))            
            delta_time = signals.meta_data["sampling_spacing"]*delta_sample
            TDOA_mat[mic1][mic2] = delta_time
    return TDOA_mat
micA_pos = convertPoint(config["microphone_positions"][0])
micB_pos = convertPoint(config["microphone_positions"][1])
source_pos = convertPoint(config["source_position"])

# Source Signal
time = generateTime(meta["sampling_rate"],meta["number_samples"])
source_signal = getSourceSignal(time)

# Do Power Calculations
powerA = getSignalPower_UsingTime_AverageFree(np.asarray(signals[0]))
powerB = getSignalPower_UsingTime_AverageFree(np.asarray(signals[1]))
powerSrc = getSignalPower_UsingTime_AverageFree(source_signal)

# Calculate TDOA
arr = array_parameters.ArrayParameters(config["microphone_positions"])
tdoa = basic_tdoa.BasicTDOA(loaded, 0, 0.0, arr)
delta_n = tdoa.tdoa_gcc_phat(0.0)[1][0][1][0]
delta_t = delta_n*meta["sampling_spacing"]
delta_s = delta_t*343.2

# TDOA LINEAR VERFAHREN
X_NOL_CURVE, Y_NOL_CURVE = KarstenDOA_calculateCurve_nonlinear(micA_pos, micB_pos, delta_s, res=0.01, rang=10)
X_LIN_CURVE, Y_LIN_CURVE = KarstenDOA_calculateCurve_linear(micA_pos, micB_pos, delta_s, res=0.01, rang=10)

# Plot Data
import matplotlib.pyplot as plt

plt.xlim(-10,10)
plt.ylim(0,20)
plt.grid()
plt.title("Geometry")