Note

This static document was automatically created from the output of a jupyter notebook.

Execute and modify the notebook online here.

# Implementing Beamformers

This Jupyter notebook will outline the step-by-step process of implementing a new receiving beamformer within the HermesPy framework, using the Minimum Variance Distortionless Response (MVDR, also known as [Cap69]) beamformer as a working example.

As an initial step, we will import all required modules from HermesPy:

[1]:

%%capture
pip install hermespy

[2]:

import numpy as np



The Capon beamformer estimates the power $$\hat{P}$$ received from a direction $$(\theta, \phi)$$, where $$\theta$$ is the zenith and $$\phi$$ is the azimuth angle of interest in spherical coordinates, respectively. Let $$Y \in \mathbb{C}^{M \times N}$$ be the the matrix of $$N$$ time-discrete samples acquired by an antenna arrary featuring $$M$$ antennas and

$$\mathbf{R} = \mathbf{Y}\mathbf{Y}^{\mathsf{H}}$$

be the respective sample correlation matrix. The antenna array’s response towards a source within its far field emitting a signal of small relative bandwidth is $$\mathbf{a}(\theta, \phi) \in \mathbb{C}^{M}$$. Then, the Capon’s spatial power response is defined as

$$\hat{P}_{\mathrm{Capon}}(\theta, \phi) = \frac{1}{\mathbf{a}^{\mathsf{H}}(\theta, \phi) \mathbf{R}^{-1} \mathbf{a}(\theta, \phi)}$$

with

$$\mathbf{w}(\theta, \phi) = \frac{\mathbf{R}^{-1} \mathbf{a}(\theta, \phi)}{\mathbf{a}^{\mathsf{H}}(\theta, \phi) \mathbf{R}^{-1} \mathbf{a}(\theta, \phi)} \in \mathbb{C}^{M}$$

being the beamforming weights to steer the sensor array’s receive characteristics towards direction $$(\theta, \phi)$$, so that

$$\tilde{\mathbf{y}}(\theta, \phi) = \mathbf{w}^\mathsf{H}(\theta, \phi) \mathbf{Y}$$

are the estimated signal samples impinging onto the sensor array from said direction.

The structure of receiving beamformers is implemented as an abstract prototype in the ReceiveBeamformer. Prototypes specify several abstract properties and methods which inheriting classes must implement. For receiving beamformers those are

• num_receive_input_streams - Number of antenna streams the beamformer can process.Our Capon implementation will always require the samples of all device antennas.

• num_receive_output_streams - Number of antenna streams the beamformer generates after processing.Since the Capon beamformer focuses the power towards a single direction of interest per estimation, a single stream of samples will be generated after beamforming.

• num_receive_focus_angles - Number of angles of interest the beamformer requires for its configuration.The same logic as before applies, only a single direction of interest per beamforming operation is required.

• _decode() - This subroutine performs the actual beamforming, given an array of baseband samples, assumed carrier frequency and the angles of interest. This is where the Capon algorithm is being implemented.

[3]:

class CaponBeamformer(ReceiveBeamformer):

def __init__(self, *args, **kwargs) -> None:

@property
return self.operator.device.antennas.num_antennas

@property
return 1

@property
return 1

def _decode(self,
samples: np.ndarray,
carrier_frequency: float,
angles: np.ndarray) -> np.ndarray:

# Compute the inverse sample covariance matrix R
sample_covariance = np.linalg.inv(samples @ samples.T.conj() + 1e-4 * np.eye(samples.shape[0]))

# Query the sensor array response vectors for the angles of interest and create a dictionary from it
for d, focus in enumerate(angles):

array_response = self.operator.device.antennas.spherical_response(carrier_frequency, focus[0, 0], focus[0, 1])
dictionary[:, d] = sample_covariance @ array_response / (array_response.T.conj() @ sample_covariance @ array_response)

beamformed_samples = dictionary.T.conj() @ samples
return beamformed_samples[:, np.newaxis, :]


And that’s it, by specifying three properties and the decode routine a new beamformer has been implemented within HermesPy. We can now plot the beamforming characteristics towards a signal impinging from $$(\theta = 0, \phi = 0)$$ by calling PlotReceivePattern() and compare it to the CoventionalBeamformer:

[4]:

from hermespy.beamforming import ConventionalBeamformer



We may now use the newly created beamforming class to configure receive signal processing chains within HermesPy. For example, within an imaging radar application simulation:

[5]:

from hermespy.simulation import Simulation

# Create a new simulation featuring a single device transmitting at 10GHz
simulation = Simulation()
device = simulation.scenario.new_device()
device.carrier_frequency = 10e9

# Configure a radar operation on the device

# Run a very low-demanding simulation for demonstration purposes
simulation.num_actors = 1
simulation.num_samples = 1
_ = simulation.run()

─────────────────────────────────────────────── Simulation Campaign ───────────────────────────────────────────────

[14:14:50] Launched simulation campaign with 1 dedicated actors                                 monte_carlo.py:1715

           Generating a maximum of 1 = 1 samples inspected by 0 evaluators                      monte_carlo.py:1735


Simulation Grid
┏━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Dimension ┃ Sections ┃
┡━━━━━━━━━━━╇━━━━━━━━━━┩
└───────────┴──────────┘

[14:14:55] Simulation finished after 5.27 seconds                                               monte_carlo.py:1875