Search code examples
pythonanglewaveform

DOATools.py - Using my own signal source (NOT generated)


I'm using doatools.py library (https://github.com/morriswmz/doatools.py) Now, my code looks like:

import numpy as np
from scipy import constants as const
import math
import doatools.model as model
import doatools.estimation as estimation



def calculate_wavelength(frequency):
    return const.speed_of_light / frequency


# Uniform circular array
#        X
#        |
#   X---------X
#        |
#        X
NUMBER_OF_ELEMENTS = 4  # elements are shown as "X"
RADIUS = 0.47 / 2
FREQ_MHZ = 315
freq = FREQ_MHZ * const.mega
wavelength = calculate_wavelength(freq)

antenna_array = model.UniformCircularArray(NUMBER_OF_ELEMENTS, RADIUS)

# Create a MUSIC-based estimator.
grid = estimation.FarField1DSearchGrid()
estimator = estimation.MUSIC(antenna_array, wavelength, grid)


R = np.array([[1.5, 2, 3, 4], [4, 5, 6, 5], [45, 5, 5, 6], [5, 1, 0, 5]])

_, estimates = estimator.estimate(R, 1, return_spectrum=False, refine_estimates=True)
print('Estimates: {0}'.format(estimates.locations))

I can generate signal with this library, but how to use my own? For example, signal from ADC (like this:

-> Switching to antenna 0 : [0, 4, 7, 10]
-> Switching to antenna 1 : [5, 6, 11, 83] 
-> Switching to antenna 2 : [0, 23, 2, 34]
-> Switching to antenna 3 : [23, 105, 98, 200]

)


Solution

  • I think your question is how you should feed the real data from antennas, right? Supposedly your data should be in order along time. I mean in case of "antenna 0 : [0, 4, 7, 10]", 0 is the 1st-in data, and 4, 7, in order, and the 10 is the last one in time. If yes, you could leave them as a simple matrix like what you typed above:

    r = matrix 4x4 of
      0, 4, 7, 10
      5, 6, 11, 83 
      0, 23, 2, 34
      23, 105, 98, 200
    
      //===============
    
      r(0,0) = 0,   r(0,1) = 4,  r(0,2) = 7,   r(0,3) = 10
    
      r(1,0) = 5,   r(1,1) = 6,  ... etc.
    
      r(2,0) = 0,   ...etc.
    
      //==============
    

    R = the product of r and its hermitian matrix (r.h in python).

    R = r @ r.h

    And this is the covariance matrix that you need to fill in as the 1st argument in function.