Antenna Arrays And Python – The Array (finally!)

As mentioned in my intro post an array antenna is a set of individual antennas connected to work as a single antenna. So far we’ve covered the individual antennas, i.e. the square patches, now it’s time to look at how they can be connected to work together.

Array Factor Fun

You can’t get far digging into arrays before you come across the Array Factor. It looks complicated but to me the easiest way to think of it is that it combines every elements position, radiating amplitude and radiating phase to give the overall array performance.

The Array Factor demonstrates that by altering an element, such as its position or phase, we can alter the arrays properties. For example the arrays beam could be steered to a desired position by altering the phase of each element.

The Array Factor is given by:


θ, φ = Direction from origin

N = number of elements

An= Amp of element

βn = Phase of element in rads

k0 = 2π/λ rads/m


is the relative phase of incident wave at element n located at xn, yn, zn.

Array Factor in Python

The script below shows how easy it is to calculate the Array Factor in Python:

Array Radiation Pattern, Directivity & Gain

The above Array Factor equation is independent of each elements individual radiating pattern. The overall radiation pattern of an array is determined by the array factor combined with the radiation pattern of each element, Fn(θn, φn), giving:

The overall radiation pattern results in a certain directivity and thus gain linked through the efficiency as discussed previously.

Some Examples

To demonstrate the effects the individual element patterns have on the overall array performance we can investigate some examples using Python.

Isotropic antenna elements

In this case each element radiates equally in all directions so Fn(θn, φn) is the same for each θn, φn. The antenna radiation pattern is now just the Array Factor as described in the code above.

15×15 Array of Isotropic Elements

Patch antenna elements

Using elements described by the PatchFunction discussed previously:

PatchFunction(θ, φ, Freq, 10.7e-3, 10.47e-3, 3e-3, 2.5)
15×15 Array of patches

Python script for patch array:

Horn antenna elements

And finally using horn antenna elements represented by cos²⁸(θ) function.

15×15 Array of cos²⁸(θ) Horns

Python script for horn array:

Next time we can see how to calculate an elements phase to steer the beam.

Antenna Arrays And Python – Patch Efficiency & Gain

Last post I dealt with antenna directivity, this post discusses antenna gain which is closely related.

Gain combines an antennas directivity and efficiency to describe how good it is at sending/receiving power in a direction. This is useful for things like link budget analysis which basically calculates if two antennas can communicate.

Antenna Gain, G, can be calculate from the directivity, D, and antenna efficiency, εr by:

The efficiency of an antenna describes how well the input power is radiated by the antenna (and due to reciprocity receive efficiency is the same as transmit efficiency):

A high efficiency antenna will radiate most of the input power while a low efficiency antenna will lose a lot of the input power before it is radiated due to things like dielectric loss, impedance mismatch, etc.

Patch Efficiency

The Python script at the bottom of the post is based on the ArrayCalc calc_patchr_eff.m file and defines a function, CalculatePatchEff, that calculate the efficiency of a rectangular patch based on the patch dimensions and materials. The comments provide some example material properties and the main function has some examples that demonstrate the effects of the material selection on the efficiency:

FR4 Patch, 14GHz, Efficiency = 47.27%

RO4350 Patch, 14GHz, Efficiency = 62.32%

Python Script

Antenna Arrays And Python – Calculating Directivity

Directivity is a measure of how directional an antenna’s radiation pattern is. For example an antenna that radiates strongly in one direction has a high directivity while an antenna that radiates equally in all directions has a low directivity.

It is not necessarily a bad thing to have an antenna with low directivity, it depends on the application. For example:

To communicate with a geosynchronous satellite 35,786km away we need an antenna that produces a strong beam directed towards the satellite. In this case a parabolic dish antenna is often used because it has a high directivity.

Alternatively a mobile phone needs to be able to connect to a cell tower no matter what orientation the phone is held which means no matter what direction it’s antenna is pointing. In this case an antenna with a low directivity is used so that the antenna can receive/transmit well in any direction.


Mobile Phone Pattern — Low Directivity


Dish Pattern — High Directivity

Calculating Directivity

Directivity can be calculated using the equation below which basically means the max value of radiated power divided by the average power in all directions:


Directivity is often expressed in dBi and represents the dB ratio with respect to an isotropic radiator.

Python Script –

The gist below shows my Python script for calculating the directivity (based on the ArrayCalc calc_directivity.m file).

The main function is:

CalcDirectivity(Efficiency, RadPatternFunction, *args)

This takes a function argument, RadPatternFunction, as an input. This function should describe the antennas radiation pattern in terms of theta and phi.

At the bottom of the script there are some basic examples showing how to calculate the directivity for three different radiation patterns – an isotropic antenna and two sin functions. Below this there are also two examples calculating the directivity for rectangular patches using the functions discussed in my Square Patch Element post.

The efficiency argument to RadPatternFunction is related to the Gain of the antenna and will be discussed in my next post.

Antenna Arrays And Python – Plotting with Pyplot

One of the most useful things to see when investigating an antenna design is the radiation pattern – a plot showing where the antenna transmits or receives power. In the previous post a Python function was developed for a square patch that calculated the total E-field pattern as a function of theta and phi. Now I want to plot this E-field which will show the radiation pattern.


I don’t have a great deal of experience with visualisation or plotting in Python but I have used matplotlib before and found it relatively ok. matplotlib is a plotting library for the Python programming language and Pyplot is a matplotlib module that provides a collection of command style functions to make matplotlib work like MATLAB.

This Pyplot tutorial covers the basics and I find the gallery useful to find example code.

E-plane & H-plane plots

First plots I wanted to see were for E-field vs 0°<theta<90 °for phi cuts at 0° and 90°. Referring to the patch geometry we described earlier this will give us the E-plane (phi = 0°) and the H-plane (phi = 90°).

Patch geometry

An example plot of a patch with W=7mm, L=5.58mm, Er=3.66, h=10.1mm is shown below. The complete Python script can be found at the end of the post with the relevant function being: PatchEHPlanePlot(freq, W, L, h, Er).

Example E&H-Plane plot

3d surface plot

The next plot I wanted was a 3D plot of the E-field across all phi and theta values. This will allow the visualisation of things like the main beam direction, side lobes, etc. While it is nice to see this for the patch it will be very helpful when it comes to investigating a full array.

An example of the surface plot for the same rectangular microstrip element is shown below and was plotted using the SurfacePlot(Fields) function in the code.

Patch Surface Plot

Patch Script

The completed patch script can be seen below. It consists of the following functions:

main: Some examples of various patch designs.

DesignPatch(Er, h, Freq): Theory taken from ArrayCalc. It returns the patch L & W for specified Er, h and freq.

SurfacePlot(Fields, Freq, W, L, h, Er): Plots a 3D surface of the field.

PatchEHPlanePlot(Freq, W, L, h, Er, isLog=True): Plots the 2D E&H-planes.

GetPatchFields(PhiStart, PhiStop, ThetaStart, ThetaStop, Freq, W, L, h, Er): Returns an array with fields for patch over phi and theta range.

PatchFunction(thetaInDeg, phiInDeg, Freq, W, L, h, Er): Calculates total E-field pattern for patch as a function of theta and phi as detailed in previous post.